summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-05-15 12:20:42 +0800
committerCheng-Han, Wu2016-05-15 12:20:42 +0800
commitbaa946968d0b5204c0b7507d10eba95ee643fe4b (patch)
tree2c6fc193cb6284b45e2527d7a51ed99d80480412
parent93c6205aa62e06ed1fcdb1d54fa240b8008786f1 (diff)
Add db migrations for PR #121
-rw-r--r--.sequelizerc8
-rw-r--r--README.md4
-rw-r--r--lib/migrations/20160515114000-user-add-tokens.js15
-rw-r--r--lib/models/user.js3
-rw-r--r--package.json1
5 files changed, 31 insertions, 0 deletions
diff --git a/.sequelizerc b/.sequelizerc
new file mode 100644
index 00000000..29a0d145
--- /dev/null
+++ b/.sequelizerc
@@ -0,0 +1,8 @@
+var path = require('path');
+
+module.exports = {
+ 'config': path.resolve('config.json'),
+ 'migrations-path': path.resolve('lib', 'migrations'),
+ 'models-path': path.resolve('lib', 'models'),
+ 'url': 'change this'
+} \ No newline at end of file
diff --git a/README.md b/README.md
index beece7d8..f2b469e2 100644
--- a/README.md
+++ b/README.md
@@ -125,6 +125,10 @@ Third-party integration api key settings
| imgur | `config.json` | for image upload |
| google drive, dropbox | `public/js/common.js` | for export and import |
+DB migration
+---
+Modify the file named `.sequelizerc`, change the value of the variable `url` with your db connection string.
+And run `node_modules/.bin/sequelize db:migrate`, that's it!
Operational Transformation
---
diff --git a/lib/migrations/20160515114000-user-add-tokens.js b/lib/migrations/20160515114000-user-add-tokens.js
new file mode 100644
index 00000000..3af490a9
--- /dev/null
+++ b/lib/migrations/20160515114000-user-add-tokens.js
@@ -0,0 +1,15 @@
+"use strict";
+
+module.exports = {
+ up: function (queryInterface, Sequelize) {
+ queryInterface.addColumn('Users', 'accessToken', Sequelize.STRING);
+ queryInterface.addColumn('Users', 'refreshToken', Sequelize.STRING);
+ return;
+ },
+
+ down: function (queryInterface, Sequelize) {
+ queryInterface.removeColumn('Users', 'accessToken');
+ queryInterface.removeColumn('Users', 'refreshToken');
+ return;
+ }
+}; \ No newline at end of file
diff --git a/lib/models/user.js b/lib/models/user.js
index 2323dc92..64173cbd 100644
--- a/lib/models/user.js
+++ b/lib/models/user.js
@@ -26,6 +26,9 @@ module.exports = function (sequelize, DataTypes) {
},
accessToken: {
type: DataTypes.STRING
+ },
+ refreshToken: {
+ type: DataTypes.STRING
}
}, {
classMethods: {
diff --git a/package.json b/package.json
index 3ecaa842..bacd2336 100644
--- a/package.json
+++ b/package.json
@@ -48,6 +48,7 @@
"request": "^2.72.0",
"reveal.js": "3.2.0",
"sequelize": "^3.21.0",
+ "sequelize-cli": "^2.4.0",
"shortid": "2.2.6",
"socket.io": "1.4.5",
"sqlite3": "^3.1.3",