From 3dddf791e6bda9c66030882a8fb26113f2d34d83 Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Mon, 20 Oct 2014 17:46:41 +0200 Subject: [PATCH] Get rid of liquibase --- .gitignore | 5 ++- unleash-server/README.md | 18 +++++----- unleash-server/config/database.json.example | 3 ++ .../20141020151056-initial-schema.js | 12 +++++++ .../sql/001-initial-schema.down.sql | 3 ++ .../migrations/sql/001-initial-schema.up.sql | 18 ++++++++++ unleash-server/package.json | 12 ++++--- .../sql/db_changes/001-create-tables.xml | 35 ------------------- .../sql/db_changes/db.changelog-master.xml | 11 ------ 9 files changed, 55 insertions(+), 62 deletions(-) create mode 100644 unleash-server/config/database.json.example create mode 100644 unleash-server/migrations/20141020151056-initial-schema.js create mode 100644 unleash-server/migrations/sql/001-initial-schema.down.sql create mode 100644 unleash-server/migrations/sql/001-initial-schema.up.sql delete mode 100644 unleash-server/sql/db_changes/001-create-tables.xml delete mode 100644 unleash-server/sql/db_changes/db.changelog-master.xml diff --git a/.gitignore b/.gitignore index aa3be40150..1d44741107 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,8 @@ node_modules .idea *.iml -# Java +# Java target + +# Local config +/unleash-server/config/database.json \ No newline at end of file diff --git a/unleash-server/README.md b/unleash-server/README.md index a82dd87d41..fb6ed82f9a 100644 --- a/unleash-server/README.md +++ b/unleash-server/README.md @@ -1,24 +1,22 @@ -# unleash-server +# unleash-server 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 +cp config/database.example.json config/database.json +npm run db-setup -//Start server in dev-mode: +// Start server in dev-mode: npm run start-dev -//Admin dashboard +// Admin dashboard http://localhost:4242 -//Feature API: +// Feature API: http://localhost:4242/features - -//Execute tests: +// Execute tests: npm test -``` \ No newline at end of file +``` diff --git a/unleash-server/config/database.json.example b/unleash-server/config/database.json.example new file mode 100644 index 0000000000..66a4e79aee --- /dev/null +++ b/unleash-server/config/database.json.example @@ -0,0 +1,3 @@ +{ + "dev": "postgres://localhost:5432/unleash_dev" +} diff --git a/unleash-server/migrations/20141020151056-initial-schema.js b/unleash-server/migrations/20141020151056-initial-schema.js new file mode 100644 index 0000000000..86a37e0911 --- /dev/null +++ b/unleash-server/migrations/20141020151056-initial-schema.js @@ -0,0 +1,12 @@ +var fs = require('fs'); +var util = require('util'); +var path = require('path').resolve(__dirname, 'sql/001-initial-schema.%s.sql'); + +exports.up = function(db, callback) { + var content = fs.readFileSync(util.format(path, 'up'), {encoding: 'utf8'}); + db.runSql(content, callback); +}; + +exports.down = function(db, callback) { + db.runSql(fs.readFileSync(util.format(path, 'down'), {encoding: 'utf8'}), callback); +}; diff --git a/unleash-server/migrations/sql/001-initial-schema.down.sql b/unleash-server/migrations/sql/001-initial-schema.down.sql new file mode 100644 index 0000000000..318db8e4b6 --- /dev/null +++ b/unleash-server/migrations/sql/001-initial-schema.down.sql @@ -0,0 +1,3 @@ +DROP TABLE strategies; +DROP TABLE features; +DROP TABLE events; diff --git a/unleash-server/migrations/sql/001-initial-schema.up.sql b/unleash-server/migrations/sql/001-initial-schema.up.sql new file mode 100644 index 0000000000..7af9856800 --- /dev/null +++ b/unleash-server/migrations/sql/001-initial-schema.up.sql @@ -0,0 +1,18 @@ +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 +); diff --git a/unleash-server/package.json b/unleash-server/package.json index 5fb4076469..6ab6b697ec 100644 --- a/unleash-server/package.json +++ b/unleash-server/package.json @@ -22,21 +22,23 @@ "test": "jshint server.js lib public/scripts test && mocha test test/*", "tdd": "mocha --watch test test/*", "test-bamboo-ci": "mocha test test/*", - "db-create": "createdb unleash", - "db-drop": "dropdb unleash", - "db-migrate": "grunt --verbose liquibase:update" + "db-create": "createdb unleash_${NODE_ENV:-dev}", + "db-drop": "dropdb unleash_${NODE_ENV:-dev}", + "db-migrate-up": "db-migrate --config config/database.json up", + "db-migrate-down": "db-migrate --config config/database.json down", + "db-setup": "npm run db-create; npm run db-migrate-up" }, "dependencies": { "bluebird": "2.2.2", "body-parser": "1.4.3", + "db-migrate": "^0.7.1", "errorhandler": "1.1.1", "express": "4.9.8", "express-validator": "2.6.0", "ini": "1.3.0", "log4js": "0.6.21", "nconf": "0.6.9", - "grunt": "^0.4.5", - "grunt-liquibase": "finn-no/grunt-liquibase#auth-in-url" + "pg": "^3.6.1" }, "devDependencies": { "chai": "1.9.1", diff --git a/unleash-server/sql/db_changes/001-create-tables.xml b/unleash-server/sql/db_changes/001-create-tables.xml deleted file mode 100644 index adfe16a343..0000000000 --- a/unleash-server/sql/db_changes/001-create-tables.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - 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 deleted file mode 100644 index efc1f5c403..0000000000 --- a/unleash-server/sql/db_changes/db.changelog-master.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - -