Skip to content

Commit

Permalink
Added finn-specific prepare as a db-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Feb 20, 2020
1 parent be9dbcc commit 9639aef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
5 changes: 0 additions & 5 deletions unleash-server/migrations/sql/001-initial-schema.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ CREATE TABLE events (
created_by varchar(255) NOT NULL,
data json
);

GRANT ALL ON TABLE events TO unleash_user;
GRANT ALL ON TABLE features TO unleash_user;
GRANT ALL ON TABLE strategies TO unleash_user;
GRANT USAGE, SELECT ON SEQUENCE events_id_seq TO unleash_user;
8 changes: 8 additions & 0 deletions unleash-server/scripts/generate-liquibase-artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ fs.readdir(sqlRoot, function (err, files) {

var changes = {};

initialInit(changes);

files.forEach(function (sqlFile) {
var match = sqlFile.match(/(.+?)\.(up|down)\.sql/);

Expand All @@ -49,3 +51,9 @@ fs.readdir(sqlRoot, function (err, files) {
util.puts(changeLog.end({pretty: true}));
});

function initialInit(changes) {
changes["init-prepare"] = {};
changes["init-prepare"]["up"] = fs.readFileSync(path.resolve(__dirname, './init.up.sql'), {encoding: encoding});
changes["init-prepare"]["down"] = fs.readFileSync(path.resolve(__dirname, './init.down.sql'), {encoding: encoding});
}

2 changes: 2 additions & 0 deletions unleash-server/scripts/init.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter default privileges for user unleash_admin revoke select,insert,update,delete on tables TO unleash_user;
alter default privileges for user unleash_admin revoke select,update on sequences TO unleash_user;
2 changes: 2 additions & 0 deletions unleash-server/scripts/init.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter default privileges for user unleash_admin grant select,insert,update,delete on tables TO unleash_user;
alter default privileges for user unleash_admin grant select,update on sequences TO unleash_user;

0 comments on commit 9639aef

Please sign in to comment.