mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
await queryInterface.createTable('announcement_courses', {
|
|
id: {
|
|
type: Sequelize.BIGINT,
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
},
|
|
announcement_id: {
|
|
type: Sequelize.BIGINT,
|
|
allowNull: false,
|
|
references: { model: 'announcements', key: 'id' },
|
|
onDelete: 'CASCADE',
|
|
},
|
|
course_id: {
|
|
type: Sequelize.BIGINT,
|
|
allowNull: false,
|
|
references: { model: 'courses', key: 'course_id' },
|
|
onDelete: 'CASCADE',
|
|
},
|
|
});
|
|
|
|
await queryInterface.addConstraint('announcement_courses', {
|
|
fields: ['announcement_id', 'course_id'],
|
|
type: 'unique',
|
|
name: 'uq_announcement_courses',
|
|
});
|
|
|
|
await queryInterface.addIndex('announcement_courses', { fields: ['announcement_id'], name: 'idx_announcement_courses_ann_id' });
|
|
await queryInterface.addIndex('announcement_courses', { fields: ['course_id'], name: 'idx_announcement_courses_course_id' });
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.dropTable('announcement_courses');
|
|
},
|
|
};
|