setup/postgres/psql_create_database.sql

Sun, 26 Nov 2017 16:51:57 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 26 Nov 2017 16:51:57 +0100
changeset 5
131903fc16b8
parent 2
setup/01_create_database.sql@fcb452578142
child 16
4e0998805276
permissions
-rw-r--r--

moves psql DB setup script to another file (we want to support other engines later) + adds some missing statements to that file

universe@2 1 -- Create a database owner role, which has no login permissions.
universe@2 2 -- You can either:
universe@2 3 -- 1) login as default user and switch the user
universe@2 4 -- 2) decide to override this decision and give login permissions
universe@2 5 -- 3) use your superuser of choice to manage the database (not recommended!)
universe@2 6 create role lightpit_dbo with password 'lpit_dbo_changeme';
universe@2 7
universe@2 8 -- Create the actual (unprivileged) database user
universe@2 9 create user lightpit_user with password 'lpit_user_changeme';
universe@2 10
universe@2 11 -- Create the LightPIT schema
universe@2 12 create schema lightpit authorization lightpit_dbo;
universe@5 13 grant usage on schema lightpit to lightpit_user;
universe@2 14
universe@2 15 -- Grant basic privileges to user (the granting user must be the dbo)
universe@2 16 alter default privileges for role lightpit_dbo in schema lightpit
universe@2 17 grant select, insert, update, delete on tables to lightpit_user;
universe@2 18 alter default privileges for role lightpit_dbo in schema lightpit
universe@2 19 grant usage, select on sequences to lightpit_user;
universe@2 20 alter default privileges for role lightpit_dbo in schema lightpit
universe@2 21 grant execute on functions to lightpit_user;
universe@2 22 alter default privileges for role lightpit_dbo in schema lightpit
universe@2 23 grant usage on types to lightpit_user;
universe@5 24
universe@5 25 -- restrict the search path to the lightpit schema
universe@5 26 alter role lightpit_dbo set search_path to lightpit;
universe@5 27 alter role lightpit_user set search_path to lightpit;

mercurial