Make User ID a uuid, reference user and building in edit log.

This commit is contained in:
Tom Russell 2018-08-08 09:05:24 +01:00
parent 9711385963
commit 9ab762e8e7

View File

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