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

Commit

Permalink
intrn(database): comment votes migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Oct 11, 2022
1 parent 6497a78 commit ab5ef35
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions database/migrations/20221011120900-create-comment-votes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* eslint-disable vue/sort-keys */

module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => {
try {
await queryInterface.dropTable("CommentVotes", { transaction })
await queryInterface.createTable("CommentVotes", {
"id": {
"allowNull": false,
"autoIncrement": true,
"primaryKey": true,
"type": Sequelize.BIGINT
},
"commentID": {
"allowNull": false,
"type": Sequelize.BIGINT,
"references": {
"model": "Comments",
"key": "id"
},
"onDelete": "cascade",
"onUpdate": "cascade"
},
"userID": {
"allowNull": false,
"type": Sequelize.BIGINT,
"references": {
"model": "Users",
"key": "id"
},
"onDelete": "cascade",
"onUpdate": "cascade"
},
"kind": {
"allowNull": false,
"type": Sequelize.ENUM([ "upvote", "downvote" ])
},
"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
}
})
},
async down(queryInterface, unusedSequelize) {
await queryInterface.sequelize.transaction(async transaction => {
try {
await queryInterface.dropTable("CommentVotes", { transaction })
} catch (err) {
await transaction.rollback()
throw err
}
})
}
}

0 comments on commit ab5ef35

Please sign in to comment.