Skip to content

Commit

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

export class Category1709815316486 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'category',
columns: [
generatePrimaryColumn('카테고리 고유 ID'),
new TableColumn({
name: 'name',
type: 'varchar',
length: '20',
isNullable: false,
comment: '카테고리 이름',
}),
],
}),
);

await queryRunner.manager.getRepository(Category).upsert(
[
{
name: '전체',
},
{
name: 'IT',
},
{
name: '요리',
},
{
name: '디자인',
},
{
name: '운동',
},
{
name: '패션/뷰티',
},
{
name: '게임',
},
{
name: '음악',
},
{
name: '반려동물',
},
{
name: '회화',
},
{
name: '육아',
},
{
name: '공부',
},
{
name: '그 외',
},
],
['name'],
);

await queryRunner.query('ALTER TABLE category COMMENT = "카테고리"');
}

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

0 comments on commit aa09a96

Please sign in to comment.