mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
make default_group as utility and added more things
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
// Backfill migration: this table already exists live (created outside of
|
||||
// sequelize-cli before migration coverage was complete). Written to match
|
||||
// the live CockroachDB schema exactly so a fresh install/cutover recreates
|
||||
// it. On the existing production DB, mark this filename as already applied
|
||||
// in SequelizeMeta instead of running it — see project notes.
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('certificates', {
|
||||
certificate_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
uuid: { type: Sequelize.UUID, allowNull: false, unique: true, defaultValue: Sequelize.literal('gen_random_uuid()') },
|
||||
cert_no: { type: Sequelize.STRING(25), allowNull: false, unique: true },
|
||||
ref_no: { type: Sequelize.STRING(50), allowNull: false },
|
||||
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
|
||||
course_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'courses', key: 'course_id' }, onDelete: 'CASCADE' },
|
||||
instructors: { type: Sequelize.TEXT, allowNull: true },
|
||||
score: { type: Sequelize.BIGINT, allowNull: true },
|
||||
length_str: { type: Sequelize.STRING(50), allowNull: true },
|
||||
issued_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW },
|
||||
created_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW },
|
||||
updated_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW },
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint('certificates', {
|
||||
fields: ['user_id', 'course_id'],
|
||||
type: 'unique',
|
||||
name: 'certificates_user_id_course_id_key',
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('certificates', ['course_id'], { name: 'idx_certificates_course_id' });
|
||||
await queryInterface.addIndex('certificates', ['user_id'], { name: 'idx_certificates_user_id' });
|
||||
await queryInterface.addIndex('certificates', ['uuid'], { name: 'idx_certificates_uuid' });
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('certificates');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user