Merged PetitTeton webapp with the inventory tracking app; Moved the database configuration out of git and added an example configuration; Added migrations to the mix so that we can easily update the production database and roll back changes to the database (from the command line install migrations [may not be necessary?]:
npm install -g sequelize-cli To update the database after updating the app from git (on the command line in the webapp base directory): sequelize db:migrate To undo the last migrations: sequelize db:migrate:undo
This commit is contained in:
44
migrations/20160602030149-Item.js
Normal file
44
migrations/20160602030149-Item.js
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: function (query, Sequelize) {
|
||||
var DataTypes = Sequelize; //Allow for more cut and paste :)
|
||||
|
||||
return query.createTable('Item', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
counts: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false
|
||||
},
|
||||
visible: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
},
|
||||
subcategoryId: {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'Subcategory',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'cascade',
|
||||
onDelete: 'cascade'
|
||||
}
|
||||
}, {
|
||||
charset: 'utf8'
|
||||
});
|
||||
},
|
||||
|
||||
down: function (query, Sequelize) {
|
||||
return query.dropTable('Item');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user