From eecf436aaaae2354780944876524ef83de385d6b Mon Sep 17 00:00:00 2001 From: Andrea Zucchelli Date: Sun, 26 Feb 2017 12:34:17 +0100 Subject: [PATCH] map table and ts update trigger --- scripts/db/postgresql/schema.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/db/postgresql/schema.sql b/scripts/db/postgresql/schema.sql index 0ac9ffe..11cffa4 100644 --- a/scripts/db/postgresql/schema.sql +++ b/scripts/db/postgresql/schema.sql @@ -14,3 +14,22 @@ role_list user_role[] not null default ARRAY['USER'::user_role], user_data jsonb ); +create table maps( +id bigserial primary key, +name text not null, +description text, +owner integer not null references users(id), +createts timestamptz not null default now(), +updatets timestamptz not null default now(), +map_data jsonb +); + +create or replace function update_ts_tg() returns trigger as $$ +begin +new.updatets:=now(); +return new; +end; +$$ +language plpgsql; +create trigger tg_update_ts before update on users for each row execute procedure update_ts_tg(); +create trigger tg_update_ts before update on maps for each row execute procedure update_ts_tg();