.. | ||
unreleased | ||
001.core.down.sql | ||
001.core.up.sql | ||
002.index-geometries.down.sql | ||
002.index-geometries.up.sql | ||
003.index-buildings.down.sql | ||
003.index-buildings.up.sql | ||
004.location-date-size-like.down.sql | ||
004.location-date-size-like.up.sql | ||
005.limit-likes.down.sql | ||
005.limit-likes.up.sql | ||
006.controls.down.sql | ||
006.controls.up.sql | ||
007.date-details.down.sql | ||
007.date-details.up.sql | ||
008.search.up.sql | ||
009.user-deleted.down.sql | ||
009.user-deleted.up.sql | ||
010.password-reset.down.sql | ||
010.password-reset.up.sql | ||
011.sustainability.down1-extra.sql | ||
011.sustainability.down.sql | ||
011.sustainability.up1-extra.sql | ||
011.sustainability.up.sql | ||
012.type.down.sql | ||
012.type.up.sql | ||
013.bulk-extracts.down.sql | ||
013.bulk-extracts.up.sql | ||
014.block-users.down.sql | ||
014.block-users.up.sql | ||
015.bulk_data_sources.down.sql | ||
015.bulk_data_sources.up.sql | ||
016.landuse.down.sql | ||
016.landuse.up.sql | ||
017.construction-materials.down.sql | ||
017.construction-materials.up.sql | ||
018.verification.down.sql | ||
018.verification.up.sql | ||
019.simple-dynamics.down.sql | ||
019.simple-dynamics.up.sql | ||
020.dynamics-bool.down.sql | ||
020.dynamics-bool.up.sql | ||
021.building-user-attributes.down.sql | ||
021.building-user-attributes.up.sql | ||
022.community.down.sql | ||
022.community.up.sql | ||
023.garden_buildings.down.sql | ||
023.garden_buildings.up.sql | ||
024.unclassified_buildings.down.sql | ||
024.unclassified_buildings.up.sql | ||
025.state_to_government.down.sql | ||
025.state_to_government.up.sql | ||
026.community_use.down.sql | ||
026.community_use.up.sql | ||
027.demolish-date.down.sql | ||
027.demolish-date.up.sql | ||
028.landuse-source.down.sql | ||
028.landuse-source.up.sql | ||
029.team.down.sql | ||
029.team.up.sql | ||
030.planning_expected.down.sql | ||
030.planning_expected.up.sql | ||
031.landowner.down.sql | ||
031.landowner.up.sql | ||
032.planning_nhle.down.sql | ||
032.planning_nhle.up.sql | ||
033.redesign_protection_designation.down.sql | ||
033.redesign_protection_designation.up.sql | ||
034.planning_livestream_data.down.sql | ||
034.planning_livestream_data.up.sql | ||
035.additional_crowdsourcing_planning_data.down.sql | ||
035.additional_crowdsourcing_planning_data.up.sql | ||
036.borough_borders_and_labels.down.sql | ||
036.borough_borders_and_labels.up.sql | ||
037.is_domestic.down.sql | ||
037.is_domestic.up.sql | ||
038.survival_status.down.sql | ||
038.survival_status.up.sql | ||
039.disaster_status.down.sql | ||
039.disaster_status.up.sql | ||
040.ui_revamp_sources.down.sql | ||
040.ui_revamp_sources.up.sql | ||
041.ui_revamp_tweaks.down.sql | ||
041.ui_revamp_tweaks.up.sql | ||
README.md |
Database setup
Initial setup, on first connection (replacing hostname, username, port, dbname as required):
$ psql "host={hostname} user={username} port={port} sslmode=require dbname=postgres"
> create database colouringlondon;
> \c colouringlondon
> create extension postgis;
> create extension pgcrypto;
> create extension pg_trgm;
> \q
To run all up migrations:
$ ls ./*.up.sql 2>/dev/null | while read -r migration; do psql < $migration; done;
Or all down migrations in reverse order:
$ ls -r ./*.down.sql 2>/dev/null | while read -r migration; do psql < $migration; done;
Create an app user:
-- role for server-side of front end (HTTP POST)
CREATE ROLE appusername WITH LOGIN;
-- create/update, authenticate and authorise users
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE users, user_sessions TO appusername;
-- join users against categories and access levels
GRANT SELECT ON TABLE user_access_levels, user_categories TO appusername;
-- read/write building data
GRANT SELECT, UPDATE ON TABLE buildings TO appusername;
GRANT SELECT, INSERT, DELETE ON TABLE building_user_likes TO appusername;
GRANT SELECT ON TABLE building_properties TO appusername;
-- read geometry data
GRANT SELECT ON TABLE geometries TO appusername;
-- read/append to logs
GRANT SELECT, INSERT ON TABLE logs to appusername;
-- use id sequences
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public to appusername;
-- use postgis/pgcrypto functions
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO appusername;
-- read map search locations
GRANT SELECT ON TABLE search_locations to appusername;
-- add/save user building attribute verification
GRANT SELECT, INSERT, DELETE ON TABLE building_verification TO appusername;
Set or update passwords:
psql -c "ALTER USER appusername WITH PASSWORD 'longsecurerandompassword';"
File naming syntax
Initial up and down migrations as ###.name.up.sql
file number should be sequential
and incremental to last migrations file number is same for up/down.
If adjusting a prior migration syntax is:
###.name.up.sql
Syntax for adding to existing migration:
0##.filename-extension-#.up.sql