diff --git a/unleash-server/migrations/sql/001-initial-schema.up.sql b/unleash-server/migrations/sql/001-initial-schema.up.sql index 5af3577f36..3712917b9c 100644 --- a/unleash-server/migrations/sql/001-initial-schema.up.sql +++ b/unleash-server/migrations/sql/001-initial-schema.up.sql @@ -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; diff --git a/unleash-server/scripts/generate-liquibase-artifact.js b/unleash-server/scripts/generate-liquibase-artifact.js index 05a8b2f9f2..b1affd6a9f 100755 --- a/unleash-server/scripts/generate-liquibase-artifact.js +++ b/unleash-server/scripts/generate-liquibase-artifact.js @@ -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/); @@ -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}); +} + diff --git a/unleash-server/scripts/init.down.sql b/unleash-server/scripts/init.down.sql new file mode 100644 index 0000000000..210ae9fdbf --- /dev/null +++ b/unleash-server/scripts/init.down.sql @@ -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; \ No newline at end of file diff --git a/unleash-server/scripts/init.up.sql b/unleash-server/scripts/init.up.sql new file mode 100644 index 0000000000..0f7c055dd0 --- /dev/null +++ b/unleash-server/scripts/init.up.sql @@ -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; \ No newline at end of file