Skip to content

Commit baa9469

Browse files
committed
Add db migrations for PR #121
1 parent 93c6205 commit baa9469

5 files changed

Lines changed: 31 additions & 0 deletions

File tree

.sequelizerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var path = require('path');
2+
3+
module.exports = {
4+
'config': path.resolve('config.json'),
5+
'migrations-path': path.resolve('lib', 'migrations'),
6+
'models-path': path.resolve('lib', 'models'),
7+
'url': 'change this'
8+
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Third-party integration api key settings
125125
| imgur | `config.json` | for image upload |
126126
| google drive, dropbox | `public/js/common.js` | for export and import |
127127

128+
DB migration
129+
---
130+
Modify the file named `.sequelizerc`, change the value of the variable `url` with your db connection string.
131+
And run `node_modules/.bin/sequelize db:migrate`, that's it!
128132

129133
Operational Transformation
130134
---
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
3+
module.exports = {
4+
up: function (queryInterface, Sequelize) {
5+
queryInterface.addColumn('Users', 'accessToken', Sequelize.STRING);
6+
queryInterface.addColumn('Users', 'refreshToken', Sequelize.STRING);
7+
return;
8+
},
9+
10+
down: function (queryInterface, Sequelize) {
11+
queryInterface.removeColumn('Users', 'accessToken');
12+
queryInterface.removeColumn('Users', 'refreshToken');
13+
return;
14+
}
15+
};

lib/models/user.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = function (sequelize, DataTypes) {
2626
},
2727
accessToken: {
2828
type: DataTypes.STRING
29+
},
30+
refreshToken: {
31+
type: DataTypes.STRING
2932
}
3033
}, {
3134
classMethods: {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"request": "^2.72.0",
4949
"reveal.js": "3.2.0",
5050
"sequelize": "^3.21.0",
51+
"sequelize-cli": "^2.4.0",
5152
"shortid": "2.2.6",
5253
"socket.io": "1.4.5",
5354
"sqlite3": "^3.1.3",

0 commit comments

Comments
 (0)