From 41bd80dacd15323bdc23a0302f7b9ae4b385ffdd Mon Sep 17 00:00:00 2001 From: Durans Date: Sun, 27 Nov 2022 23:23:49 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20ajuste=20nas=20migrations=20para=20?= =?UTF-8?q?melhorar=20o=20fluxo=20de=20execu=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...222347-alter-column-queue-table-tickets.ts | 44 +++++++++---------- ...222701-alter-column-queue-table-tickets.ts | 44 +++++++++---------- 2 files changed, 40 insertions(+), 48 deletions(-) diff --git a/backend/src/database/migrations/20201207222347-alter-column-queue-table-tickets.ts b/backend/src/database/migrations/20201207222347-alter-column-queue-table-tickets.ts index 5f4c398e..06a110fd 100644 --- a/backend/src/database/migrations/20201207222347-alter-column-queue-table-tickets.ts +++ b/backend/src/database/migrations/20201207222347-alter-column-queue-table-tickets.ts @@ -1,31 +1,27 @@ import { QueryInterface, DataTypes } from "sequelize"; module.exports = { - up: (queryInterface: QueryInterface) => { - return Promise.all([ - queryInterface.removeColumn("Tickets", "queue"), - queryInterface.addColumn("Tickets", "queue", { - type: DataTypes.INTEGER, - references: { model: "Queues", key: "id" }, - onUpdate: "CASCADE", - onDelete: "restrict", - defaultValue: null, - allowNull: true - }) - ]); + up: async (queryInterface: QueryInterface) => { + await queryInterface.removeColumn("Tickets", "queue"); + await queryInterface.addColumn("Tickets", "queue", { + type: DataTypes.INTEGER, + references: { model: "Queues", key: "id" }, + onUpdate: "CASCADE", + onDelete: "restrict", + defaultValue: null, + allowNull: true + }); }, - down: (queryInterface: QueryInterface) => { - return Promise.all([ - queryInterface.removeColumn("Tickets", "queue"), - queryInterface.addColumn("Tickets", "queue", { - type: DataTypes.INTEGER, - // references: { model: "ServiceQueue", key: "id" }, - // onUpdate: "CASCADE", - // onDelete: "CASCADE", - defaultValue: null, - allowNull: true - }) - ]); + down: async (queryInterface: QueryInterface) => { + await queryInterface.removeColumn("Tickets", "queue"); + await queryInterface.addColumn("Tickets", "queue", { + type: DataTypes.INTEGER, + // references: { model: "ServiceQueue", key: "id" }, + // onUpdate: "CASCADE", + // onDelete: "CASCADE", + defaultValue: null, + allowNull: true + }); } }; diff --git a/backend/src/database/migrations/20201208222701-alter-column-queue-table-tickets.ts b/backend/src/database/migrations/20201208222701-alter-column-queue-table-tickets.ts index 9281d3cc..bf2f5548 100644 --- a/backend/src/database/migrations/20201208222701-alter-column-queue-table-tickets.ts +++ b/backend/src/database/migrations/20201208222701-alter-column-queue-table-tickets.ts @@ -1,31 +1,27 @@ import { QueryInterface, DataTypes } from "sequelize"; module.exports = { - up: (queryInterface: QueryInterface) => { - return Promise.all([ - queryInterface.removeColumn("Tickets", "queue"), - queryInterface.addColumn("Tickets", "queueId", { - type: DataTypes.INTEGER, - references: { model: "Queues", key: "id" }, - onUpdate: "CASCADE", - onDelete: "restrict", - defaultValue: null, - allowNull: true - }) - ]); + up: async (queryInterface: QueryInterface) => { + await queryInterface.removeColumn("Tickets", "queue"); + await queryInterface.addColumn("Tickets", "queueId", { + type: DataTypes.INTEGER, + references: { model: "Queues", key: "id" }, + onUpdate: "CASCADE", + onDelete: "restrict", + defaultValue: null, + allowNull: true + }); }, - down: (queryInterface: QueryInterface) => { - return Promise.all([ - queryInterface.removeColumn("Tickets", "queueId"), - queryInterface.addColumn("Tickets", "queue", { - type: DataTypes.INTEGER, - // references: { model: "ServiceQueue", key: "id" }, - // onUpdate: "CASCADE", - // onDelete: "CASCADE", - defaultValue: null, - allowNull: true - }) - ]); + down: async (queryInterface: QueryInterface) => { + await queryInterface.removeColumn("Tickets", "queueId"); + await queryInterface.addColumn("Tickets", "queue", { + type: DataTypes.INTEGER, + // references: { model: "ServiceQueue", key: "id" }, + // onUpdate: "CASCADE", + // onDelete: "CASCADE", + defaultValue: null, + allowNull: true + }); } };