From 23a1378d7e8a79e05d8bf0de8215e3f48dfc9a08 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 6 May 2026 11:07:55 +0000 Subject: [PATCH] Add files table migration --- .../migrations/1773330455699-create-files.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 backend/src/db/migrations/1773330455699-create-files.js diff --git a/backend/src/db/migrations/1773330455699-create-files.js b/backend/src/db/migrations/1773330455699-create-files.js new file mode 100644 index 0000000..fd3fd96 --- /dev/null +++ b/backend/src/db/migrations/1773330455699-create-files.js @@ -0,0 +1,71 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('files', { + id: { + type: Sequelize.DataTypes.UUID, + defaultValue: Sequelize.DataTypes.UUIDV4, + primaryKey: true, + }, + belongsTo: { + type: Sequelize.DataTypes.STRING(255), + }, + belongsToId: { + type: Sequelize.DataTypes.UUID, + }, + belongsToColumn: { + type: Sequelize.DataTypes.STRING(255), + }, + name: { + type: Sequelize.DataTypes.STRING(2083), + allowNull: false, + }, + sizeInBytes: { + type: Sequelize.DataTypes.INTEGER, + allowNull: true, + }, + privateUrl: { + type: Sequelize.DataTypes.STRING(2083), + allowNull: true, + }, + publicUrl: { + type: Sequelize.DataTypes.STRING(2083), + allowNull: false, + }, + createdAt: { + type: Sequelize.DataTypes.DATE, + }, + updatedAt: { + type: Sequelize.DataTypes.DATE, + }, + deletedAt: { + type: Sequelize.DataTypes.DATE, + }, + createdById: { + type: Sequelize.DataTypes.UUID, + references: { + model: 'users', + key: 'id', + }, + }, + updatedById: { + type: Sequelize.DataTypes.UUID, + references: { + model: 'users', + key: 'id', + }, + }, + }); + + await queryInterface.addIndex('files', [ + 'belongsTo', + 'belongsToId', + 'belongsToColumn', + ]); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('files'); + }, +};