-
Notifications
You must be signed in to change notification settings - Fork 12
/
db_schema.go
62 lines (59 loc) · 3.58 KB
/
db_schema.go
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
package main
// HANDLED BY prisma in console project
//
//var ddls = []string{
// `create table if not exists source_spec()`,
// `alter table source_spec add column if not exists package varchar not null`,
// `alter table source_spec add column if not exists version varchar not null`,
// `alter table source_spec add column if not exists specs json`,
// `alter table source_spec add column if not exists timestamp timestamp with time zone`,
// `alter table source_spec add column if not exists error varchar`,
// `alter table source_spec add constraint source_spec_pk primary key (package, version)`,
// `create table if not exists source_catalog()`,
// `alter table source_catalog add column if not exists package varchar not null`,
// `alter table source_catalog add column if not exists version varchar not null`,
// `alter table source_catalog add column if not exists key varchar not null`,
// `alter table source_catalog add column if not exists catalog json`,
// `alter table source_catalog add column if not exists timestamp timestamp with time zone`,
// `alter table source_catalog add column if not exists status varchar`,
// `alter table source_catalog add column if not exists description varchar`,
// `alter table source_catalog add constraint source_catalog_pk primary key (package, version, key)`,
// `create table if not exists source_check()`,
// `alter table source_check add column if not exists package varchar not null`,
// `alter table source_check add column if not exists version varchar not null`,
// `alter table source_check add column if not exists key varchar not null`,
// `alter table source_check add column if not exists status varchar`,
// `alter table source_check add column if not exists description varchar`,
// `alter table source_check add column if not exists timestamp timestamp with time zone`,
// `alter table source_check add constraint source_check_pk primary key (key)`,
// `create table if not exists source_state()`,
// `alter table source_state add column if not exists sync_id varchar not null`,
// `alter table source_state add column if not exists state json`,
// `alter table source_state add column if not exists timestamp timestamp with time zone`,
// `alter table source_state add constraint source_state_pk primary key (sync_id)`,
// `create table if not exists source_task()`,
// `alter table source_task add column if not exists sync_id varchar not null`,
// `alter table source_task add column if not exists task_id varchar not null`,
// `alter table source_task add column if not exists package varchar not null`,
// `alter table source_task add column if not exists version varchar not null`,
// `alter table source_task add column if not exists started_at timestamp with time zone`,
// `alter table source_task add column if not exists updated_at timestamp with time zone`,
// `alter table source_task add column if not exists status varchar`,
// `alter table source_task add column if not exists description varchar`,
// `alter table source_task add constraint source_task_pk primary key (task_id)`,
// `create index if not exists source_task_sync_id_index on source_task (sync_id)`,
// `create index if not exists source_task_started_at_index on source_task (started_at desc)`,
//}
//func InitDBSchema(dbpool *pgxpool.Pool) error {
// for _, ddl := range ddls {
// _, err := dbpool.Exec(context.Background(), ddl)
// if err != nil && !IsConstraintExistsError(err) {
// return fmt.Errorf("Error running DDL query '%s': %v", ddl, err)
// }
// }
// return nil
//}
//
//func IsConstraintExistsError(err error) bool {
// return strings.Contains(err.Error(), "multiple primary keys for table")
//}