Skip to content

Commit

Permalink
setting(#316): Integrate banned-user migration files
Browse files Browse the repository at this point in the history
  • Loading branch information
hobiJeong committed Mar 7, 2024
1 parent c12dee7 commit fcc02e2
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/migrations/banned-user/1709815730552-banned-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { generatePrimaryColumn } from '@src/migrations/__utils/util';
import { MigrationInterface, QueryRunner, Table, TableColumn } from 'typeorm';

export class BannedUser1709815730552 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'banned_user',
columns: [
generatePrimaryColumn('밴된 유저 테이블 데이터 고유 ID'),
new TableColumn({
name: 'ban_user_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '밴한 어드민 고유 ID',
}),
new TableColumn({
name: 'banned_user_id',
type: 'int',
unsigned: true,
isNullable: false,
comment: '밴 당한 유저 고유 ID',
}),
new TableColumn({
name: 'reason',
type: 'varchar',
length: '200',
isNullable: false,
comment: '정지 사유',
}),
new TableColumn({
name: 'banned_at',
type: 'timestamp',
isNullable: false,
default: 'CURRENT_TIMESTAMP',
comment: '정지 당한 날짜',
}),
new TableColumn({
name: 'end_at',
type: 'datetime',
isNullable: true,
comment: '정지가 끝나는 날짜',
}),
],
foreignKeys: [
{
name: 'fk_banned_user_ban_user_id',
columnNames: ['ban_user_id'],
referencedTableName: 'user',
referencedColumnNames: ['id'],
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
{
name: 'fk_banned_user_banned_user_id',
columnNames: ['banned_user_id'],
referencedTableName: 'user',
referencedColumnNames: ['id'],
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
],
}),
);

await queryRunner.query(
'ALTER TABLE `banned_user` COMMENT = "정지 당한 유저 테이블"',
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('banned_user');
}
}

0 comments on commit fcc02e2

Please sign in to comment.