From 55f725a502011155f0943f2340ef3763f014ccc0 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 26 Apr 2020 15:48:24 +0300 Subject: Initial commit --- postgrest/migrations/001-initial.sql | 1 + postgrest/migrations/002-todos.sql | 9 +++++++++ postgrest/migrations/003-roles.sql | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 postgrest/migrations/001-initial.sql create mode 100644 postgrest/migrations/002-todos.sql create mode 100644 postgrest/migrations/003-roles.sql (limited to 'postgrest/migrations') diff --git a/postgrest/migrations/001-initial.sql b/postgrest/migrations/001-initial.sql new file mode 100644 index 0000000..be41377 --- /dev/null +++ b/postgrest/migrations/001-initial.sql @@ -0,0 +1 @@ +create schema api; diff --git a/postgrest/migrations/002-todos.sql b/postgrest/migrations/002-todos.sql new file mode 100644 index 0000000..5efb477 --- /dev/null +++ b/postgrest/migrations/002-todos.sql @@ -0,0 +1,9 @@ +create table api.todos ( + id serial primary key, + done boolean not null default false, + task text not null, + due timestamptz +); + +-- insert into api.todos (task) values +-- ('finish tutorial 0'), ('pat self on back'); diff --git a/postgrest/migrations/003-roles.sql b/postgrest/migrations/003-roles.sql new file mode 100644 index 0000000..86e49f0 --- /dev/null +++ b/postgrest/migrations/003-roles.sql @@ -0,0 +1,15 @@ +-- authenticator role +create role authenticator noinherit login password 'mysecretpassword'; + +-- web_anon role +create role web_anon nologin; +grant usage on schema api to web_anon; +grant web_anon to authenticator; +-- grant select on api.todos to web_anon; + +-- todo_user role +create role todo_user nologin; +grant usage on schema api to todo_user; +grant all on api.todos to todo_user; +grant usage, select on sequence api.todos_id_seq to todo_user; +grant todo_user to authenticator; -- cgit v1.3