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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import * as Sequelize from 'sequelize'
async function up (utils: {
transaction: Sequelize.Transaction
queryInterface: Sequelize.QueryInterface
sequelize: Sequelize.Sequelize
}): Promise<void> {
{
const query = `
CREATE TABLE IF NOT EXISTS "runnerRegistrationToken"(
"id" serial,
"registrationToken" varchar(255) NOT NULL,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
PRIMARY KEY ("id")
);
`
await utils.sequelize.query(query, { transaction : utils.transaction })
}
{
const query = `
CREATE TABLE IF NOT EXISTS "runner"(
"id" serial,
"runnerToken" varchar(255) NOT NULL,
"name" varchar(255) NOT NULL,
"description" varchar(1000),
"lastContact" timestamp with time zone NOT NULL,
"ip" varchar(255) NOT NULL,
"runnerRegistrationTokenId" integer REFERENCES "runnerRegistrationToken"("id") ON DELETE CASCADE ON UPDATE CASCADE,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
PRIMARY KEY ("id")
);
`
await utils.sequelize.query(query, { transaction : utils.transaction })
}
{
const query = `
CREATE TABLE IF NOT EXISTS "runnerJob"(
"id" serial,
"uuid" uuid NOT NULL,
"type" varchar(255) NOT NULL,
"payload" jsonb NOT NULL,
"privatePayload" jsonb NOT NULL,
"state" integer NOT NULL,
"failures" integer NOT NULL DEFAULT 0,
"error" varchar(5000),
"priority" integer NOT NULL,
"processingJobToken" varchar(255),
"progress" integer,
"startedAt" timestamp with time zone,
"finishedAt" timestamp with time zone,
"dependsOnRunnerJobId" integer REFERENCES "runnerJob"("id") ON DELETE CASCADE ON UPDATE CASCADE,
"runnerId" integer REFERENCES "runner"("id") ON DELETE SET NULL ON UPDATE CASCADE,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
PRIMARY KEY ("id")
);
`
await utils.sequelize.query(query, { transaction : utils.transaction })
}
}
function down (options) {
throw new Error('Not implemented.')
}
export {
up,
down
}
|