From aa09a96a1b09313123fea57e8641bcedf3275c91 Mon Sep 17 00:00:00 2001 From: hobiJeong Date: Thu, 7 Mar 2024 23:50:30 +0900 Subject: [PATCH] setting(#316): Integrate category migration files --- .../category/1709815316486-category.ts | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/migrations/category/1709815316486-category.ts diff --git a/src/migrations/category/1709815316486-category.ts b/src/migrations/category/1709815316486-category.ts new file mode 100644 index 00000000..3baee6d1 --- /dev/null +++ b/src/migrations/category/1709815316486-category.ts @@ -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 { + 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 { + await queryRunner.dropTable('category'); + } +}