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