Add files table migration
This commit is contained in:
parent
04aa6e9598
commit
23a1378d7e
71
backend/src/db/migrations/1773330455699-create-files.js
Normal file
71
backend/src/db/migrations/1773330455699-create-files.js
Normal file
@ -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');
|
||||
},
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user