Skip to content

Commit 52618c7

Browse files
committed
add migration setup
1 parent 3a3f69f commit 52618c7

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { MigrationInterface, QueryRunner, Table } from "typeorm"
2+
3+
export class CreateUsersTable1696849524727 implements MigrationInterface {
4+
5+
public async up(queryRunner: QueryRunner): Promise<void> {
6+
queryRunner.createTable(new Table({
7+
name: 'users',
8+
columns: [
9+
{
10+
name: "id",
11+
type: "int",
12+
isPrimary: true,
13+
isGenerated: true,
14+
},
15+
{
16+
name: "uuid",
17+
type: "varchar",
18+
isUnique: true,
19+
},
20+
{
21+
name: "name",
22+
type: "varchar",
23+
},
24+
{
25+
name: "username",
26+
type: "varchar",
27+
isUnique: true,
28+
},
29+
{
30+
name: "email",
31+
type: "varchar",
32+
isUnique: true,
33+
},
34+
{
35+
name: "phone",
36+
type: "varchar",
37+
isUnique: true,
38+
},
39+
{
40+
name: "created_at",
41+
type: "datetime",
42+
default: "now()",
43+
},
44+
{
45+
name: "updated_at",
46+
type: "datetime",
47+
default: "now()",
48+
}
49+
],
50+
}));
51+
}
52+
53+
public async down(queryRunner: QueryRunner): Promise<void> {
54+
await queryRunner.dropTable('users');
55+
}
56+
57+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"test:cov": "jest --coverage",
1919
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
2020
"test:e2e": "jest --config ./test/jest-e2e.json",
21-
"nest": "nest"
21+
"nest": "nest",
22+
"typeorm": "typeorm"
2223
},
2324
"dependencies": {
2425
"@google-cloud/storage": "^6.12.0",

0 commit comments

Comments
 (0)