Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(database): remove both create table on down migration for post …
Browse files Browse the repository at this point in the history
…and semester
  • Loading branch information
Angelo Magtoto committed Oct 9, 2022
1 parent 75b558b commit 30eaccf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 90 deletions.
54 changes: 1 addition & 53 deletions database/migrations/20220930220400-create-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,62 +49,10 @@ module.exports = {
}
})
},
async down(queryInterface, Sequelize) {
async down(queryInterface, unusedSequelize) {
await queryInterface.sequelize.transaction(async transaction => {
try {
await queryInterface.dropTable("Posts", { transaction })
await queryInterface.createTable("Posts", {
"id": {
"allowNull": false,
"autoIncrement": true,
"primaryKey": true,
"type": Sequelize.INTEGER
},
"title": {
"allowNull": false,
"type": Sequelize.STRING
},
"desc": {
"allowNull": false,
"type": Sequelize.STRING
},
"badWordExist": {
"allowNull": false,
"type": Sequelize.BOOLEAN
},
"userID": {
"allowNull": false,
"type": Sequelize.BIGINT,
"references": {
"model": "Users",
"key": "id"
},
"onDelete": "cascade",
"onUpdate": "cascade"
},
"roleID": {
"allowNull": false,
"type": Sequelize.BIGINT,
"references": {
"model": "Roles",
"key": "id"
},
"onDelete": "cascade",
"onUpdate": "cascade"
},
"createdAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"updatedAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"deletedAt": {
"allowNull": true,
"type": Sequelize.DATE
}
}, { transaction })
} catch (err) {
await transaction.rollback()
throw err
Expand Down
38 changes: 1 addition & 37 deletions database/migrations/20221006032100-create-semester.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,10 @@ module.exports = {
}
})
},
async down(queryInterface, Sequelize) {
async down(queryInterface, unusedSequelize) {
await queryInterface.sequelize.transaction(async transaction => {
try {
await queryInterface.dropTable("Semesters", { transaction })
await queryInterface.createTable("Semesters", {
"id": {
"allowNull": false,
"autoIncrement": true,
"primaryKey": true,
"type": Sequelize.BIGINT
},
"name": {
"allowNull": false,
"type": Sequelize.STRING
},
"semesterOrders": {
"allowNull": false,
"type": Sequelize.ENUM([ "first", "second", "third" ])
},
"startAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"endAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"createdAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"updatedAt": {
"allowNull": false,
"type": Sequelize.DATE
},
"deletedAt": {
"allowNull": true,
"type": Sequelize.DATE
}
}, { transaction })
} catch (err) {
await transaction.rollback()
throw err
Expand Down

0 comments on commit 30eaccf

Please sign in to comment.