Files
outline/server/migrations/20251020204139-create-emojis.js
T
2025-12-01 02:31:50 +01:00

74 lines
1.9 KiB
JavaScript

"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable(
"emojis",
{
id: {
type: Sequelize.UUID,
primaryKey: true,
allowNull: false,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
attachmentId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "attachments",
key: "id",
},
onDelete: "CASCADE",
},
teamId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "teams",
key: "id",
},
onDelete: "CASCADE",
},
createdById: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
key: "id",
},
onDelete: "CASCADE",
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
},
{ transaction }
);
await queryInterface.addIndex("emojis", ["teamId"], { transaction });
await queryInterface.addIndex("emojis", ["createdById"], { transaction });
await queryInterface.addIndex("emojis", ["attachmentId"], {
transaction,
});
await queryInterface.addIndex("emojis", ["teamId", "name"], {
unique: true,
transaction,
});
});
},
async down(queryInterface) {
await queryInterface.dropTable("emojis");
},
};