diff --git a/README.md b/README.md index 73e8f3fe4b..189e4eaeb1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -unleash -======= +# unleash + +feature toggle service + + + -feature toggle server + clients diff --git a/unleash-server/README.md b/unleash-server/README.md index 4ddbf3ab43..a82dd87d41 100644 --- a/unleash-server/README.md +++ b/unleash-server/README.md @@ -5,6 +5,10 @@ unleash-server is a place to ask for the status of features. # Important commands: ``` +// Set up DB +npm run db-create +npm run db-migrate + //Start server in dev-mode: npm run start-dev diff --git a/unleash-server/package.json b/unleash-server/package.json index 16ec2d7b5d..b51fd0c849 100644 --- a/unleash-server/package.json +++ b/unleash-server/package.json @@ -21,7 +21,10 @@ "start-dev": "NODE_ENV=local supervisor --ignore ./node_modules/ server.js", "test": "jshint server.js lib public/scripts test && mocha test test/*", "tdd": "mocha --watch test test/*", - "test-bamboo-ci": "mocha test test/*" + "test-bamboo-ci": "mocha test test/*", + "db-create": "createdb unleash", + "db-drop": "dropdb unleash", + "db-migrate": "cd sql && grunt liquibase:update" }, "dependencies": { "bluebird": "2.2.2", @@ -31,7 +34,9 @@ "express-validator": "2.6.0", "ini": "1.3.0", "log4js": "0.6.21", - "nconf": "0.6.9" + "nconf": "0.6.9", + "grunt": "^0.4.5", + "grunt-liquibase": "^0.1.5" }, "devDependencies": { "chai": "1.9.1", diff --git a/unleash-server/sql/Gruntfile.js b/unleash-server/sql/Gruntfile.js new file mode 100644 index 0000000000..90a7eadf83 --- /dev/null +++ b/unleash-server/sql/Gruntfile.js @@ -0,0 +1,28 @@ +var dbPort = (process.env.BOXEN_POSTGRESQL_PORT || '5432'); + +module.exports = function(grunt) { + grunt.loadNpmTasks('grunt-liquibase'); + + grunt.initConfig({ + liquibase : { + options: { + username : '', + password : '', + url : 'jdbc:postgresql://localhost:' + dbPort + '/unleash', + changeLogFile: 'db_changes/db.changelog-master.xml' + }, + update: { + command: 'update' + }, + dropAll: { + command: 'dropAll' + }, + version : { + command: 'version' + } + } + }); + + grunt.registerTask('default', []); +}; + diff --git a/unleash-server/sql/db_changes/001-create-tables.xml b/unleash-server/sql/db_changes/001-create-tables.xml new file mode 100644 index 0000000000..adfe16a343 --- /dev/null +++ b/unleash-server/sql/db_changes/001-create-tables.xml @@ -0,0 +1,35 @@ + + + + + + CREATE TABLE strategies ( + created_at timestamp default now(), + name varchar(255) PRIMARY KEY NOT NULL, + description text + ); + + CREATE TABLE features ( + created_at timestamp default now(), + name varchar(255) PRIMARY KEY NOT NULL, + strategy_name varchar(255) references strategies(name), + parameters json + ); + + CREATE TABLE events ( + created_at timestamp default now(), + type varchar(255) NOT NULL, + data json + ); + + + + DROP TABLE strategies; + DROP TABLE features; + + + diff --git a/unleash-server/sql/db_changes/db.changelog-master.xml b/unleash-server/sql/db_changes/db.changelog-master.xml new file mode 100644 index 0000000000..efc1f5c403 --- /dev/null +++ b/unleash-server/sql/db_changes/db.changelog-master.xml @@ -0,0 +1,11 @@ + + + + + + +