From 74ab417191569d7144ec051e0eb6521f1a567df0 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 14 Jan 2016 07:07:24 -0500 Subject: [PATCH] add database migration support --- .gitignore | 2 +- database.json | 6 ++++++ migrations/20160114114150-images.js | 19 +++++++++++++++++++ project.clj | 4 +++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 database.json create mode 100644 migrations/20160114114150-images.js diff --git a/.gitignore b/.gitignore index 850d27c..c5a49a0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ pom.xml.asc /public/out /public/index.js /images - +/db diff --git a/database.json b/database.json new file mode 100644 index 0000000..905a8b7 --- /dev/null +++ b/database.json @@ -0,0 +1,6 @@ +{ + "dev": { + "driver": "sqlite3", + "filename": "db/dev.db" + } +} diff --git a/migrations/20160114114150-images.js b/migrations/20160114114150-images.js new file mode 100644 index 0000000..c9258fa --- /dev/null +++ b/migrations/20160114114150-images.js @@ -0,0 +1,19 @@ +var dbm = global.dbm || require('db-migrate'); +var type = dbm.dataType; + +exports.up = function(db, callback) { + db.createTable('images', { + id: {type: 'int', primaryKey: true}, + path: 'string', + name: 'string', + width: 'int', + height: 'int', + type: 'string', + createdAt: 'int', + updatedAt: 'int' + }, callback); +}; + +exports.down = function(db, callback) { + db.dropTable('images', callback); +}; diff --git a/project.clj b/project.clj index 3410f74..6002882 100644 --- a/project.clj +++ b/project.clj @@ -8,7 +8,9 @@ :source-paths ["src/server" "src/client"] :npm { :dependencies [[ws "0.4.30"] [imagemagick-native "https://github.com/elad/node-imagemagick-native.git"] - [express "4.13.3"]]} + [express "4.13.3"] + [sqlite3 "3.1.1"] + [db-migrate "0.9.23"]]} :cljsbuild { :builds [{:source-paths ["src/server"] :compiler {