forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1674320000000-CreateUsersTable.ts
More file actions
63 lines (60 loc) · 1.62 KB
/
Copy path1674320000000-CreateUsersTable.ts
File metadata and controls
63 lines (60 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { MigrationInterface, QueryRunner, Table, TableIndex } from "typeorm";
export class CreateUsersTable1674320000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: "users",
columns: [
{
name: "id",
type: "uuid",
isPrimary: true,
default: "gen_random_uuid()",
},
{
name: "email",
type: "varchar",
isUnique: true,
isNullable: false,
},
{
name: "email_preferences",
type: "jsonb",
default:
'\'{"invitations": true, "reminders": true, "receivedConfirmation": true, "completion": true}\'',
isNullable: false,
},
{
name: "last_email_sent_at",
type: "timestamp",
isNullable: true,
},
{
name: "created_at",
type: "timestamp",
default: "CURRENT_TIMESTAMP",
isNullable: false,
},
{
name: "updated_at",
type: "timestamp",
default: "CURRENT_TIMESTAMP",
onUpdate: "CURRENT_TIMESTAMP",
isNullable: false,
},
],
}),
true,
);
await queryRunner.createIndex(
"users",
new TableIndex({
name: "idx_users_email",
columnNames: ["email"],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable("users", true);
}
}