sequelize-middleware/migrations/20200211081344-create-cars.js
2020-02-11 15:38:28 +01:00

40 lines
827 B
JavaScript

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable("Cars", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
year: {
type: Sequelize.INTEGER
},
active: {
type: Sequelize.BOOLEAN
},
brandId: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: "Brands",
key: "id"
}
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: queryInterface => {
return queryInterface.dropTable("Cars");
}
};