Skip to content

Commit 313401f

Browse files
committed
✨ feat: 마이그레이션 파일 작성
1 parent ab269ce commit 313401f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class CreateFile1754122785239 implements MigrationInterface {
4+
name = 'CreateFile1754122785239';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE TABLE \`file\` (\`id\` int NOT NULL AUTO_INCREMENT, \`originalname\` varchar(255) NOT NULL, \`mimetype\` varchar(255) NOT NULL, \`path\` varchar(255) NOT NULL, \`size\` int NOT NULL, \`createdAt\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`user_id\` int NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
9+
);
10+
await queryRunner.query(
11+
`ALTER TABLE \`file\` ADD CONSTRAINT \`FK_516f1cf15166fd07b732b4b6ab0\` FOREIGN KEY (\`user_id\`) REFERENCES \`user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
12+
);
13+
}
14+
15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(
17+
`ALTER TABLE \`file\` DROP FOREIGN KEY \`FK_516f1cf15166fd07b732b4b6ab0\``,
18+
);
19+
await queryRunner.query(`DROP TABLE \`file\``);
20+
}
21+
}

0 commit comments

Comments
 (0)