@pikku/kysely 0.13.33 → 0.13.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,40 +18,37 @@ export const workflowSchema = {
18
18
  name: 'workflow',
19
19
  ownedBy: ['workflowService', 'workflowRunService'],
20
20
  statements: [
21
- (db) => db.schema
21
+ (db, _types, ctx) => db.schema
22
22
  .createTable('workflowRuns')
23
- .addColumn('workflowRunId', 'text', (col) => col.primaryKey())
24
- .addColumn('workflow', 'text', (col) => col.notNull())
25
- .addColumn('status', 'text', (col) => col.notNull())
26
- .addColumn('input', 'text', (col) => col.notNull())
27
- .addColumn('output', 'text')
28
- .addColumn('error', 'text')
29
- .addColumn('state', 'text', (col) => col.defaultTo('{}'))
23
+ .addColumn('workflowRunId', ctx.key, (col) => col.primaryKey())
24
+ .addColumn('workflow', ctx.key, (col) => col.notNull())
25
+ .addColumn('status', ctx.key, (col) => col.notNull())
26
+ .addColumn('input', ctx.text, (col) => col.notNull())
27
+ .addColumn('output', ctx.text)
28
+ .addColumn('error', ctx.text)
29
+ .addColumn('state', ctx.text, (col) => col.defaultTo(ctx.defaultText('{}')))
30
30
  .addColumn('inline', 'boolean', (col) => col.defaultTo(false))
31
- .addColumn('graphHash', 'text')
31
+ .addColumn('graphHash', ctx.key)
32
32
  .addColumn('deterministic', 'boolean', (col) => col.defaultTo(false))
33
- .addColumn('plannedSteps', 'text')
34
- .addColumn('wire', 'text')
33
+ .addColumn('plannedSteps', ctx.text)
34
+ .addColumn('wire', ctx.text)
35
35
  .addColumn('createdAt', 'timestamp', (col) => col.defaultTo(sql `CURRENT_TIMESTAMP`).notNull())
36
36
  .addColumn('updatedAt', 'timestamp', (col) => col.defaultTo(sql `CURRENT_TIMESTAMP`).notNull()),
37
- (db) => db.schema
37
+ (db, _types, ctx) => db.schema
38
38
  .createTable('workflowStep')
39
- .addColumn('workflowStepId', 'text', (col) => col.primaryKey())
40
- .addColumn('workflowRunId', 'text', (col) => col
41
- .notNull()
42
- .references('workflowRuns.workflowRunId')
43
- .onDelete('cascade'))
44
- .addColumn('stepName', 'text', (col) => col.notNull())
45
- .addColumn('rpcName', 'text')
46
- .addColumn('data', 'text')
47
- .addColumn('status', 'text', (col) => col.notNull().defaultTo('pending'))
48
- .addColumn('result', 'text')
49
- .addColumn('error', 'text')
50
- .addColumn('childRunId', 'text')
51
- .addColumn('branchTaken', 'text')
39
+ .addColumn('workflowStepId', ctx.key, (col) => col.primaryKey())
40
+ .addColumn('workflowRunId', ctx.key, (col) => ctx.references(col.notNull(), 'workflowRuns.workflowRunId'))
41
+ .addColumn('stepName', ctx.key, (col) => col.notNull())
42
+ .addColumn('rpcName', ctx.text)
43
+ .addColumn('data', ctx.text)
44
+ .addColumn('status', ctx.key, (col) => col.notNull().defaultTo(ctx.defaultText('pending')))
45
+ .addColumn('result', ctx.text)
46
+ .addColumn('error', ctx.text)
47
+ .addColumn('childRunId', ctx.text)
48
+ .addColumn('branchTaken', ctx.text)
52
49
  .addColumn('retries', 'integer')
53
- .addColumn('retryDelay', 'text')
54
- .addColumn('fromStepName', 'text')
50
+ .addColumn('retryDelay', ctx.text)
51
+ .addColumn('fromStepName', ctx.text)
55
52
  .addColumn('currentAttempt', 'integer')
56
53
  .addColumn('leaseExpiresAt', 'bigint')
57
54
  .addColumn('createdAt', 'timestamp', (col) => col.defaultTo(sql `CURRENT_TIMESTAMP`).notNull())
@@ -59,30 +56,33 @@ export const workflowSchema = {
59
56
  .addUniqueConstraint('workflow_step_run_name_unique', [
60
57
  'workflowRunId',
61
58
  'stepName',
62
- ]),
63
- (db) => db.schema
59
+ ])
60
+ .$call(ctx.foreignKeys('workflowStep', {
61
+ workflowRunId: 'workflowRuns.workflowRunId',
62
+ })),
63
+ (db, _types, ctx) => db.schema
64
64
  .createTable('workflowStepHistory')
65
- .addColumn('historyId', 'text', (col) => col.primaryKey())
66
- .addColumn('workflowStepId', 'text', (col) => col
67
- .notNull()
68
- .references('workflowStep.workflowStepId')
69
- .onDelete('cascade'))
70
- .addColumn('status', 'text', (col) => col.notNull())
71
- .addColumn('result', 'text')
72
- .addColumn('error', 'text')
65
+ .addColumn('historyId', ctx.key, (col) => col.primaryKey())
66
+ .addColumn('workflowStepId', ctx.key, (col) => ctx.references(col.notNull(), 'workflowStep.workflowStepId'))
67
+ .addColumn('status', ctx.key, (col) => col.notNull())
68
+ .addColumn('result', ctx.text)
69
+ .addColumn('error', ctx.text)
73
70
  .addColumn('attempt', 'integer')
74
71
  .addColumn('createdAt', 'timestamp', (col) => col.defaultTo(sql `CURRENT_TIMESTAMP`).notNull())
75
72
  .addColumn('runningAt', 'timestamp')
76
73
  .addColumn('scheduledAt', 'timestamp')
77
74
  .addColumn('succeededAt', 'timestamp')
78
- .addColumn('failedAt', 'timestamp'),
79
- (db) => db.schema
75
+ .addColumn('failedAt', 'timestamp')
76
+ .$call(ctx.foreignKeys('workflowStepHistory', {
77
+ workflowStepId: 'workflowStep.workflowStepId',
78
+ })),
79
+ (db, _types, ctx) => db.schema
80
80
  .createTable('workflowVersions')
81
- .addColumn('workflowName', 'text', (col) => col.notNull())
82
- .addColumn('graphHash', 'text', (col) => col.notNull())
83
- .addColumn('graph', 'text', (col) => col.notNull())
84
- .addColumn('source', 'text', (col) => col.notNull())
85
- .addColumn('status', 'text', (col) => col.notNull().defaultTo('active'))
81
+ .addColumn('workflowName', ctx.key, (col) => col.notNull())
82
+ .addColumn('graphHash', ctx.key, (col) => col.notNull())
83
+ .addColumn('graph', ctx.text, (col) => col.notNull())
84
+ .addColumn('source', ctx.key, (col) => col.notNull())
85
+ .addColumn('status', ctx.key, (col) => col.notNull().defaultTo(ctx.defaultText('active')))
86
86
  .addColumn('createdAt', 'timestamp', (col) => col.defaultTo(sql `CURRENT_TIMESTAMP`).notNull())
87
87
  .addPrimaryKeyConstraint('workflow_versions_pk', [
88
88
  'workflowName',
@@ -90,23 +90,23 @@ export const workflowSchema = {
90
90
  ]),
91
91
  // The indexes trail the tables so that a table is never indexed before it
92
92
  // exists, whatever order the declarations are read in.
93
- (db) => db.schema
93
+ (db, _types, ctx) => db.schema
94
94
  .createIndex('idx_workflow_runs_status_created')
95
95
  .on('workflowRuns')
96
96
  .columns(['status', 'createdAt']),
97
- (db) => db.schema
97
+ (db, _types, ctx) => db.schema
98
98
  .createIndex('idx_workflow_runs_workflow_created')
99
99
  .on('workflowRuns')
100
100
  .columns(['workflow', 'createdAt']),
101
- (db) => db.schema
101
+ (db, _types, ctx) => db.schema
102
102
  .createIndex('idx_workflow_step_run_status')
103
103
  .on('workflowStep')
104
104
  .columns(['workflowRunId', 'status']),
105
- (db) => db.schema
105
+ (db, _types, ctx) => db.schema
106
106
  .createIndex('idx_workflow_step_history_step')
107
107
  .on('workflowStepHistory')
108
108
  .columns(['workflowStepId', 'createdAt']),
109
- (db) => db.schema
109
+ (db, _types, ctx) => db.schema
110
110
  .createIndex('idx_workflow_versions_source_status')
111
111
  .on('workflowVersions')
112
112
  .columns(['source', 'status']),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely",
3
- "version": "0.13.33",
3
+ "version": "0.13.35",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -15,6 +15,7 @@
15
15
  "pikku-kysely-pure": "dist/bin/pikku-kysely-pure.js"
16
16
  },
17
17
  "type": "module",
18
+ "sideEffects": false,
18
19
  "scripts": {
19
20
  "tsc": "tsc",
20
21
  "ncu": "npx npm-check-updates",
@@ -26,7 +27,7 @@
26
27
  "prepublishOnly": "bun run build"
27
28
  },
28
29
  "peerDependencies": {
29
- "@pikku/core": "^0.12.133"
30
+ "@pikku/core": "^0.12.138"
30
31
  },
31
32
  "dependencies": {
32
33
  "kysely": "^0.29.5"