Added some new tests
This commit is contained in:
parent
0039a8b4ec
commit
918f873fea
15 changed files with 887 additions and 114 deletions
26
migrations/20200212092056-create-colors.js
Normal file
26
migrations/20200212092056-create-colors.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable("Colors", {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
down: queryInterface => {
|
||||
return queryInterface.dropTable("Colors");
|
||||
}
|
||||
};
|
39
migrations/20200212092136-create-cars-colors.js
Normal file
39
migrations/20200212092136-create-cars-colors.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable("CarsColors", {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
CarId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: "Cars",
|
||||
key: "id"
|
||||
}
|
||||
},
|
||||
ColorId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: "Colors",
|
||||
key: "id"
|
||||
}
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
down: queryInterface => {
|
||||
return queryInterface.dropTable("CarsColors");
|
||||
}
|
||||
};
|
15
migrations/20200212093136-setUniqueCarsColors.js
Normal file
15
migrations/20200212093136-setUniqueCarsColors.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
module.exports = {
|
||||
up: queryInterface => {
|
||||
return queryInterface.addConstraint("CarsColors", ["CarId", "ColorId"], {
|
||||
type: "unique",
|
||||
name: "CarsColors_unique_carId_colorId"
|
||||
});
|
||||
},
|
||||
|
||||
down: queryInterface => {
|
||||
return queryInterface.removeConstraint(
|
||||
"CarsColors",
|
||||
"CarsColors_unique_carId_colorId"
|
||||
);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue