From 9ab762e8e75755d9d836b45fa2b995d99ed69586 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Wed, 8 Aug 2018 09:05:24 +0100 Subject: [PATCH] Make User ID a uuid, reference user and building in edit log. --- migrations/001.create-core.up.sql | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/migrations/001.create-core.up.sql b/migrations/001.create-core.up.sql index 10eaf059..20efb5bd 100644 --- a/migrations/001.create-core.up.sql +++ b/migrations/001.create-core.up.sql @@ -40,14 +40,12 @@ CREATE INDEX building_geometry_idx ON buildings ( geometry_id ); -- Minimal user data to support login and edit history CREATE TABLE users ( -- internal unique id - user_id serial PRIMARY KEY, + user_id uuid PRIMARY KEY, -- username for login (required) - username varchar UNIQUE NOT NULL, + username varchar(30) UNIQUE NOT NULL, -- email address for password reset (optional) email varchar(50), - -- salt - to be generated by application - salt varchar (20), - -- password - as generated application from hash(salt+password) + -- password - as generated from hash(salt+password) via pgcrypto pass varchar(60) ); @@ -65,11 +63,14 @@ CREATE TABLE log ( -- default timestamp to time now log_timestamp TIMESTAMP default NOW(), -- log document to be extended in application - -- log change action (CREATE/UPDATE/DELETE) + -- log change diff (CREATE/UPDATE/DELETE) log_doc jsonb, -- log user id - user_id integer REFERENCES users + user_id uuid REFERENCES users, + -- log building id + building_id integer REFERENCES buildings ); CREATE INDEX log_timestamp_idx ON log ( log_timestamp ); CREATE INDEX log_user_idx ON log ( user_id ); +CREATE INDEX log_building_idx ON log ( building_id );