-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20240423094907-create-product.js
60 lines (59 loc) · 1.28 KB
/
20240423094907-create-product.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('Products', {
id: {
allowNull: false,
primaryKey: true,
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4
},
name: {
type: Sequelize.STRING,
allowNull: false,
unique: true
},
description: {
type: Sequelize.STRING
},
price: {
type: Sequelize.INTEGER,
allowNull: false,
},
categoryId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'Categories',
key: 'id'
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE'
},
image: {
type: Sequelize.STRING,
allowNull: false
},
stock: {
type: Sequelize.INTEGER,
defaultValue: 0
},
countReview: {
type: Sequelize.INTEGER,
defaultValue: 0
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('Products');
}
};