Some checks failed
Deploy to production / deploy (push) Has been cancelled
- Modified the deployment workflow to include new migration paths for the backend, ensuring that migrations are correctly referenced in the deployment process. - Updated the `db:migrate` script in package.json to point to the `migrations-active` directory, enhancing clarity and organization of migration files. - Adjusted the deployment conditions to account for changes in migration file locations, improving the accuracy of change detection during deployments. - Removed obsolete migration files to streamline the migration process and prevent confusion.
90 lines
2.5 KiB
JavaScript
90 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
/** @type {import('sequelize-cli').Migration} */
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
await queryInterface.createTable(
|
|
{ schema: 'community', tableName: 'erotic_video_image_visibility' },
|
|
{
|
|
id: {
|
|
type: Sequelize.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
allowNull: false,
|
|
},
|
|
erotic_video_id: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: { schema: 'community', tableName: 'erotic_video' },
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
visibility_type_id: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: { schema: 'type', tableName: 'image_visibility' },
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
}
|
|
);
|
|
|
|
await queryInterface.createTable(
|
|
{ schema: 'community', tableName: 'erotic_video_visibility_user' },
|
|
{
|
|
id: {
|
|
type: Sequelize.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
allowNull: false,
|
|
},
|
|
erotic_video_id: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: { schema: 'community', tableName: 'erotic_video' },
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
user_id: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: { schema: 'community', tableName: 'user' },
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
}
|
|
);
|
|
|
|
await queryInterface.sequelize.query(`
|
|
INSERT INTO community.erotic_video_image_visibility (erotic_video_id, visibility_type_id)
|
|
SELECT ev.id, iv.id
|
|
FROM community.erotic_video ev
|
|
CROSS JOIN type.image_visibility iv
|
|
WHERE iv.description = 'adults'
|
|
AND NOT EXISTS (
|
|
SELECT 1
|
|
FROM community.erotic_video_image_visibility eviv
|
|
WHERE eviv.erotic_video_id = ev.id
|
|
AND eviv.visibility_type_id = iv.id
|
|
)
|
|
`);
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.dropTable({ schema: 'community', tableName: 'erotic_video_visibility_user' });
|
|
await queryInterface.dropTable({ schema: 'community', tableName: 'erotic_video_image_visibility' });
|
|
},
|
|
};
|