-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Less smart database setup, single user for the app
Makes this run on Scaleway where you only get a single database user. Can probably be improved later.
- Loading branch information
Showing
10 changed files
with
61 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
*.tmp.* | ||
tmp | ||
*.tmp | ||
*.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
\c postgres | ||
|
||
SELECT PG_TERMINATE_BACKEND(pid) | ||
FROM pg_stat_activity | ||
WHERE datname = 'skjera'; | ||
|
||
DROP DATABASE IF EXISTS skjera; | ||
DROP ROLE IF EXISTS "skjera-backend"; | ||
DROP ROLE IF EXISTS "skjera-owner"; | ||
|
||
--- | ||
-- This is a psql script, not a generic sql script | ||
|
||
CREATE DATABASE skjera; | ||
|
||
\c skjera | ||
|
||
CREATE ROLE "skjera-backend" WITH LOGIN ENCRYPTED PASSWORD 'skjera-backend'; | ||
-- GRANT ALL ON DATABASE skjera to "skjera-backend"; | ||
|
||
CREATE ROLE "skjera-owner" WITH LOGIN ENCRYPTED PASSWORD 'skjera-owner'; | ||
GRANT ALL ON DATABASE skjera TO "skjera-owner"; | ||
|
||
\c skjera | ||
|
||
GRANT ALL ON SCHEMA public TO "skjera-owner"; | ||
GRANT USAGE ON SCHEMA public TO "skjera-backend"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- This is a psql script, not a generic sql script | ||
|
||
\c postgres | ||
|
||
SELECT PG_TERMINATE_BACKEND(pid) | ||
FROM pg_stat_activity | ||
WHERE datname = 'skjera'; | ||
|
||
DROP DATABASE IF EXISTS skjera; | ||
DROP ROLE IF EXISTS "skjera-backend"; | ||
DROP ROLE IF EXISTS "skjera-owner"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CREATE SCHEMA skjera; | ||
|
||
GRANT ALL ON SCHEMA skjera TO "skjera-backend"; | ||
-- GRANT ALL ON SCHEMA skjera TO "skjera-backend"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ CREATE TABLE skjera.employee | |
PRIMARY KEY (id) | ||
); | ||
|
||
GRANT ALL ON skjera.employee TO "skjera-backend"; | ||
-- GRANT ALL ON skjera.employee TO "skjera-backend"; | ||
|
||
CREATE TABLE skjera.some_account | ||
( | ||
|
@@ -23,7 +23,7 @@ CREATE TABLE skjera.some_account | |
PRIMARY KEY (id) | ||
); | ||
|
||
GRANT ALL ON skjera.some_account TO "skjera-backend"; | ||
-- GRANT ALL ON skjera.some_account TO "skjera-backend"; | ||
|
||
INSERT INTO skjera.employee(email, name) | ||
VALUES ('[email protected]', 'Trygve Laugstøl'), | ||
|