Created
January 24, 2017 14:48
-
-
Save notgiorgi/7276aae5baebb5725799ce0f5b8468f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GSession = require('./schema') | |
module.exports = { | |
up(dbService) { | |
return dbService.createTable(GSession.options.tableName, GSession.schema)) | |
}, | |
down(dbService) { | |
return dbService.dropTable(Gsession.options.tableName) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GSession = require('./schema') | |
module.exports = sequelize => sequelize.define('GSession', GSession.schema, GSession.options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { DataTypes } = require('sequelize') | |
module.exports = { | |
schema: { | |
id: { | |
type: DataTypes.INTEGER, | |
primaryKey: true, | |
allowNull: false, | |
autoIncrement: true, | |
}, | |
start_time: DataTypes.DATE, | |
end_time: DataTypes.DATE, | |
is_closed: { | |
type: DataTypes.BOOLEAN, | |
defaultValue: false, | |
}, | |
}, | |
options: { | |
tableName: 'gsessions', | |
timestamps: false, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migration files should be immutable while Model schema will be changed anytime. We need to create to new migration file to change db, and then change model directly. So it's not a good idea to share schema between model and migration file.