From 4eff053ea78c135474e1799e8aa0af0f1e2b775b Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 14 Mar 2026 14:33:16 +0000 Subject: [PATCH] Autosave: 20260314-143316 --- .../migrations/1773497460361-create-files.js | 31 +++++++++++++++++++ .../1773497460362-add-belongsTo-to-files.js | 23 ++++++++++++++ .../1773497460363-add-sizeInBytes-to-files.js | 14 +++++++++ .../1773497460364-add-privateUrl-to-files.js | 14 +++++++++ .../1773497460365-add-publicUrl-to-files.js | 18 +++++++++++ .../1773497460366-add-deletedAt-to-files.js | 16 ++++++++++ .../1773497460367-add-createdById-to-files.js | 22 +++++++++++++ 7 files changed, 138 insertions(+) create mode 100644 backend/src/db/migrations/1773497460361-create-files.js create mode 100644 backend/src/db/migrations/1773497460362-add-belongsTo-to-files.js create mode 100644 backend/src/db/migrations/1773497460363-add-sizeInBytes-to-files.js create mode 100644 backend/src/db/migrations/1773497460364-add-privateUrl-to-files.js create mode 100644 backend/src/db/migrations/1773497460365-add-publicUrl-to-files.js create mode 100644 backend/src/db/migrations/1773497460366-add-deletedAt-to-files.js create mode 100644 backend/src/db/migrations/1773497460367-add-createdById-to-files.js diff --git a/backend/src/db/migrations/1773497460361-create-files.js b/backend/src/db/migrations/1773497460361-create-files.js new file mode 100644 index 0000000..c03fb3a --- /dev/null +++ b/backend/src/db/migrations/1773497460361-create-files.js @@ -0,0 +1,31 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('files', { + id: { + allowNull: false, + primaryKey: true, + type: Sequelize.UUID, + defaultValue: Sequelize.UUIDV4 + }, + name: { + type: Sequelize.STRING + }, + url: { + type: Sequelize.STRING + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('files'); + } +}; diff --git a/backend/src/db/migrations/1773497460362-add-belongsTo-to-files.js b/backend/src/db/migrations/1773497460362-add-belongsTo-to-files.js new file mode 100644 index 0000000..27cae16 --- /dev/null +++ b/backend/src/db/migrations/1773497460362-add-belongsTo-to-files.js @@ -0,0 +1,23 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('files', 'belongsTo', { + type: Sequelize.STRING(255), + allowNull: true, + }); + await queryInterface.addColumn('files', 'belongsToId', { + type: Sequelize.UUID, + allowNull: true, + }); + await queryInterface.addColumn('files', 'belongsToColumn', { + type: Sequelize.STRING(255), + allowNull: true, + }); + }, + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('files', 'belongsTo'); + await queryInterface.removeColumn('files', 'belongsToId'); + await queryInterface.removeColumn('files', 'belongsToColumn'); + } +}; diff --git a/backend/src/db/migrations/1773497460363-add-sizeInBytes-to-files.js b/backend/src/db/migrations/1773497460363-add-sizeInBytes-to-files.js new file mode 100644 index 0000000..60b8e61 --- /dev/null +++ b/backend/src/db/migrations/1773497460363-add-sizeInBytes-to-files.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('files', 'sizeInBytes', { + type: Sequelize.INTEGER, + allowNull: true, + }); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('files', 'sizeInBytes'); + } +}; diff --git a/backend/src/db/migrations/1773497460364-add-privateUrl-to-files.js b/backend/src/db/migrations/1773497460364-add-privateUrl-to-files.js new file mode 100644 index 0000000..a7384e7 --- /dev/null +++ b/backend/src/db/migrations/1773497460364-add-privateUrl-to-files.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + return queryInterface.addColumn('files', 'privateUrl', { + type: Sequelize.STRING, + allowNull: true, + }); + }, + + down: async (queryInterface, Sequelize) => { + return queryInterface.removeColumn('files', 'privateUrl'); + } +}; diff --git a/backend/src/db/migrations/1773497460365-add-publicUrl-to-files.js b/backend/src/db/migrations/1773497460365-add-publicUrl-to-files.js new file mode 100644 index 0000000..44cb090 --- /dev/null +++ b/backend/src/db/migrations/1773497460365-add-publicUrl-to-files.js @@ -0,0 +1,18 @@ +module.exports = { + up: async (queryInterface, Sequelize) => { + const tableInfo = await queryInterface.describeTable('files'); + if (!tableInfo.publicUrl) { + await queryInterface.addColumn('files', 'publicUrl', { + type: Sequelize.STRING(2083), + allowNull: false, + defaultValue: '', + }); + } + }, + down: async (queryInterface, Sequelize) => { + const tableInfo = await queryInterface.describeTable('files'); + if (tableInfo.publicUrl) { + await queryInterface.removeColumn('files', 'publicUrl'); + } + }, +}; diff --git a/backend/src/db/migrations/1773497460366-add-deletedAt-to-files.js b/backend/src/db/migrations/1773497460366-add-deletedAt-to-files.js new file mode 100644 index 0000000..78749e8 --- /dev/null +++ b/backend/src/db/migrations/1773497460366-add-deletedAt-to-files.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + const tableInfo = await queryInterface.describeTable('files'); + if (!tableInfo.deletedAt) { + await queryInterface.addColumn('files', 'deletedAt', { + type: Sequelize.DATE, + allowNull: true, + }); + } + }, + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('files', 'deletedAt'); + } +}; diff --git a/backend/src/db/migrations/1773497460367-add-createdById-to-files.js b/backend/src/db/migrations/1773497460367-add-createdById-to-files.js new file mode 100644 index 0000000..875f98d --- /dev/null +++ b/backend/src/db/migrations/1773497460367-add-createdById-to-files.js @@ -0,0 +1,22 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + const tableInfo = await queryInterface.describeTable('files'); + if (!tableInfo.createdById) { + await queryInterface.addColumn('files', 'createdById', { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'users', + key: 'id' + }, + onUpdate: 'CASCADE', + onDelete: 'SET NULL' + }); + } + }, + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('files', 'createdById'); + } +};