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 );