Added some tests (createOne and getAll)
This commit is contained in:
parent
ef7ca0315b
commit
9f0886541c
21 changed files with 2940 additions and 67 deletions
28
migrations/20200211081052-create-brands.js
Normal file
28
migrations/20200211081052-create-brands.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable("Brands", {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
down: queryInterface => {
|
||||
return queryInterface.dropTable("Brands");
|
||||
}
|
||||
};
|
40
migrations/20200211081344-create-cars.js
Normal file
40
migrations/20200211081344-create-cars.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
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");
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue