@treeseed/sdk 0.10.11 → 0.10.13

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.
Files changed (52) hide show
  1. package/README.md +2 -2
  2. package/dist/api/auth/d1-store.js +20 -1
  3. package/dist/capacity-provider.d.ts +53 -1
  4. package/dist/capacity.d.ts +80 -1
  5. package/dist/capacity.js +687 -8
  6. package/dist/db/d1.d.ts +109 -3227
  7. package/dist/db/index.d.ts +1 -0
  8. package/dist/db/index.js +1 -0
  9. package/dist/db/market-schema.d.ts +43769 -0
  10. package/dist/db/market-schema.js +1878 -0
  11. package/dist/db/node-sqlite.d.ts +109 -3227
  12. package/dist/db/schema.d.ts +226 -5757
  13. package/dist/db/schema.js +35 -226
  14. package/dist/index.d.ts +6 -4
  15. package/dist/index.js +32 -0
  16. package/dist/market-client.d.ts +135 -0
  17. package/dist/market-client.js +134 -1
  18. package/dist/operations/services/commit-message-provider.js +1 -1
  19. package/dist/operations/services/d1-migration.js +0 -59
  20. package/dist/operations/services/deploy.js +5 -1
  21. package/dist/operations/services/github-api.d.ts +83 -0
  22. package/dist/operations/services/github-api.js +167 -0
  23. package/dist/operations/services/local-dev.js +3 -3
  24. package/dist/operations/services/mailpit-runtime.d.ts +13 -2
  25. package/dist/operations/services/mailpit-runtime.js +19 -14
  26. package/dist/operations/services/project-web-monitor.d.ts +15 -0
  27. package/dist/operations/services/project-web-monitor.js +260 -0
  28. package/dist/operations/services/railway-api.js +2 -2
  29. package/dist/operations/services/release-candidate.js +9 -9
  30. package/dist/operations/services/runtime-paths.d.ts +1 -1
  31. package/dist/operations/services/runtime-paths.js +2 -2
  32. package/dist/operations/services/template-registry.js +10 -1
  33. package/dist/operations.d.ts +1 -0
  34. package/dist/operations.js +11 -1
  35. package/dist/platform-operation-store.d.ts +4 -0
  36. package/dist/platform-operation-store.js +29 -3
  37. package/dist/platform-operations.d.ts +8 -0
  38. package/dist/platform-operations.js +19 -0
  39. package/dist/remote.js +6 -6
  40. package/dist/scripts/tenant-d1-migrate-local.js +2 -3
  41. package/dist/scripts/test-cloudflare-local.js +1 -1
  42. package/dist/scripts/workspace-command-e2e.js +3 -1
  43. package/dist/sdk-types.d.ts +281 -3
  44. package/dist/sdk-types.js +5 -1
  45. package/dist/seeds/normalize.js +6 -0
  46. package/dist/seeds/schema.js +61 -1
  47. package/dist/seeds/types.d.ts +32 -0
  48. package/drizzle/d1/0000_treeseed_d1.sql +37 -0
  49. package/drizzle/market/0000_market_control_plane.sql +2929 -0
  50. package/drizzle/market/0001_capacity_budget_mode_default.sql +4 -0
  51. package/drizzle/market/0002_user_email_addresses.sql +26 -0
  52. package/package.json +8 -1
@@ -0,0 +1,2929 @@
1
+ CREATE TABLE IF NOT EXISTS "agent_messages" (
2
+ "id" serial PRIMARY KEY NOT NULL,
3
+ "type" text NOT NULL,
4
+ "payload_json" text NOT NULL,
5
+ "created_at" text NOT NULL
6
+ );
7
+
8
+ CREATE TABLE IF NOT EXISTS "agent_pool_registrations" (
9
+ "id" text PRIMARY KEY NOT NULL,
10
+ "pool_id" text NOT NULL,
11
+ "project_id" text NOT NULL,
12
+ "runner_id" text,
13
+ "manager_id" text,
14
+ "service_name" text,
15
+ "heartbeat_at" text NOT NULL,
16
+ "desired_workers" integer,
17
+ "observed_queue_depth" integer,
18
+ "observed_active_leases" integer,
19
+ "metadata_json" text,
20
+ "created_at" text NOT NULL,
21
+ "updated_at" text NOT NULL
22
+ );
23
+
24
+ CREATE TABLE IF NOT EXISTS "agent_pool_scale_decisions" (
25
+ "id" text PRIMARY KEY NOT NULL,
26
+ "pool_id" text NOT NULL,
27
+ "project_id" text NOT NULL,
28
+ "environment" text NOT NULL,
29
+ "desired_workers" integer NOT NULL,
30
+ "observed_queue_depth" integer DEFAULT 0 NOT NULL,
31
+ "observed_active_leases" integer DEFAULT 0 NOT NULL,
32
+ "work_day_id" text,
33
+ "reason" text NOT NULL,
34
+ "metadata_json" text NOT NULL,
35
+ "created_at" text NOT NULL,
36
+ "updated_at" text NOT NULL
37
+ );
38
+
39
+ CREATE TABLE IF NOT EXISTS "agent_pools" (
40
+ "id" text PRIMARY KEY NOT NULL,
41
+ "project_id" text NOT NULL,
42
+ "team_id" text NOT NULL,
43
+ "environment" text NOT NULL,
44
+ "name" text NOT NULL,
45
+ "registration_identity" text,
46
+ "service_base_url" text,
47
+ "status" text DEFAULT 'pending' NOT NULL,
48
+ "min_workers" integer DEFAULT 0 NOT NULL,
49
+ "max_workers" integer DEFAULT 1 NOT NULL,
50
+ "target_queue_depth" integer DEFAULT 1 NOT NULL,
51
+ "cooldown_seconds" integer DEFAULT 60 NOT NULL,
52
+ "metadata_json" text,
53
+ "created_at" text NOT NULL,
54
+ "updated_at" text NOT NULL
55
+ );
56
+
57
+ CREATE TABLE IF NOT EXISTS "agent_runs" (
58
+ "run_id" text PRIMARY KEY NOT NULL,
59
+ "agent_slug" text NOT NULL,
60
+ "status" text NOT NULL,
61
+ "created_at" text NOT NULL
62
+ );
63
+
64
+ CREATE TABLE IF NOT EXISTS "api_tokens" (
65
+ "id" text PRIMARY KEY NOT NULL,
66
+ "user_id" text NOT NULL,
67
+ "kind" text NOT NULL,
68
+ "name" text NOT NULL,
69
+ "token_prefix" text NOT NULL,
70
+ "token_hash" text NOT NULL,
71
+ "scopes_json" text NOT NULL,
72
+ "expires_at" text,
73
+ "last_used_at" text,
74
+ "revoked_at" text,
75
+ "metadata_json" text,
76
+ "created_at" text NOT NULL,
77
+ "updated_at" text NOT NULL
78
+ );
79
+
80
+ CREATE TABLE IF NOT EXISTS "approval_requests" (
81
+ "id" text PRIMARY KEY NOT NULL,
82
+ "team_id" text NOT NULL,
83
+ "project_id" text NOT NULL,
84
+ "work_day_id" text,
85
+ "task_id" text,
86
+ "kind" text NOT NULL,
87
+ "state" text DEFAULT 'pending' NOT NULL,
88
+ "severity" text DEFAULT 'medium' NOT NULL,
89
+ "requested_by_type" text DEFAULT 'worker' NOT NULL,
90
+ "requested_by_id" text,
91
+ "title" text NOT NULL,
92
+ "summary" text NOT NULL,
93
+ "options_json" text DEFAULT '[]' NOT NULL,
94
+ "recommendation_json" text DEFAULT '{}' NOT NULL,
95
+ "policy_snapshot_json" text DEFAULT '{}' NOT NULL,
96
+ "expires_at" text,
97
+ "decided_by_type" text,
98
+ "decided_by_id" text,
99
+ "decided_at" text,
100
+ "decision_json" text,
101
+ "metadata_json" text DEFAULT '{}' NOT NULL,
102
+ "created_at" text NOT NULL,
103
+ "updated_at" text NOT NULL
104
+ );
105
+
106
+ CREATE TABLE IF NOT EXISTS "audit_events" (
107
+ "id" text PRIMARY KEY NOT NULL,
108
+ "actor_type" text NOT NULL,
109
+ "actor_id" text,
110
+ "event_type" text NOT NULL,
111
+ "target_type" text,
112
+ "target_id" text,
113
+ "data_json" text,
114
+ "created_at" text NOT NULL
115
+ );
116
+
117
+ CREATE TABLE IF NOT EXISTS "auth_sessions" (
118
+ "id" text PRIMARY KEY NOT NULL,
119
+ "user_id" text NOT NULL,
120
+ "session_type" text NOT NULL,
121
+ "refresh_token_hash" text NOT NULL,
122
+ "scopes_json" text NOT NULL,
123
+ "expires_at" text NOT NULL,
124
+ "revoked_at" text,
125
+ "data_json" text,
126
+ "created_at" text NOT NULL,
127
+ "updated_at" text NOT NULL
128
+ );
129
+
130
+ CREATE TABLE IF NOT EXISTS "better_auth_account" (
131
+ "id" text PRIMARY KEY NOT NULL,
132
+ "accountId" text NOT NULL,
133
+ "providerId" text NOT NULL,
134
+ "userId" text NOT NULL,
135
+ "accessToken" text,
136
+ "refreshToken" text,
137
+ "idToken" text,
138
+ "accessTokenExpiresAt" bigint,
139
+ "refreshTokenExpiresAt" bigint,
140
+ "scope" text,
141
+ "password" text,
142
+ "createdAt" bigint NOT NULL,
143
+ "updatedAt" bigint NOT NULL
144
+ );
145
+
146
+ CREATE TABLE IF NOT EXISTS "better_auth_session" (
147
+ "id" text PRIMARY KEY NOT NULL,
148
+ "expiresAt" bigint NOT NULL,
149
+ "token" text NOT NULL,
150
+ "createdAt" bigint NOT NULL,
151
+ "updatedAt" bigint NOT NULL,
152
+ "ipAddress" text,
153
+ "userAgent" text,
154
+ "userId" text NOT NULL,
155
+ CONSTRAINT "better_auth_session_token_unique" UNIQUE("token")
156
+ );
157
+
158
+ CREATE TABLE IF NOT EXISTS "better_auth_user" (
159
+ "id" text PRIMARY KEY NOT NULL,
160
+ "name" text NOT NULL,
161
+ "email" text NOT NULL,
162
+ "emailVerified" integer DEFAULT 0 NOT NULL,
163
+ "image" text,
164
+ "createdAt" bigint NOT NULL,
165
+ "updatedAt" bigint NOT NULL,
166
+ "username" text,
167
+ "firstName" text,
168
+ "lastName" text,
169
+ CONSTRAINT "better_auth_user_email_unique" UNIQUE("email")
170
+ );
171
+
172
+ CREATE TABLE IF NOT EXISTS "better_auth_verification" (
173
+ "id" text PRIMARY KEY NOT NULL,
174
+ "identifier" text NOT NULL,
175
+ "value" text NOT NULL,
176
+ "expiresAt" bigint NOT NULL,
177
+ "createdAt" bigint NOT NULL,
178
+ "updatedAt" bigint NOT NULL
179
+ );
180
+
181
+ CREATE TABLE IF NOT EXISTS "capacity_grants" (
182
+ "id" text PRIMARY KEY NOT NULL,
183
+ "capacity_provider_id" text NOT NULL,
184
+ "lane_id" text,
185
+ "grant_scope" text DEFAULT 'team' NOT NULL,
186
+ "team_id" text NOT NULL,
187
+ "project_id" text,
188
+ "environment" text,
189
+ "state" text DEFAULT 'active' NOT NULL,
190
+ "daily_credit_limit" real,
191
+ "weekly_credit_limit" real,
192
+ "monthly_credit_limit" real,
193
+ "daily_usd_limit" real,
194
+ "weekly_quota_minutes" real,
195
+ "monthly_provider_units" real,
196
+ "priority_weight" real DEFAULT 1 NOT NULL,
197
+ "overflow_policy" text DEFAULT 'soft_grant' NOT NULL,
198
+ "metadata_json" text DEFAULT '{}' NOT NULL,
199
+ "created_at" text NOT NULL,
200
+ "updated_at" text NOT NULL
201
+ );
202
+
203
+ CREATE TABLE IF NOT EXISTS "capacity_ledger_entries" (
204
+ "id" text PRIMARY KEY NOT NULL,
205
+ "capacity_provider_id" text NOT NULL,
206
+ "lane_id" text,
207
+ "reservation_id" text,
208
+ "team_id" text NOT NULL,
209
+ "project_id" text,
210
+ "work_day_id" text,
211
+ "task_id" text,
212
+ "phase" text NOT NULL,
213
+ "credits" real NOT NULL,
214
+ "provider_units" real,
215
+ "usd" real,
216
+ "source" text NOT NULL,
217
+ "metadata_json" text DEFAULT '{}' NOT NULL,
218
+ "created_at" text NOT NULL
219
+ );
220
+
221
+ CREATE TABLE IF NOT EXISTS "capacity_provider_api_keys" (
222
+ "id" text PRIMARY KEY NOT NULL,
223
+ "capacity_provider_id" text NOT NULL,
224
+ "team_id" text NOT NULL,
225
+ "name" text NOT NULL,
226
+ "key_prefix" text NOT NULL,
227
+ "key_hash" text NOT NULL,
228
+ "scopes_json" text DEFAULT '[]' NOT NULL,
229
+ "status" text DEFAULT 'active' NOT NULL,
230
+ "last_used_at" text,
231
+ "rotated_from_key_id" text,
232
+ "expires_at" text,
233
+ "revoked_at" text,
234
+ "created_by_id" text,
235
+ "created_at" text NOT NULL,
236
+ "updated_at" text NOT NULL
237
+ );
238
+
239
+ CREATE TABLE IF NOT EXISTS "capacity_provider_deployments" (
240
+ "id" text PRIMARY KEY NOT NULL,
241
+ "team_id" text NOT NULL,
242
+ "capacity_provider_id" text NOT NULL,
243
+ "launch_mode" text NOT NULL,
244
+ "host_kind" text NOT NULL,
245
+ "host_id" text,
246
+ "status" text NOT NULL,
247
+ "image_ref" text,
248
+ "service_refs_json" text DEFAULT '{}' NOT NULL,
249
+ "env_refs_json" text DEFAULT '{}' NOT NULL,
250
+ "result_json" text DEFAULT '{}' NOT NULL,
251
+ "error_json" text,
252
+ "created_by_id" text,
253
+ "created_at" text NOT NULL,
254
+ "updated_at" text NOT NULL,
255
+ "completed_at" text
256
+ );
257
+
258
+ CREATE TABLE IF NOT EXISTS "capacity_provider_hosts" (
259
+ "id" text PRIMARY KEY NOT NULL,
260
+ "capacity_provider_id" text NOT NULL,
261
+ "host_id" text NOT NULL,
262
+ "role" text NOT NULL,
263
+ "required" integer DEFAULT 1 NOT NULL,
264
+ "metadata_json" text DEFAULT '{}' NOT NULL,
265
+ "created_at" text NOT NULL,
266
+ "updated_at" text NOT NULL
267
+ );
268
+
269
+ CREATE TABLE IF NOT EXISTS "capacity_provider_lanes" (
270
+ "id" text PRIMARY KEY NOT NULL,
271
+ "capacity_provider_id" text NOT NULL,
272
+ "name" text NOT NULL,
273
+ "business_model" text DEFAULT 'custom' NOT NULL,
274
+ "model_family" text,
275
+ "model_class" text,
276
+ "region_policy" text,
277
+ "unit" text DEFAULT 'treeseed_credit' NOT NULL,
278
+ "scarcity_level" text DEFAULT 'medium' NOT NULL,
279
+ "hard_limits_json" text DEFAULT '{}' NOT NULL,
280
+ "routing_policy_json" text DEFAULT '{}' NOT NULL,
281
+ "metadata_json" text DEFAULT '{}' NOT NULL,
282
+ "created_at" text NOT NULL,
283
+ "updated_at" text NOT NULL
284
+ );
285
+
286
+ CREATE TABLE IF NOT EXISTS "capacity_provider_registrations" (
287
+ "id" text PRIMARY KEY NOT NULL,
288
+ "capacity_provider_id" text NOT NULL,
289
+ "team_id" text NOT NULL,
290
+ "runtime_version" text NOT NULL,
291
+ "market_id" text NOT NULL,
292
+ "capabilities_json" text DEFAULT '[]' NOT NULL,
293
+ "budgets_json" text DEFAULT '{}' NOT NULL,
294
+ "health_json" text DEFAULT '{}' NOT NULL,
295
+ "status" text DEFAULT 'online' NOT NULL,
296
+ "registered_at" text NOT NULL,
297
+ "last_seen_at" text NOT NULL,
298
+ "disconnected_at" text,
299
+ "created_at" text NOT NULL,
300
+ "updated_at" text NOT NULL
301
+ );
302
+
303
+ CREATE TABLE IF NOT EXISTS "capacity_providers" (
304
+ "id" text PRIMARY KEY NOT NULL,
305
+ "team_id" text,
306
+ "owner_team_id" text,
307
+ "name" text NOT NULL,
308
+ "kind" text NOT NULL,
309
+ "status" text DEFAULT 'pending' NOT NULL,
310
+ "provider" text NOT NULL,
311
+ "billing_scope" text DEFAULT 'team' NOT NULL,
312
+ "monthly_credit_budget" real DEFAULT 0 NOT NULL,
313
+ "daily_credit_budget" real DEFAULT 0 NOT NULL,
314
+ "credit_budget_mode" text DEFAULT 'derived' NOT NULL,
315
+ "max_concurrent_workdays" integer DEFAULT 1 NOT NULL,
316
+ "max_concurrent_workers" integer DEFAULT 1 NOT NULL,
317
+ "capacity_model_json" text DEFAULT '{}' NOT NULL,
318
+ "metadata_json" text DEFAULT '{}' NOT NULL,
319
+ "created_at" text NOT NULL,
320
+ "updated_at" text NOT NULL
321
+ );
322
+
323
+ CREATE TABLE IF NOT EXISTS "capacity_reservations" (
324
+ "id" text PRIMARY KEY NOT NULL,
325
+ "capacity_provider_id" text NOT NULL,
326
+ "execution_provider_id" text,
327
+ "lane_id" text NOT NULL,
328
+ "team_id" text NOT NULL,
329
+ "project_id" text NOT NULL,
330
+ "work_day_id" text,
331
+ "task_id" text,
332
+ "state" text DEFAULT 'reserved' NOT NULL,
333
+ "reserved_credits" real NOT NULL,
334
+ "consumed_credits" real DEFAULT 0 NOT NULL,
335
+ "native_unit" text,
336
+ "reserved_native_amount" real,
337
+ "consumed_native_amount" real,
338
+ "reserved_provider_units" real,
339
+ "consumed_provider_units" real,
340
+ "reserved_usd" real,
341
+ "consumed_usd" real,
342
+ "expires_at" text,
343
+ "metadata_json" text DEFAULT '{}' NOT NULL,
344
+ "created_at" text NOT NULL,
345
+ "updated_at" text NOT NULL
346
+ );
347
+
348
+ CREATE TABLE IF NOT EXISTS "capacity_routing_decisions" (
349
+ "id" text PRIMARY KEY NOT NULL,
350
+ "task_id" text,
351
+ "work_day_id" text,
352
+ "project_id" text NOT NULL,
353
+ "selected_provider_id" text NOT NULL,
354
+ "selected_lane_id" text NOT NULL,
355
+ "selected_model" text,
356
+ "decision" text DEFAULT 'selected' NOT NULL,
357
+ "reason" text NOT NULL,
358
+ "candidate_json" text DEFAULT '[]' NOT NULL,
359
+ "score_json" text DEFAULT '{}' NOT NULL,
360
+ "metadata_json" text DEFAULT '{}' NOT NULL,
361
+ "created_at" text NOT NULL
362
+ );
363
+
364
+ CREATE TABLE IF NOT EXISTS "catalog_artifact_versions" (
365
+ "id" text PRIMARY KEY NOT NULL,
366
+ "item_id" text NOT NULL,
367
+ "team_id" text NOT NULL,
368
+ "kind" text NOT NULL,
369
+ "version" text NOT NULL,
370
+ "content_key" text NOT NULL,
371
+ "manifest_key" text,
372
+ "metadata_json" text,
373
+ "published_at" text NOT NULL,
374
+ "created_at" text NOT NULL,
375
+ "updated_at" text NOT NULL
376
+ );
377
+
378
+ CREATE TABLE IF NOT EXISTS "catalog_item_collaborators" (
379
+ "id" text PRIMARY KEY NOT NULL,
380
+ "item_id" text NOT NULL,
381
+ "subject_type" text NOT NULL,
382
+ "subject_id" text NOT NULL,
383
+ "role" text NOT NULL,
384
+ "metadata_json" text,
385
+ "created_at" text NOT NULL,
386
+ "updated_at" text NOT NULL
387
+ );
388
+
389
+ CREATE TABLE IF NOT EXISTS "catalog_items" (
390
+ "id" text PRIMARY KEY NOT NULL,
391
+ "team_id" text NOT NULL,
392
+ "kind" text NOT NULL,
393
+ "slug" text NOT NULL,
394
+ "title" text NOT NULL,
395
+ "summary" text,
396
+ "visibility" text NOT NULL,
397
+ "listing_enabled" integer DEFAULT 0 NOT NULL,
398
+ "offer_mode" text NOT NULL,
399
+ "manifest_key" text,
400
+ "artifact_key" text,
401
+ "search_text" text,
402
+ "metadata_json" text,
403
+ "created_at" text NOT NULL,
404
+ "updated_at" text NOT NULL
405
+ );
406
+
407
+ CREATE TABLE IF NOT EXISTS "contact_submissions" (
408
+ "id" serial PRIMARY KEY NOT NULL,
409
+ "email" text NOT NULL,
410
+ "message" text NOT NULL,
411
+ "created_at" text NOT NULL
412
+ );
413
+
414
+ CREATE TABLE IF NOT EXISTS "credit_conversion_profiles" (
415
+ "id" text PRIMARY KEY NOT NULL,
416
+ "task_signature" text NOT NULL,
417
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL,
418
+ "execution_provider_kind" text NOT NULL,
419
+ "native_unit" text NOT NULL,
420
+ "sample_count" integer DEFAULT 0 NOT NULL,
421
+ "completed_sample_count" integer DEFAULT 0 NOT NULL,
422
+ "interrupted_sample_count" integer DEFAULT 0 NOT NULL,
423
+ "native_units_per_credit_p50" real,
424
+ "native_units_per_credit_p90" real,
425
+ "credits_per_native_unit_p50" real,
426
+ "credits_per_native_unit_p90" real,
427
+ "actual_credits_p50" real,
428
+ "actual_credits_p90" real,
429
+ "confidence" text DEFAULT 'low' NOT NULL,
430
+ "formula_version" text NOT NULL,
431
+ "metadata_json" text DEFAULT '{}' NOT NULL,
432
+ "created_at" text NOT NULL,
433
+ "updated_at" text NOT NULL
434
+ );
435
+
436
+ CREATE TABLE IF NOT EXISTS "cursor_state" (
437
+ "agent_slug" text,
438
+ "cursor_key" text,
439
+ "status" text NOT NULL,
440
+ "schema_version" integer DEFAULT 1 NOT NULL,
441
+ "updated_at" text NOT NULL,
442
+ "payload_json" text NOT NULL,
443
+ "meta_json" text NOT NULL,
444
+ CONSTRAINT "cursor_state_agent_slug_cursor_key_pk" PRIMARY KEY("agent_slug","cursor_key")
445
+ );
446
+
447
+ CREATE TABLE IF NOT EXISTS "device_codes" (
448
+ "id" text PRIMARY KEY NOT NULL,
449
+ "device_code" text NOT NULL,
450
+ "user_code" text NOT NULL,
451
+ "requested_scopes_json" text NOT NULL,
452
+ "expires_at" text NOT NULL,
453
+ "interval_seconds" integer NOT NULL,
454
+ "status" text NOT NULL,
455
+ "user_id" text,
456
+ "created_at" text NOT NULL,
457
+ "updated_at" text NOT NULL,
458
+ CONSTRAINT "device_codes_device_code_unique" UNIQUE("device_code"),
459
+ CONSTRAINT "device_codes_user_code_unique" UNIQUE("user_code")
460
+ );
461
+
462
+ CREATE TABLE IF NOT EXISTS "entitlements" (
463
+ "id" text PRIMARY KEY NOT NULL,
464
+ "team_id" text,
465
+ "project_id" text,
466
+ "tier" text NOT NULL,
467
+ "status" text NOT NULL,
468
+ "metadata_json" text,
469
+ "created_at" text NOT NULL,
470
+ "updated_at" text NOT NULL
471
+ );
472
+
473
+ CREATE TABLE IF NOT EXISTS "execution_provider_native_limits" (
474
+ "id" text PRIMARY KEY NOT NULL,
475
+ "execution_provider_id" text NOT NULL,
476
+ "scope" text NOT NULL,
477
+ "native_unit" text NOT NULL,
478
+ "limit_amount" real NOT NULL,
479
+ "reserve_buffer_percent" real DEFAULT 0 NOT NULL,
480
+ "reset_cadence" text,
481
+ "reset_at" text,
482
+ "confidence" text DEFAULT 'estimated' NOT NULL,
483
+ "source" text DEFAULT 'configured' NOT NULL,
484
+ "metadata_json" text DEFAULT '{}' NOT NULL,
485
+ "created_at" text NOT NULL,
486
+ "updated_at" text NOT NULL
487
+ );
488
+
489
+ CREATE TABLE IF NOT EXISTS "execution_provider_observations" (
490
+ "id" text PRIMARY KEY NOT NULL,
491
+ "execution_provider_id" text NOT NULL,
492
+ "observed_at" text NOT NULL,
493
+ "health" text DEFAULT 'unknown' NOT NULL,
494
+ "active_workers" integer,
495
+ "queued_tasks" integer,
496
+ "throttle_state" text,
497
+ "native_remaining_json" text DEFAULT '{}' NOT NULL,
498
+ "reset_at" text,
499
+ "confidence" text DEFAULT 'estimated' NOT NULL,
500
+ "metadata_json" text DEFAULT '{}' NOT NULL,
501
+ "created_at" text NOT NULL
502
+ );
503
+
504
+ CREATE TABLE IF NOT EXISTS "execution_providers" (
505
+ "id" text PRIMARY KEY NOT NULL,
506
+ "team_id" text NOT NULL,
507
+ "capacity_provider_id" text,
508
+ "name" text NOT NULL,
509
+ "kind" text NOT NULL,
510
+ "status" text DEFAULT 'active' NOT NULL,
511
+ "native_unit" text NOT NULL,
512
+ "quota_visibility" text DEFAULT 'opaque' NOT NULL,
513
+ "max_concurrent_workers" integer DEFAULT 1 NOT NULL,
514
+ "reset_cadence" text,
515
+ "config_json" text DEFAULT '{}' NOT NULL,
516
+ "metadata_json" text DEFAULT '{}' NOT NULL,
517
+ "created_at" text NOT NULL,
518
+ "updated_at" text NOT NULL
519
+ );
520
+
521
+ CREATE TABLE IF NOT EXISTS "graph_runs" (
522
+ "id" text PRIMARY KEY NOT NULL,
523
+ "work_day_id" text NOT NULL,
524
+ "corpus_hash" text NOT NULL,
525
+ "graph_version" text NOT NULL,
526
+ "query_json" text,
527
+ "seed_ids_json" text,
528
+ "selected_node_ids_json" text,
529
+ "stats_json" text,
530
+ "snapshot_ref" text,
531
+ "created_at" text NOT NULL
532
+ );
533
+
534
+ CREATE TABLE IF NOT EXISTS "hub_content_sources" (
535
+ "id" text PRIMARY KEY NOT NULL,
536
+ "hub_id" text NOT NULL,
537
+ "team_id" text NOT NULL,
538
+ "content_repository_id" text,
539
+ "production_source" text NOT NULL,
540
+ "overlay_policy" text NOT NULL,
541
+ "r2_bucket_name" text,
542
+ "r2_manifest_key" text,
543
+ "r2_public_base_url" text,
544
+ "latest_publish_id" text,
545
+ "latest_content_version" text,
546
+ "metadata_json" text DEFAULT '{}' NOT NULL,
547
+ "created_at" text NOT NULL,
548
+ "updated_at" text NOT NULL,
549
+ CONSTRAINT "hub_content_sources_hub_id_unique" UNIQUE("hub_id")
550
+ );
551
+
552
+ CREATE TABLE IF NOT EXISTS "hub_launch_events" (
553
+ "id" text PRIMARY KEY NOT NULL,
554
+ "launch_id" text NOT NULL,
555
+ "seq" integer NOT NULL,
556
+ "phase" text NOT NULL,
557
+ "status" text NOT NULL,
558
+ "title" text,
559
+ "summary" text,
560
+ "started_at" text,
561
+ "finished_at" text,
562
+ "error_json" text,
563
+ "data_json" text DEFAULT '{}' NOT NULL,
564
+ "created_at" text NOT NULL
565
+ );
566
+
567
+ CREATE TABLE IF NOT EXISTS "hub_launches" (
568
+ "id" text PRIMARY KEY NOT NULL,
569
+ "hub_id" text NOT NULL,
570
+ "team_id" text NOT NULL,
571
+ "job_id" text,
572
+ "intent_json" text NOT NULL,
573
+ "plan_json" text DEFAULT '{}' NOT NULL,
574
+ "state" text NOT NULL,
575
+ "current_phase" text,
576
+ "last_successful_phase" text,
577
+ "result_json" text,
578
+ "error_json" text,
579
+ "created_at" text NOT NULL,
580
+ "updated_at" text NOT NULL,
581
+ "completed_at" text
582
+ );
583
+
584
+ CREATE TABLE IF NOT EXISTS "hub_repositories" (
585
+ "id" text PRIMARY KEY NOT NULL,
586
+ "hub_id" text NOT NULL,
587
+ "team_id" text NOT NULL,
588
+ "role" text NOT NULL,
589
+ "repository_host_id" text,
590
+ "provider" text NOT NULL,
591
+ "owner" text NOT NULL,
592
+ "name" text NOT NULL,
593
+ "url" text,
594
+ "default_branch" text,
595
+ "current_branch" text,
596
+ "status" text DEFAULT 'queued' NOT NULL,
597
+ "access_policy_json" text DEFAULT '{}' NOT NULL,
598
+ "release_policy_json" text DEFAULT '{}' NOT NULL,
599
+ "publish_policy_json" text DEFAULT '{}' NOT NULL,
600
+ "submodule_path" text,
601
+ "metadata_json" text DEFAULT '{}' NOT NULL,
602
+ "created_at" text NOT NULL,
603
+ "updated_at" text NOT NULL
604
+ );
605
+
606
+ CREATE TABLE IF NOT EXISTS "hub_workspace_links" (
607
+ "id" text PRIMARY KEY NOT NULL,
608
+ "hub_id" text NOT NULL,
609
+ "team_id" text NOT NULL,
610
+ "parent_repository_host_id" text,
611
+ "parent_owner" text,
612
+ "parent_name" text,
613
+ "parent_url" text,
614
+ "parent_branch" text,
615
+ "hub_mount_path" text,
616
+ "software_submodule_path" text,
617
+ "content_submodule_path" text,
618
+ "update_submodule_pointers_enabled" integer DEFAULT 0 NOT NULL,
619
+ "access_policy_json" text DEFAULT '{}' NOT NULL,
620
+ "metadata_json" text DEFAULT '{}' NOT NULL,
621
+ "created_at" text NOT NULL,
622
+ "updated_at" text NOT NULL
623
+ );
624
+
625
+ CREATE TABLE IF NOT EXISTS "knowledge_packs" (
626
+ "id" text PRIMARY KEY NOT NULL,
627
+ "team_id" text NOT NULL,
628
+ "slug" text NOT NULL,
629
+ "name" text NOT NULL,
630
+ "summary" text,
631
+ "source_kind" text NOT NULL,
632
+ "source_ref" text,
633
+ "install_strategy" text NOT NULL,
634
+ "visibility" text NOT NULL,
635
+ "metadata_json" text,
636
+ "created_at" text NOT NULL,
637
+ "updated_at" text NOT NULL,
638
+ CONSTRAINT "knowledge_packs_slug_unique" UNIQUE("slug")
639
+ );
640
+
641
+ CREATE TABLE IF NOT EXISTS "lease_state" (
642
+ "model" text,
643
+ "item_key" text,
644
+ "status" text NOT NULL,
645
+ "schema_version" integer DEFAULT 1 NOT NULL,
646
+ "claimed_by" text,
647
+ "claimed_at" text,
648
+ "lease_expires_at" text,
649
+ "created_at" text NOT NULL,
650
+ "updated_at" text NOT NULL,
651
+ "payload_json" text NOT NULL,
652
+ "meta_json" text NOT NULL,
653
+ CONSTRAINT "lease_state_model_item_key_pk" PRIMARY KEY("model","item_key")
654
+ );
655
+
656
+ CREATE TABLE IF NOT EXISTS "market_auth_credentials" (
657
+ "user_id" text PRIMARY KEY NOT NULL,
658
+ "email" text NOT NULL,
659
+ "username" text,
660
+ "password_hash" text NOT NULL,
661
+ "status" text DEFAULT 'active' NOT NULL,
662
+ "created_at" text NOT NULL,
663
+ "updated_at" text NOT NULL,
664
+ CONSTRAINT "market_auth_credentials_email_unique" UNIQUE("email"),
665
+ CONSTRAINT "market_auth_credentials_username_unique" UNIQUE("username")
666
+ );
667
+
668
+ CREATE TABLE IF NOT EXISTS "market_auth_password_resets" (
669
+ "id" text PRIMARY KEY NOT NULL,
670
+ "user_id" text NOT NULL,
671
+ "token_hash" text NOT NULL,
672
+ "expires_at" text NOT NULL,
673
+ "used_at" text,
674
+ "created_at" text NOT NULL,
675
+ CONSTRAINT "market_auth_password_resets_token_hash_unique" UNIQUE("token_hash")
676
+ );
677
+
678
+ CREATE TABLE IF NOT EXISTS "market_operation_runners" (
679
+ "id" text PRIMARY KEY NOT NULL,
680
+ "runner_key" text NOT NULL,
681
+ "name" text NOT NULL,
682
+ "environment" text NOT NULL,
683
+ "status" text DEFAULT 'online' NOT NULL,
684
+ "version" text,
685
+ "capabilities_json" text DEFAULT '[]' NOT NULL,
686
+ "active_job_count" integer DEFAULT 0 NOT NULL,
687
+ "max_concurrent_jobs" integer DEFAULT 1 NOT NULL,
688
+ "heartbeat_at" text,
689
+ "metadata_json" text DEFAULT '{}' NOT NULL,
690
+ "created_at" text NOT NULL,
691
+ "updated_at" text NOT NULL,
692
+ CONSTRAINT "market_operation_runners_runner_key_unique" UNIQUE("runner_key")
693
+ );
694
+
695
+ CREATE TABLE IF NOT EXISTS "message_queue" (
696
+ "id" serial PRIMARY KEY NOT NULL,
697
+ "message_type" text NOT NULL,
698
+ "status" text NOT NULL,
699
+ "schema_version" integer DEFAULT 1 NOT NULL,
700
+ "related_model" text,
701
+ "related_id" text,
702
+ "priority" integer DEFAULT 0 NOT NULL,
703
+ "available_at" text NOT NULL,
704
+ "claimed_by" text,
705
+ "claimed_at" text,
706
+ "lease_expires_at" text,
707
+ "attempts" integer DEFAULT 0 NOT NULL,
708
+ "max_attempts" integer DEFAULT 3 NOT NULL,
709
+ "created_at" text NOT NULL,
710
+ "updated_at" text NOT NULL,
711
+ "payload_json" text NOT NULL,
712
+ "meta_json" text NOT NULL
713
+ );
714
+
715
+ CREATE TABLE IF NOT EXISTS "native_usage_observations" (
716
+ "id" text PRIMARY KEY NOT NULL,
717
+ "task_usage_actual_id" text,
718
+ "task_id" text,
719
+ "work_day_id" text,
720
+ "project_id" text NOT NULL,
721
+ "task_signature" text NOT NULL,
722
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL,
723
+ "capacity_provider_id" text,
724
+ "execution_provider_id" text,
725
+ "native_unit" text,
726
+ "native_usage_json" text DEFAULT '{}' NOT NULL,
727
+ "observed_at" text NOT NULL,
728
+ "source" text DEFAULT 'provider_report' NOT NULL,
729
+ "formula_version" text DEFAULT 'treeseed.actual-credits.v1' NOT NULL,
730
+ "actual_credits" real NOT NULL,
731
+ "metadata_json" text DEFAULT '{}' NOT NULL,
732
+ "created_at" text NOT NULL
733
+ );
734
+
735
+ CREATE TABLE IF NOT EXISTS "permissions" (
736
+ "id" text PRIMARY KEY NOT NULL,
737
+ "key" text NOT NULL,
738
+ "resource" text NOT NULL,
739
+ "action" text NOT NULL,
740
+ "scope" text NOT NULL,
741
+ "description" text,
742
+ "created_at" text NOT NULL,
743
+ CONSTRAINT "permissions_key_unique" UNIQUE("key")
744
+ );
745
+
746
+ CREATE TABLE IF NOT EXISTS "platform_operation_events" (
747
+ "id" text PRIMARY KEY NOT NULL,
748
+ "operation_id" text NOT NULL,
749
+ "seq" integer NOT NULL,
750
+ "kind" text NOT NULL,
751
+ "data_json" text DEFAULT '{}' NOT NULL,
752
+ "created_at" text NOT NULL
753
+ );
754
+
755
+ CREATE TABLE IF NOT EXISTS "platform_operations" (
756
+ "id" text PRIMARY KEY NOT NULL,
757
+ "namespace" text NOT NULL,
758
+ "operation" text NOT NULL,
759
+ "status" text NOT NULL,
760
+ "target" text NOT NULL,
761
+ "idempotency_key" text,
762
+ "input_json" text DEFAULT '{}' NOT NULL,
763
+ "output_json" text,
764
+ "error_json" text,
765
+ "requested_by_type" text NOT NULL,
766
+ "requested_by_id" text,
767
+ "assigned_runner_id" text,
768
+ "lease_expires_at" text,
769
+ "created_at" text NOT NULL,
770
+ "updated_at" text NOT NULL,
771
+ "started_at" text,
772
+ "finished_at" text,
773
+ "cancelled_at" text
774
+ );
775
+
776
+ CREATE TABLE IF NOT EXISTS "platform_repository_claims" (
777
+ "id" text PRIMARY KEY NOT NULL,
778
+ "repository_key" text NOT NULL,
779
+ "runner_id" text NOT NULL,
780
+ "workspace_path" text NOT NULL,
781
+ "branch" text,
782
+ "commit_sha" text,
783
+ "claim_state" text DEFAULT 'active' NOT NULL,
784
+ "lease_expires_at" text,
785
+ "metadata_json" text DEFAULT '{}' NOT NULL,
786
+ "created_at" text NOT NULL,
787
+ "updated_at" text NOT NULL
788
+ );
789
+
790
+ CREATE TABLE IF NOT EXISTS "priority_overrides" (
791
+ "id" text PRIMARY KEY NOT NULL,
792
+ "project_id" text NOT NULL,
793
+ "model" text NOT NULL,
794
+ "subject_id" text NOT NULL,
795
+ "priority" real DEFAULT 0 NOT NULL,
796
+ "estimated_credits" real,
797
+ "metadata_json" text NOT NULL,
798
+ "created_at" text NOT NULL,
799
+ "updated_at" text NOT NULL
800
+ );
801
+
802
+ CREATE TABLE IF NOT EXISTS "priority_snapshots" (
803
+ "id" text PRIMARY KEY NOT NULL,
804
+ "project_id" text NOT NULL,
805
+ "work_day_id" text,
806
+ "snapshot_json" text NOT NULL,
807
+ "metadata_json" text NOT NULL,
808
+ "generated_at" text NOT NULL,
809
+ "created_at" text NOT NULL,
810
+ "updated_at" text NOT NULL
811
+ );
812
+
813
+ CREATE TABLE IF NOT EXISTS "project_capability_grants" (
814
+ "id" text PRIMARY KEY NOT NULL,
815
+ "project_id" text NOT NULL,
816
+ "label" text,
817
+ "namespace" text NOT NULL,
818
+ "operation" text NOT NULL,
819
+ "execution_class" text NOT NULL,
820
+ "allowed_targets_json" text NOT NULL,
821
+ "default_dispatch_mode" text NOT NULL,
822
+ "approval_policy_json" text DEFAULT '{}' NOT NULL,
823
+ "resource_scope_json" text DEFAULT '{}' NOT NULL,
824
+ "metadata_json" text DEFAULT '{}' NOT NULL,
825
+ "enabled" integer DEFAULT 1 NOT NULL,
826
+ "created_at" text NOT NULL,
827
+ "updated_at" text NOT NULL
828
+ );
829
+
830
+ CREATE TABLE IF NOT EXISTS "project_connections" (
831
+ "id" text PRIMARY KEY NOT NULL,
832
+ "project_id" text NOT NULL,
833
+ "mode" text NOT NULL,
834
+ "project_api_base_url" text,
835
+ "execution_owner" text NOT NULL,
836
+ "runner_registration_state" text DEFAULT 'pending' NOT NULL,
837
+ "runner_key_prefix" text,
838
+ "runner_key_hash" text,
839
+ "runner_registered_at" text,
840
+ "runner_last_seen_at" text,
841
+ "metadata_json" text,
842
+ "created_at" text NOT NULL,
843
+ "updated_at" text NOT NULL,
844
+ CONSTRAINT "project_connections_project_id_unique" UNIQUE("project_id")
845
+ );
846
+
847
+ CREATE TABLE IF NOT EXISTS "project_deployment_events" (
848
+ "id" text PRIMARY KEY NOT NULL,
849
+ "deployment_id" text NOT NULL,
850
+ "project_id" text NOT NULL,
851
+ "team_id" text NOT NULL,
852
+ "operation_id" text,
853
+ "kind" text NOT NULL,
854
+ "message" text NOT NULL,
855
+ "status" text,
856
+ "severity" text DEFAULT 'info' NOT NULL,
857
+ "sequence" integer NOT NULL,
858
+ "payload_json" text DEFAULT '{}' NOT NULL,
859
+ "created_at" text NOT NULL
860
+ );
861
+
862
+ CREATE TABLE IF NOT EXISTS "project_deployments" (
863
+ "id" text PRIMARY KEY NOT NULL,
864
+ "team_id" text NOT NULL,
865
+ "project_id" text NOT NULL,
866
+ "environment" text NOT NULL,
867
+ "deployment_kind" text NOT NULL,
868
+ "action" text DEFAULT 'deploy_web' NOT NULL,
869
+ "status" text NOT NULL,
870
+ "platform_operation_id" text,
871
+ "retry_of_deployment_id" text,
872
+ "resumed_from_deployment_id" text,
873
+ "idempotency_key" text,
874
+ "requested_by_user_id" text,
875
+ "source_ref" text,
876
+ "release_tag" text,
877
+ "commit_sha" text,
878
+ "triggered_by_type" text,
879
+ "triggered_by_id" text,
880
+ "repository_json" text DEFAULT '{}' NOT NULL,
881
+ "external_workflow_json" text DEFAULT '{}' NOT NULL,
882
+ "target_json" text DEFAULT '{}' NOT NULL,
883
+ "monitor_json" text DEFAULT '{}' NOT NULL,
884
+ "summary" text,
885
+ "error_json" text DEFAULT '{}' NOT NULL,
886
+ "metadata_json" text,
887
+ "started_at" text,
888
+ "finished_at" text,
889
+ "created_at" text NOT NULL,
890
+ "updated_at" text NOT NULL,
891
+ "completed_at" text
892
+ );
893
+
894
+ CREATE TABLE IF NOT EXISTS "project_environments" (
895
+ "id" text PRIMARY KEY NOT NULL,
896
+ "project_id" text NOT NULL,
897
+ "environment" text NOT NULL,
898
+ "deployment_profile" text NOT NULL,
899
+ "base_url" text,
900
+ "cloudflare_account_id" text,
901
+ "pages_project_name" text,
902
+ "worker_name" text,
903
+ "r2_bucket_name" text,
904
+ "d1_database_name" text,
905
+ "queue_name" text,
906
+ "railway_project_name" text,
907
+ "metadata_json" text,
908
+ "created_at" text NOT NULL,
909
+ "updated_at" text NOT NULL
910
+ );
911
+
912
+ CREATE TABLE IF NOT EXISTS "project_hosting" (
913
+ "id" text PRIMARY KEY NOT NULL,
914
+ "project_id" text NOT NULL,
915
+ "hosting_kind" text NOT NULL,
916
+ "registration" text DEFAULT 'none' NOT NULL,
917
+ "market_base_url" text,
918
+ "source_repo_owner" text,
919
+ "source_repo_name" text,
920
+ "source_repo_url" text,
921
+ "source_repo_workflow_path" text,
922
+ "metadata_json" text,
923
+ "created_at" text NOT NULL,
924
+ "updated_at" text NOT NULL,
925
+ CONSTRAINT "project_hosting_project_id_unique" UNIQUE("project_id")
926
+ );
927
+
928
+ CREATE TABLE IF NOT EXISTS "project_infrastructure_resources" (
929
+ "id" text PRIMARY KEY NOT NULL,
930
+ "project_id" text NOT NULL,
931
+ "environment" text NOT NULL,
932
+ "provider" text NOT NULL,
933
+ "resource_kind" text NOT NULL,
934
+ "logical_name" text NOT NULL,
935
+ "locator" text,
936
+ "metadata_json" text,
937
+ "created_at" text NOT NULL,
938
+ "updated_at" text NOT NULL
939
+ );
940
+
941
+ CREATE TABLE IF NOT EXISTS "project_summary_snapshots" (
942
+ "project_id" text PRIMARY KEY NOT NULL,
943
+ "team_id" text NOT NULL,
944
+ "summary_json" text NOT NULL,
945
+ "generated_at" text NOT NULL,
946
+ "created_at" text NOT NULL,
947
+ "updated_at" text NOT NULL
948
+ );
949
+
950
+ CREATE TABLE IF NOT EXISTS "project_update_plans" (
951
+ "id" text PRIMARY KEY NOT NULL,
952
+ "hub_id" text NOT NULL,
953
+ "team_id" text NOT NULL,
954
+ "source_kind" text NOT NULL,
955
+ "source_ref" text,
956
+ "source_version" text,
957
+ "plan_json" text DEFAULT '{}' NOT NULL,
958
+ "state" text DEFAULT 'planned' NOT NULL,
959
+ "requires_decision" integer DEFAULT 0 NOT NULL,
960
+ "decision_id" text,
961
+ "created_by" text,
962
+ "created_at" text NOT NULL,
963
+ "updated_at" text NOT NULL
964
+ );
965
+
966
+ CREATE TABLE IF NOT EXISTS "project_workday_summaries" (
967
+ "id" text PRIMARY KEY NOT NULL,
968
+ "project_id" text NOT NULL,
969
+ "environment" text NOT NULL,
970
+ "work_day_id" text NOT NULL,
971
+ "kind" text NOT NULL,
972
+ "state" text,
973
+ "started_at" text,
974
+ "ended_at" text,
975
+ "summary_json" text NOT NULL,
976
+ "metadata_json" text NOT NULL,
977
+ "created_at" text NOT NULL,
978
+ "updated_at" text NOT NULL
979
+ );
980
+
981
+ CREATE TABLE IF NOT EXISTS "projects" (
982
+ "id" text PRIMARY KEY NOT NULL,
983
+ "team_id" text NOT NULL,
984
+ "slug" text NOT NULL,
985
+ "name" text NOT NULL,
986
+ "description" text,
987
+ "metadata_json" text,
988
+ "created_at" text NOT NULL,
989
+ "updated_at" text NOT NULL,
990
+ CONSTRAINT "projects_slug_unique" UNIQUE("slug")
991
+ );
992
+
993
+ CREATE TABLE IF NOT EXISTS "provider_credential_sessions" (
994
+ "id" text PRIMARY KEY NOT NULL,
995
+ "team_id" text NOT NULL,
996
+ "project_id" text,
997
+ "job_id" text,
998
+ "host_kind" text NOT NULL,
999
+ "host_id" text NOT NULL,
1000
+ "purpose" text NOT NULL,
1001
+ "encrypted_payload_json" text NOT NULL,
1002
+ "status" text DEFAULT 'active' NOT NULL,
1003
+ "expires_at" text NOT NULL,
1004
+ "consumed_at" text,
1005
+ "created_by_id" text,
1006
+ "created_at" text NOT NULL,
1007
+ "updated_at" text NOT NULL,
1008
+ "metadata_json" text DEFAULT '{}' NOT NULL
1009
+ );
1010
+
1011
+ CREATE TABLE IF NOT EXISTS "remote_job_events" (
1012
+ "id" text PRIMARY KEY NOT NULL,
1013
+ "job_id" text NOT NULL,
1014
+ "seq" integer NOT NULL,
1015
+ "kind" text NOT NULL,
1016
+ "data_json" text,
1017
+ "created_at" text NOT NULL
1018
+ );
1019
+
1020
+ CREATE TABLE IF NOT EXISTS "remote_jobs" (
1021
+ "id" text PRIMARY KEY NOT NULL,
1022
+ "project_id" text NOT NULL,
1023
+ "namespace" text NOT NULL,
1024
+ "operation" text NOT NULL,
1025
+ "status" text NOT NULL,
1026
+ "preferred_mode" text NOT NULL,
1027
+ "selected_target" text NOT NULL,
1028
+ "capability_json" text NOT NULL,
1029
+ "input_json" text NOT NULL,
1030
+ "output_json" text,
1031
+ "error_json" text,
1032
+ "requested_by_type" text NOT NULL,
1033
+ "requested_by_id" text,
1034
+ "assigned_runner_id" text,
1035
+ "idempotency_key" text,
1036
+ "created_at" text NOT NULL,
1037
+ "updated_at" text NOT NULL,
1038
+ "started_at" text,
1039
+ "finished_at" text,
1040
+ "cancelled_at" text
1041
+ );
1042
+
1043
+ CREATE TABLE IF NOT EXISTS "reports" (
1044
+ "id" text PRIMARY KEY NOT NULL,
1045
+ "work_day_id" text NOT NULL,
1046
+ "kind" text NOT NULL,
1047
+ "body_json" text NOT NULL,
1048
+ "rendered_ref" text,
1049
+ "sent_at" text,
1050
+ "created_at" text NOT NULL
1051
+ );
1052
+
1053
+ CREATE TABLE IF NOT EXISTS "repository_claims" (
1054
+ "id" text PRIMARY KEY NOT NULL,
1055
+ "project_id" text NOT NULL,
1056
+ "repository_id" text NOT NULL,
1057
+ "runner_id" text NOT NULL,
1058
+ "runner_service_name" text NOT NULL,
1059
+ "volume_identity" text NOT NULL,
1060
+ "last_seen_commit" text,
1061
+ "last_task_at" text,
1062
+ "claim_state" text DEFAULT 'active' NOT NULL,
1063
+ "metadata_json" text NOT NULL,
1064
+ "created_at" text NOT NULL,
1065
+ "updated_at" text NOT NULL
1066
+ );
1067
+
1068
+ CREATE TABLE IF NOT EXISTS "repository_hosts" (
1069
+ "id" text PRIMARY KEY NOT NULL,
1070
+ "team_id" text,
1071
+ "provider" text NOT NULL,
1072
+ "ownership" text NOT NULL,
1073
+ "name" text NOT NULL,
1074
+ "account_label" text,
1075
+ "organization_or_owner" text NOT NULL,
1076
+ "default_visibility" text DEFAULT 'private' NOT NULL,
1077
+ "software_repository_name_template" text DEFAULT '{hub}-site' NOT NULL,
1078
+ "content_repository_name_template" text DEFAULT '{hub}-content' NOT NULL,
1079
+ "branch_policy_json" text DEFAULT '{}' NOT NULL,
1080
+ "workflow_policy_json" text DEFAULT '{}' NOT NULL,
1081
+ "encrypted_payload_json" text,
1082
+ "allowed_project_kinds_json" text DEFAULT '["knowledge_hub"]' NOT NULL,
1083
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1084
+ "status" text DEFAULT 'active' NOT NULL,
1085
+ "created_by_id" text,
1086
+ "updated_by_id" text,
1087
+ "created_at" text NOT NULL,
1088
+ "updated_at" text NOT NULL
1089
+ );
1090
+
1091
+ CREATE TABLE IF NOT EXISTS "role_permissions" (
1092
+ "role_id" text,
1093
+ "permission_id" text,
1094
+ "created_at" text NOT NULL,
1095
+ CONSTRAINT "role_permissions_role_id_permission_id_pk" PRIMARY KEY("role_id","permission_id")
1096
+ );
1097
+
1098
+ CREATE TABLE IF NOT EXISTS "roles" (
1099
+ "id" text PRIMARY KEY NOT NULL,
1100
+ "key" text NOT NULL,
1101
+ "description" text,
1102
+ "created_at" text NOT NULL,
1103
+ CONSTRAINT "roles_key_unique" UNIQUE("key")
1104
+ );
1105
+
1106
+ CREATE TABLE IF NOT EXISTS "runner_scale_decisions" (
1107
+ "id" text PRIMARY KEY NOT NULL,
1108
+ "project_id" text NOT NULL,
1109
+ "environment" text NOT NULL,
1110
+ "work_day_id" text,
1111
+ "runner_id" text,
1112
+ "runner_service_name" text,
1113
+ "action" text NOT NULL,
1114
+ "reason" text NOT NULL,
1115
+ "metadata_json" text NOT NULL,
1116
+ "created_at" text NOT NULL
1117
+ );
1118
+
1119
+ CREATE TABLE IF NOT EXISTS "runtime_envelopes" (
1120
+ "id" serial PRIMARY KEY NOT NULL,
1121
+ "record_type" text NOT NULL,
1122
+ "payload_json" text NOT NULL,
1123
+ "created_at" text NOT NULL
1124
+ );
1125
+
1126
+ CREATE TABLE IF NOT EXISTS "runtime_records" (
1127
+ "id" serial PRIMARY KEY NOT NULL,
1128
+ "record_type" text NOT NULL,
1129
+ "record_key" text NOT NULL,
1130
+ "lookup_key" text,
1131
+ "secondary_key" text,
1132
+ "status" text NOT NULL,
1133
+ "schema_version" integer DEFAULT 1 NOT NULL,
1134
+ "created_at" text NOT NULL,
1135
+ "updated_at" text NOT NULL,
1136
+ "payload_json" text NOT NULL,
1137
+ "meta_json" text NOT NULL
1138
+ );
1139
+
1140
+ CREATE TABLE IF NOT EXISTS "scale_decisions" (
1141
+ "id" text PRIMARY KEY NOT NULL,
1142
+ "project_id" text NOT NULL,
1143
+ "environment" text NOT NULL,
1144
+ "pool_name" text NOT NULL,
1145
+ "work_day_id" text,
1146
+ "desired_workers" integer NOT NULL,
1147
+ "observed_queue_depth" integer DEFAULT 0 NOT NULL,
1148
+ "observed_active_leases" integer DEFAULT 0 NOT NULL,
1149
+ "reason" text NOT NULL,
1150
+ "metadata_json" text NOT NULL,
1151
+ "created_at" text NOT NULL
1152
+ );
1153
+
1154
+ CREATE TABLE IF NOT EXISTS "seed_runs" (
1155
+ "id" text PRIMARY KEY NOT NULL,
1156
+ "seed_name" text NOT NULL,
1157
+ "seed_version" integer NOT NULL,
1158
+ "environments_json" text NOT NULL,
1159
+ "mode" text NOT NULL,
1160
+ "state" text NOT NULL,
1161
+ "actor_type" text,
1162
+ "actor_id" text,
1163
+ "manifest_hash" text NOT NULL,
1164
+ "plan_json" text NOT NULL,
1165
+ "result_json" text,
1166
+ "error_json" text,
1167
+ "created_at" text NOT NULL,
1168
+ "updated_at" text NOT NULL,
1169
+ "completed_at" text
1170
+ );
1171
+
1172
+ CREATE TABLE IF NOT EXISTS "service_credentials" (
1173
+ "id" text PRIMARY KEY NOT NULL,
1174
+ "service_id" text NOT NULL,
1175
+ "name" text NOT NULL,
1176
+ "secret_hash" text NOT NULL,
1177
+ "roles_json" text NOT NULL,
1178
+ "permissions_json" text NOT NULL,
1179
+ "revoked_at" text,
1180
+ "created_at" text NOT NULL,
1181
+ "updated_at" text NOT NULL,
1182
+ "last_used_at" text,
1183
+ CONSTRAINT "service_credentials_service_id_unique" UNIQUE("service_id")
1184
+ );
1185
+
1186
+ CREATE TABLE IF NOT EXISTS "subscribers" (
1187
+ "email" text PRIMARY KEY NOT NULL,
1188
+ "created_at" text NOT NULL
1189
+ );
1190
+
1191
+ CREATE TABLE IF NOT EXISTS "task_credit_ledger" (
1192
+ "id" text PRIMARY KEY NOT NULL,
1193
+ "project_id" text NOT NULL,
1194
+ "work_day_id" text NOT NULL,
1195
+ "task_id" text,
1196
+ "phase" text NOT NULL,
1197
+ "credits" real NOT NULL,
1198
+ "metadata_json" text NOT NULL,
1199
+ "created_at" text NOT NULL
1200
+ );
1201
+
1202
+ CREATE TABLE IF NOT EXISTS "task_estimate_profiles" (
1203
+ "task_signature" text,
1204
+ "execution_profile_id" text DEFAULT 'standard-code-model',
1205
+ "sample_count" integer DEFAULT 0 NOT NULL,
1206
+ "completed_sample_count" integer DEFAULT 0 NOT NULL,
1207
+ "interrupted_sample_count" integer DEFAULT 0 NOT NULL,
1208
+ "input_tokens_p50" integer,
1209
+ "input_tokens_p90" integer,
1210
+ "output_tokens_p50" integer,
1211
+ "output_tokens_p90" integer,
1212
+ "quota_minutes_p50" real,
1213
+ "quota_minutes_p90" real,
1214
+ "files_changed_p50" real,
1215
+ "files_changed_p90" real,
1216
+ "credits_p50" real,
1217
+ "credits_p90" real,
1218
+ "credits_variance" real,
1219
+ "confidence_score" real,
1220
+ "outlier_count" integer DEFAULT 0 NOT NULL,
1221
+ "partial_credits" real,
1222
+ "first_sample_at" text,
1223
+ "last_sample_at" text,
1224
+ "updated_at" text NOT NULL,
1225
+ CONSTRAINT "task_estimate_profiles_task_signature_execution_profile_id_pk" PRIMARY KEY("task_signature","execution_profile_id")
1226
+ );
1227
+
1228
+ CREATE TABLE IF NOT EXISTS "task_estimates" (
1229
+ "id" text PRIMARY KEY NOT NULL,
1230
+ "task_id" text,
1231
+ "work_day_id" text,
1232
+ "project_id" text NOT NULL,
1233
+ "estimate_phase" text NOT NULL,
1234
+ "task_signature" text NOT NULL,
1235
+ "confidence" text NOT NULL,
1236
+ "estimated_credits_p50" real NOT NULL,
1237
+ "estimated_credits_p90" real NOT NULL,
1238
+ "reserved_credits" real NOT NULL,
1239
+ "estimated_input_tokens_p50" integer,
1240
+ "estimated_input_tokens_p90" integer,
1241
+ "estimated_output_tokens_p50" integer,
1242
+ "estimated_output_tokens_p90" integer,
1243
+ "estimated_quota_minutes_p50" real,
1244
+ "estimated_quota_minutes_p90" real,
1245
+ "features_json" text DEFAULT '{}' NOT NULL,
1246
+ "created_at" text NOT NULL,
1247
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL
1248
+ );
1249
+
1250
+ CREATE TABLE IF NOT EXISTS "task_events" (
1251
+ "id" text PRIMARY KEY NOT NULL,
1252
+ "task_id" text NOT NULL,
1253
+ "seq" integer NOT NULL,
1254
+ "kind" text NOT NULL,
1255
+ "data_json" text NOT NULL,
1256
+ "created_at" text NOT NULL
1257
+ );
1258
+
1259
+ CREATE TABLE IF NOT EXISTS "task_outputs" (
1260
+ "id" text PRIMARY KEY NOT NULL,
1261
+ "task_id" text NOT NULL,
1262
+ "output_json" text NOT NULL,
1263
+ "output_ref" text,
1264
+ "created_at" text NOT NULL
1265
+ );
1266
+
1267
+ CREATE TABLE IF NOT EXISTS "task_usage_actuals" (
1268
+ "id" text PRIMARY KEY NOT NULL,
1269
+ "task_id" text,
1270
+ "work_day_id" text,
1271
+ "project_id" text NOT NULL,
1272
+ "task_signature" text NOT NULL,
1273
+ "capacity_provider_id" text,
1274
+ "execution_provider_id" text,
1275
+ "lane_id" text,
1276
+ "business_model" text NOT NULL,
1277
+ "model_name" text,
1278
+ "input_tokens" integer,
1279
+ "output_tokens" integer,
1280
+ "cached_input_tokens" integer,
1281
+ "quota_minutes" real,
1282
+ "wall_minutes" real,
1283
+ "files_opened" integer,
1284
+ "files_changed" integer,
1285
+ "diff_lines_added" integer,
1286
+ "diff_lines_removed" integer,
1287
+ "test_runs" integer,
1288
+ "retry_count" integer,
1289
+ "actual_credits" real NOT NULL,
1290
+ "actual_usd" real,
1291
+ "credit_formula_version" text DEFAULT 'treeseed.actual-credits.v1' NOT NULL,
1292
+ "actual_credit_source" text DEFAULT 'central_calculator' NOT NULL,
1293
+ "native_usage_json" text DEFAULT '{}' NOT NULL,
1294
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1295
+ "created_at" text NOT NULL,
1296
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL
1297
+ );
1298
+
1299
+ CREATE TABLE IF NOT EXISTS "tasks" (
1300
+ "id" text PRIMARY KEY NOT NULL,
1301
+ "work_day_id" text NOT NULL,
1302
+ "agent_id" text NOT NULL,
1303
+ "type" text NOT NULL,
1304
+ "state" text NOT NULL,
1305
+ "priority" integer DEFAULT 0 NOT NULL,
1306
+ "idempotency_key" text NOT NULL,
1307
+ "payload_json" text NOT NULL,
1308
+ "payload_hash" text,
1309
+ "attempt_count" integer DEFAULT 0 NOT NULL,
1310
+ "max_attempts" integer DEFAULT 3 NOT NULL,
1311
+ "claimed_by" text,
1312
+ "lease_expires_at" text,
1313
+ "available_at" text NOT NULL,
1314
+ "last_error_code" text,
1315
+ "last_error_message" text,
1316
+ "graph_version" text,
1317
+ "parent_task_id" text,
1318
+ "created_at" text NOT NULL,
1319
+ "started_at" text,
1320
+ "completed_at" text,
1321
+ "updated_at" text NOT NULL,
1322
+ CONSTRAINT "tasks_idempotency_key_unique" UNIQUE("idempotency_key")
1323
+ );
1324
+
1325
+ CREATE TABLE IF NOT EXISTS "team_api_keys" (
1326
+ "id" text PRIMARY KEY NOT NULL,
1327
+ "team_id" text NOT NULL,
1328
+ "name" text NOT NULL,
1329
+ "key_prefix" text NOT NULL,
1330
+ "key_hash" text NOT NULL,
1331
+ "permissions_json" text NOT NULL,
1332
+ "expires_at" text,
1333
+ "last_used_at" text,
1334
+ "revoked_at" text,
1335
+ "created_at" text NOT NULL,
1336
+ "updated_at" text NOT NULL
1337
+ );
1338
+
1339
+ CREATE TABLE IF NOT EXISTS "team_inbox_items" (
1340
+ "id" text PRIMARY KEY NOT NULL,
1341
+ "team_id" text NOT NULL,
1342
+ "project_id" text,
1343
+ "kind" text NOT NULL,
1344
+ "state" text NOT NULL,
1345
+ "title" text NOT NULL,
1346
+ "summary" text,
1347
+ "href" text,
1348
+ "item_key" text,
1349
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1350
+ "created_at" text NOT NULL,
1351
+ "updated_at" text NOT NULL
1352
+ );
1353
+
1354
+ CREATE TABLE IF NOT EXISTS "team_invites" (
1355
+ "id" text PRIMARY KEY NOT NULL,
1356
+ "team_id" text NOT NULL,
1357
+ "email" text NOT NULL,
1358
+ "role_key" text NOT NULL,
1359
+ "token_prefix" text NOT NULL,
1360
+ "token_hash" text NOT NULL,
1361
+ "status" text DEFAULT 'pending' NOT NULL,
1362
+ "invited_by_user_id" text,
1363
+ "accepted_by_user_id" text,
1364
+ "accepted_at" text,
1365
+ "expires_at" text NOT NULL,
1366
+ "created_at" text NOT NULL,
1367
+ "updated_at" text NOT NULL
1368
+ );
1369
+
1370
+ CREATE TABLE IF NOT EXISTS "team_memberships" (
1371
+ "id" text PRIMARY KEY NOT NULL,
1372
+ "team_id" text NOT NULL,
1373
+ "user_id" text NOT NULL,
1374
+ "status" text DEFAULT 'active' NOT NULL,
1375
+ "created_at" text NOT NULL,
1376
+ "updated_at" text NOT NULL
1377
+ );
1378
+
1379
+ CREATE TABLE IF NOT EXISTS "team_role_bindings" (
1380
+ "id" text PRIMARY KEY NOT NULL,
1381
+ "team_membership_id" text NOT NULL,
1382
+ "role_id" text NOT NULL,
1383
+ "created_at" text NOT NULL
1384
+ );
1385
+
1386
+ CREATE TABLE IF NOT EXISTS "team_storage_locators" (
1387
+ "id" text PRIMARY KEY NOT NULL,
1388
+ "team_id" text NOT NULL,
1389
+ "bucket_name" text NOT NULL,
1390
+ "manifest_key_template" text NOT NULL,
1391
+ "preview_root_template" text NOT NULL,
1392
+ "public_base_url" text,
1393
+ "metadata_json" text,
1394
+ "created_at" text NOT NULL,
1395
+ "updated_at" text NOT NULL,
1396
+ CONSTRAINT "team_storage_locators_team_id_unique" UNIQUE("team_id")
1397
+ );
1398
+
1399
+ CREATE TABLE IF NOT EXISTS "team_web_hosts" (
1400
+ "id" text PRIMARY KEY NOT NULL,
1401
+ "team_id" text NOT NULL,
1402
+ "provider" text NOT NULL,
1403
+ "ownership" text NOT NULL,
1404
+ "name" text NOT NULL,
1405
+ "account_label" text,
1406
+ "allowed_environments_json" text DEFAULT '[]' NOT NULL,
1407
+ "status" text DEFAULT 'active' NOT NULL,
1408
+ "encrypted_payload_json" text,
1409
+ "metadata_json" text,
1410
+ "created_by_id" text,
1411
+ "updated_by_id" text,
1412
+ "created_at" text NOT NULL,
1413
+ "updated_at" text NOT NULL
1414
+ );
1415
+
1416
+ CREATE TABLE IF NOT EXISTS "teams" (
1417
+ "id" text PRIMARY KEY NOT NULL,
1418
+ "slug" text NOT NULL,
1419
+ "name" text NOT NULL,
1420
+ "metadata_json" text,
1421
+ "created_at" text NOT NULL,
1422
+ "updated_at" text NOT NULL,
1423
+ "display_name" text,
1424
+ "logo_url" text,
1425
+ "profile_summary" text,
1426
+ CONSTRAINT "teams_slug_unique" UNIQUE("slug")
1427
+ );
1428
+
1429
+ CREATE TABLE IF NOT EXISTS "user_email_addresses" (
1430
+ "id" text PRIMARY KEY NOT NULL,
1431
+ "user_id" text NOT NULL,
1432
+ "email" text NOT NULL,
1433
+ "normalized_email" text NOT NULL,
1434
+ "status" text DEFAULT 'pending' NOT NULL,
1435
+ "is_primary" integer DEFAULT 0 NOT NULL,
1436
+ "verification_requested_at" text,
1437
+ "verified_at" text,
1438
+ "created_at" text NOT NULL,
1439
+ "updated_at" text NOT NULL,
1440
+ CONSTRAINT "user_email_addresses_normalized_email_unique" UNIQUE("normalized_email")
1441
+ );
1442
+
1443
+ CREATE TABLE IF NOT EXISTS "user_identities" (
1444
+ "id" text PRIMARY KEY NOT NULL,
1445
+ "user_id" text NOT NULL,
1446
+ "provider" text NOT NULL,
1447
+ "provider_subject" text NOT NULL,
1448
+ "email" text,
1449
+ "email_verified" integer DEFAULT 0 NOT NULL,
1450
+ "profile_json" text,
1451
+ "created_at" text NOT NULL,
1452
+ "updated_at" text NOT NULL
1453
+ );
1454
+
1455
+ CREATE TABLE IF NOT EXISTS "user_preferences" (
1456
+ "user_id" text PRIMARY KEY NOT NULL,
1457
+ "color_scheme" text DEFAULT 'fern' NOT NULL,
1458
+ "theme_mode" text DEFAULT 'system' NOT NULL,
1459
+ "created_at" text NOT NULL,
1460
+ "updated_at" text NOT NULL
1461
+ );
1462
+
1463
+ CREATE TABLE IF NOT EXISTS "user_role_bindings" (
1464
+ "id" text PRIMARY KEY NOT NULL,
1465
+ "user_id" text NOT NULL,
1466
+ "role_id" text NOT NULL,
1467
+ "created_at" text NOT NULL
1468
+ );
1469
+
1470
+ CREATE TABLE IF NOT EXISTS "users" (
1471
+ "id" text PRIMARY KEY NOT NULL,
1472
+ "email" text,
1473
+ "display_name" text,
1474
+ "status" text DEFAULT 'active' NOT NULL,
1475
+ "metadata_json" text,
1476
+ "created_at" text NOT NULL,
1477
+ "updated_at" text NOT NULL,
1478
+ "username" text
1479
+ );
1480
+
1481
+ CREATE TABLE IF NOT EXISTS "web_sessions" (
1482
+ "id" text PRIMARY KEY NOT NULL,
1483
+ "user_id" text NOT NULL,
1484
+ "identity_id" text,
1485
+ "better_auth_session_id" text,
1486
+ "provider" text NOT NULL,
1487
+ "provider_subject" text NOT NULL,
1488
+ "email" text,
1489
+ "display_name" text,
1490
+ "principal_json" text NOT NULL,
1491
+ "csrf_token" text NOT NULL,
1492
+ "ip_address" text,
1493
+ "user_agent" text,
1494
+ "authenticated_at" text NOT NULL,
1495
+ "last_seen_at" text,
1496
+ "expires_at" text NOT NULL,
1497
+ "revoked_at" text,
1498
+ "created_at" text NOT NULL,
1499
+ "updated_at" text NOT NULL
1500
+ );
1501
+
1502
+ CREATE TABLE IF NOT EXISTS "work_days" (
1503
+ "id" text PRIMARY KEY NOT NULL,
1504
+ "project_id" text NOT NULL,
1505
+ "state" text NOT NULL,
1506
+ "capacity_budget" integer DEFAULT 0 NOT NULL,
1507
+ "capacity_used" integer DEFAULT 0 NOT NULL,
1508
+ "graph_version" text,
1509
+ "summary_json" text,
1510
+ "started_at" text NOT NULL,
1511
+ "ended_at" text,
1512
+ "created_at" text NOT NULL,
1513
+ "updated_at" text NOT NULL
1514
+ );
1515
+
1516
+ CREATE TABLE IF NOT EXISTS "work_policies" (
1517
+ "project_id" text,
1518
+ "environment" text,
1519
+ "schedule_json" text NOT NULL,
1520
+ "daily_task_credit_budget" integer DEFAULT 0 NOT NULL,
1521
+ "max_queued_tasks" integer DEFAULT 0 NOT NULL,
1522
+ "max_queued_credits" integer DEFAULT 0 NOT NULL,
1523
+ "autoscale_json" text NOT NULL,
1524
+ "credit_weights_json" text NOT NULL,
1525
+ "metadata_json" text NOT NULL,
1526
+ "created_at" text NOT NULL,
1527
+ "updated_at" text NOT NULL,
1528
+ "enabled" integer DEFAULT 1 NOT NULL,
1529
+ "start_cron" text DEFAULT '0 9 * * 1-5' NOT NULL,
1530
+ "duration_minutes" integer DEFAULT 480 NOT NULL,
1531
+ "max_runners" integer DEFAULT 1 NOT NULL,
1532
+ "max_workers_per_runner" integer DEFAULT 4 NOT NULL,
1533
+ "daily_credit_budget" integer DEFAULT 0 NOT NULL,
1534
+ "closeout_grace_minutes" integer DEFAULT 15 NOT NULL,
1535
+ CONSTRAINT "work_policies_project_id_environment_pk" PRIMARY KEY("project_id","environment")
1536
+ );
1537
+
1538
+ CREATE TABLE IF NOT EXISTS "workday_manager_leases" (
1539
+ "id" text PRIMARY KEY NOT NULL,
1540
+ "project_id" text NOT NULL,
1541
+ "environment" text NOT NULL,
1542
+ "work_day_id" text,
1543
+ "manager_id" text NOT NULL,
1544
+ "state" text DEFAULT 'active' NOT NULL,
1545
+ "heartbeat_at" text NOT NULL,
1546
+ "expires_at" text NOT NULL,
1547
+ "metadata_json" text NOT NULL,
1548
+ "created_at" text NOT NULL,
1549
+ "updated_at" text NOT NULL
1550
+ );
1551
+
1552
+ CREATE TABLE IF NOT EXISTS "workday_requests" (
1553
+ "id" text PRIMARY KEY NOT NULL,
1554
+ "project_id" text NOT NULL,
1555
+ "environment" text NOT NULL,
1556
+ "type" text NOT NULL,
1557
+ "state" text DEFAULT 'pending' NOT NULL,
1558
+ "work_day_id" text,
1559
+ "requested_by" text,
1560
+ "reason" text,
1561
+ "payload_json" text NOT NULL,
1562
+ "metadata_json" text NOT NULL,
1563
+ "created_at" text NOT NULL,
1564
+ "updated_at" text NOT NULL
1565
+ );
1566
+
1567
+ CREATE TABLE IF NOT EXISTS "worker_runners" (
1568
+ "id" text PRIMARY KEY NOT NULL,
1569
+ "project_id" text NOT NULL,
1570
+ "environment" text NOT NULL,
1571
+ "runner_id" text NOT NULL,
1572
+ "runner_service_name" text NOT NULL,
1573
+ "volume_identity" text NOT NULL,
1574
+ "state" text DEFAULT 'active' NOT NULL,
1575
+ "max_local_workers" integer DEFAULT 4 NOT NULL,
1576
+ "active_local_workers" integer DEFAULT 0 NOT NULL,
1577
+ "available_capacity" integer DEFAULT 4 NOT NULL,
1578
+ "last_heartbeat_at" text,
1579
+ "claimed_repository_ids_json" text NOT NULL,
1580
+ "metadata_json" text NOT NULL,
1581
+ "created_at" text NOT NULL,
1582
+ "updated_at" text NOT NULL
1583
+ );
1584
+
1585
+ -- Treeseed Market schema adoption columns
1586
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "id" integer;
1587
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "type" text;
1588
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "payload_json" text;
1589
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "created_at" text;
1590
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "id" text;
1591
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "pool_id" text;
1592
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "project_id" text;
1593
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "runner_id" text;
1594
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "manager_id" text;
1595
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "service_name" text;
1596
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
1597
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
1598
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer;
1599
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer;
1600
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1601
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "created_at" text;
1602
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1603
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
1604
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "pool_id" text;
1605
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
1606
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
1607
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
1608
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer DEFAULT 0;
1609
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer DEFAULT 0;
1610
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1611
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
1612
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1613
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
1614
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1615
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "id" text;
1616
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "project_id" text;
1617
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "team_id" text;
1618
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "environment" text;
1619
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "name" text;
1620
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "registration_identity" text;
1621
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "service_base_url" text;
1622
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
1623
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "min_workers" integer DEFAULT 0;
1624
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "max_workers" integer DEFAULT 1;
1625
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "target_queue_depth" integer DEFAULT 1;
1626
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "cooldown_seconds" integer DEFAULT 60;
1627
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1628
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "created_at" text;
1629
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "updated_at" text;
1630
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "run_id" text;
1631
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "agent_slug" text;
1632
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "status" text;
1633
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
1634
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "id" text;
1635
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "user_id" text;
1636
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "kind" text;
1637
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "name" text;
1638
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "token_prefix" text;
1639
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "token_hash" text;
1640
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "scopes_json" text;
1641
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "expires_at" text;
1642
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "last_used_at" text;
1643
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1644
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1645
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "created_at" text;
1646
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "updated_at" text;
1647
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "id" text;
1648
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "team_id" text;
1649
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "project_id" text;
1650
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1651
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "task_id" text;
1652
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "kind" text;
1653
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'pending';
1654
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "severity" text DEFAULT 'medium';
1655
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "requested_by_type" text DEFAULT 'worker';
1656
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
1657
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "title" text;
1658
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "summary" text;
1659
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "options_json" text DEFAULT '[]';
1660
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "recommendation_json" text DEFAULT '{}';
1661
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "policy_snapshot_json" text DEFAULT '{}';
1662
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "expires_at" text;
1663
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_by_type" text;
1664
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_by_id" text;
1665
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_at" text;
1666
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decision_json" text;
1667
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1668
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "created_at" text;
1669
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "updated_at" text;
1670
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "id" text;
1671
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "actor_type" text;
1672
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "actor_id" text;
1673
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "event_type" text;
1674
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "target_type" text;
1675
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "target_id" text;
1676
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "data_json" text;
1677
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "created_at" text;
1678
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "id" text;
1679
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "user_id" text;
1680
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "session_type" text;
1681
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "refresh_token_hash" text;
1682
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "scopes_json" text;
1683
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
1684
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1685
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "data_json" text;
1686
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
1687
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1688
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "id" text;
1689
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accountId" text;
1690
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "providerId" text;
1691
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "userId" text;
1692
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accessToken" text;
1693
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "refreshToken" text;
1694
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "idToken" text;
1695
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accessTokenExpiresAt" integer;
1696
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "refreshTokenExpiresAt" integer;
1697
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "scope" text;
1698
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "password" text;
1699
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1700
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1701
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "id" text;
1702
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "expiresAt" integer;
1703
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "token" text;
1704
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1705
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1706
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "ipAddress" text;
1707
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "userAgent" text;
1708
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "userId" text;
1709
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "id" text;
1710
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "name" text;
1711
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "email" text;
1712
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "emailVerified" integer DEFAULT 0;
1713
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "image" text;
1714
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1715
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1716
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "username" text;
1717
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "firstName" text;
1718
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "lastName" text;
1719
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "id" text;
1720
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "identifier" text;
1721
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "value" text;
1722
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "expiresAt" integer;
1723
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1724
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1725
+ ALTER TABLE "better_auth_verification" ALTER COLUMN "expiresAt" TYPE bigint;
1726
+ ALTER TABLE "better_auth_verification" ALTER COLUMN "createdAt" TYPE bigint;
1727
+ ALTER TABLE "better_auth_verification" ALTER COLUMN "updatedAt" TYPE bigint;
1728
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "id" text;
1729
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1730
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "lane_id" text;
1731
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "grant_scope" text DEFAULT 'team';
1732
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "team_id" text;
1733
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "project_id" text;
1734
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "environment" text;
1735
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
1736
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "daily_credit_limit" real;
1737
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "weekly_credit_limit" real;
1738
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "monthly_credit_limit" real;
1739
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "daily_usd_limit" real;
1740
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "weekly_quota_minutes" real;
1741
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "monthly_provider_units" real;
1742
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "priority_weight" real DEFAULT 1;
1743
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "overflow_policy" text DEFAULT 'soft_grant';
1744
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1745
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "created_at" text;
1746
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "updated_at" text;
1747
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "id" text;
1748
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1749
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "lane_id" text;
1750
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "reservation_id" text;
1751
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "team_id" text;
1752
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "project_id" text;
1753
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1754
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "task_id" text;
1755
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "phase" text;
1756
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "credits" real;
1757
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "provider_units" real;
1758
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "usd" real;
1759
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "source" text;
1760
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1761
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "created_at" text;
1762
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "id" text;
1763
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1764
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "team_id" text;
1765
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "name" text;
1766
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "key_prefix" text;
1767
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "key_hash" text;
1768
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "scopes_json" text DEFAULT '[]';
1769
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
1770
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "last_used_at" text;
1771
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "rotated_from_key_id" text;
1772
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "expires_at" text;
1773
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1774
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "created_by_id" text;
1775
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "created_at" text;
1776
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "updated_at" text;
1777
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "id" text;
1778
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "team_id" text;
1779
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1780
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "launch_mode" text;
1781
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "host_kind" text;
1782
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "host_id" text;
1783
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "status" text;
1784
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "image_ref" text;
1785
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "service_refs_json" text DEFAULT '{}';
1786
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "env_refs_json" text DEFAULT '{}';
1787
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "result_json" text DEFAULT '{}';
1788
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "error_json" text;
1789
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "created_by_id" text;
1790
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "created_at" text;
1791
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "updated_at" text;
1792
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "completed_at" text;
1793
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "id" text;
1794
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1795
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "host_id" text;
1796
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "role" text;
1797
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "required" integer DEFAULT 1;
1798
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1799
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
1800
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
1801
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "id" text;
1802
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1803
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "name" text;
1804
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "business_model" text DEFAULT 'custom';
1805
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "model_family" text;
1806
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "model_class" text;
1807
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "region_policy" text;
1808
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "unit" text DEFAULT 'treeseed_credit';
1809
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "scarcity_level" text DEFAULT 'medium';
1810
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "hard_limits_json" text DEFAULT '{}';
1811
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "routing_policy_json" text DEFAULT '{}';
1812
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1813
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "created_at" text;
1814
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "updated_at" text;
1815
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "id" text;
1816
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1817
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "team_id" text;
1818
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "runtime_version" text;
1819
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "market_id" text;
1820
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "capabilities_json" text DEFAULT '[]';
1821
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "budgets_json" text DEFAULT '{}';
1822
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "health_json" text DEFAULT '{}';
1823
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'online';
1824
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "registered_at" text;
1825
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "last_seen_at" text;
1826
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "disconnected_at" text;
1827
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "created_at" text;
1828
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1829
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "id" text;
1830
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "team_id" text;
1831
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "owner_team_id" text;
1832
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "name" text;
1833
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "kind" text;
1834
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
1835
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "provider" text;
1836
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "billing_scope" text DEFAULT 'team';
1837
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "monthly_credit_budget" real DEFAULT 0;
1838
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "daily_credit_budget" real DEFAULT 0;
1839
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "credit_budget_mode" text DEFAULT 'derived';
1840
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workdays" integer DEFAULT 1;
1841
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workers" integer DEFAULT 1;
1842
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "capacity_model_json" text DEFAULT '{}';
1843
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1844
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "created_at" text;
1845
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "updated_at" text;
1846
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "id" text;
1847
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1848
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1849
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "lane_id" text;
1850
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "team_id" text;
1851
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "project_id" text;
1852
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1853
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "task_id" text;
1854
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'reserved';
1855
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_credits" real;
1856
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_credits" real DEFAULT 0;
1857
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "native_unit" text;
1858
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_native_amount" real;
1859
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_native_amount" real;
1860
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_provider_units" real;
1861
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_provider_units" real;
1862
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_usd" real;
1863
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_usd" real;
1864
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "expires_at" text;
1865
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1866
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "created_at" text;
1867
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1868
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "id" text;
1869
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "task_id" text;
1870
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1871
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
1872
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_provider_id" text;
1873
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_lane_id" text;
1874
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_model" text;
1875
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "decision" text DEFAULT 'selected';
1876
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
1877
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "candidate_json" text DEFAULT '[]';
1878
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "score_json" text DEFAULT '{}';
1879
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1880
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
1881
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "id" text;
1882
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "item_id" text;
1883
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "team_id" text;
1884
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "kind" text;
1885
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "version" text;
1886
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "content_key" text;
1887
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "manifest_key" text;
1888
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1889
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "published_at" text;
1890
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "created_at" text;
1891
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1892
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "id" text;
1893
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "item_id" text;
1894
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "subject_type" text;
1895
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "subject_id" text;
1896
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "role" text;
1897
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1898
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "created_at" text;
1899
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "updated_at" text;
1900
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "id" text;
1901
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "team_id" text;
1902
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "kind" text;
1903
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "slug" text;
1904
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "title" text;
1905
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "summary" text;
1906
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "visibility" text;
1907
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "listing_enabled" integer DEFAULT 0;
1908
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "offer_mode" text;
1909
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "manifest_key" text;
1910
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "artifact_key" text;
1911
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "search_text" text;
1912
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1913
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "created_at" text;
1914
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "updated_at" text;
1915
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "id" integer;
1916
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "email" text;
1917
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "message" text;
1918
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "created_at" text;
1919
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "id" text;
1920
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "task_signature" text;
1921
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
1922
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "execution_provider_kind" text;
1923
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_unit" text;
1924
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "sample_count" integer DEFAULT 0;
1925
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "completed_sample_count" integer DEFAULT 0;
1926
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "interrupted_sample_count" integer DEFAULT 0;
1927
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_units_per_credit_p50" real;
1928
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_units_per_credit_p90" real;
1929
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "credits_per_native_unit_p50" real;
1930
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "credits_per_native_unit_p90" real;
1931
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "actual_credits_p50" real;
1932
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "actual_credits_p90" real;
1933
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'low';
1934
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "formula_version" text;
1935
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1936
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "created_at" text;
1937
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "updated_at" text;
1938
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "agent_slug" text;
1939
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "cursor_key" text;
1940
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "status" text;
1941
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
1942
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "updated_at" text;
1943
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "payload_json" text;
1944
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "meta_json" text;
1945
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "id" text;
1946
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "device_code" text;
1947
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "user_code" text;
1948
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "requested_scopes_json" text;
1949
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "expires_at" text;
1950
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "interval_seconds" integer;
1951
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "status" text;
1952
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "user_id" text;
1953
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "created_at" text;
1954
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "updated_at" text;
1955
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "id" text;
1956
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "team_id" text;
1957
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "project_id" text;
1958
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "tier" text;
1959
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "status" text;
1960
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1961
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "created_at" text;
1962
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "updated_at" text;
1963
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "id" text;
1964
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1965
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "scope" text;
1966
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "native_unit" text;
1967
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "limit_amount" real;
1968
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reserve_buffer_percent" real DEFAULT 0;
1969
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reset_cadence" text;
1970
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reset_at" text;
1971
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'estimated';
1972
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "source" text DEFAULT 'configured';
1973
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1974
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "created_at" text;
1975
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "updated_at" text;
1976
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "id" text;
1977
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1978
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "observed_at" text;
1979
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "health" text DEFAULT 'unknown';
1980
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "active_workers" integer;
1981
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "queued_tasks" integer;
1982
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "throttle_state" text;
1983
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "native_remaining_json" text DEFAULT '{}';
1984
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "reset_at" text;
1985
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'estimated';
1986
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1987
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "created_at" text;
1988
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "id" text;
1989
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "team_id" text;
1990
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1991
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "name" text;
1992
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "kind" text;
1993
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
1994
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "native_unit" text;
1995
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "quota_visibility" text DEFAULT 'opaque';
1996
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workers" integer DEFAULT 1;
1997
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "reset_cadence" text;
1998
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "config_json" text DEFAULT '{}';
1999
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2000
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "created_at" text;
2001
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "updated_at" text;
2002
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "id" text;
2003
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2004
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "corpus_hash" text;
2005
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "graph_version" text;
2006
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "query_json" text;
2007
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "seed_ids_json" text;
2008
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "selected_node_ids_json" text;
2009
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "stats_json" text;
2010
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "snapshot_ref" text;
2011
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
2012
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "id" text;
2013
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "hub_id" text;
2014
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "team_id" text;
2015
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "content_repository_id" text;
2016
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "production_source" text;
2017
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "overlay_policy" text;
2018
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_bucket_name" text;
2019
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_manifest_key" text;
2020
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_public_base_url" text;
2021
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "latest_publish_id" text;
2022
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "latest_content_version" text;
2023
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2024
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "created_at" text;
2025
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "updated_at" text;
2026
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "id" text;
2027
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "launch_id" text;
2028
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2029
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "phase" text;
2030
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "status" text;
2031
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "title" text;
2032
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "summary" text;
2033
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "started_at" text;
2034
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "finished_at" text;
2035
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "error_json" text;
2036
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "data_json" text DEFAULT '{}';
2037
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2038
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "id" text;
2039
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "hub_id" text;
2040
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "team_id" text;
2041
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "job_id" text;
2042
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "intent_json" text;
2043
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "plan_json" text DEFAULT '{}';
2044
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "state" text;
2045
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "current_phase" text;
2046
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "last_successful_phase" text;
2047
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "result_json" text;
2048
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "error_json" text;
2049
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "created_at" text;
2050
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "updated_at" text;
2051
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "completed_at" text;
2052
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "id" text;
2053
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "hub_id" text;
2054
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "team_id" text;
2055
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "role" text;
2056
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "repository_host_id" text;
2057
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "provider" text;
2058
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "owner" text;
2059
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "name" text;
2060
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "url" text;
2061
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "default_branch" text;
2062
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "current_branch" text;
2063
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'queued';
2064
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "access_policy_json" text DEFAULT '{}';
2065
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "release_policy_json" text DEFAULT '{}';
2066
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "publish_policy_json" text DEFAULT '{}';
2067
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "submodule_path" text;
2068
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2069
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "created_at" text;
2070
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "updated_at" text;
2071
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "id" text;
2072
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "hub_id" text;
2073
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "team_id" text;
2074
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_repository_host_id" text;
2075
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_owner" text;
2076
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_name" text;
2077
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_url" text;
2078
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_branch" text;
2079
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "hub_mount_path" text;
2080
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "software_submodule_path" text;
2081
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "content_submodule_path" text;
2082
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "update_submodule_pointers_enabled" integer DEFAULT 0;
2083
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "access_policy_json" text DEFAULT '{}';
2084
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2085
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "created_at" text;
2086
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "updated_at" text;
2087
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "id" text;
2088
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "team_id" text;
2089
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "slug" text;
2090
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "name" text;
2091
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "summary" text;
2092
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "source_kind" text;
2093
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "source_ref" text;
2094
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "install_strategy" text;
2095
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "visibility" text;
2096
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2097
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "created_at" text;
2098
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2099
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "model" text;
2100
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "item_key" text;
2101
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "status" text;
2102
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2103
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2104
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "claimed_at" text;
2105
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2106
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "created_at" text;
2107
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "updated_at" text;
2108
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "payload_json" text;
2109
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "meta_json" text;
2110
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "user_id" text;
2111
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "email" text;
2112
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "username" text;
2113
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "password_hash" text;
2114
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2115
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "created_at" text;
2116
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "updated_at" text;
2117
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "id" text;
2118
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "user_id" text;
2119
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "token_hash" text;
2120
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "expires_at" text;
2121
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "used_at" text;
2122
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "created_at" text;
2123
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "id" text;
2124
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "runner_key" text;
2125
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "name" text;
2126
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "environment" text;
2127
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'online';
2128
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "version" text;
2129
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "capabilities_json" text DEFAULT '[]';
2130
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "active_job_count" integer DEFAULT 0;
2131
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "max_concurrent_jobs" integer DEFAULT 1;
2132
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
2133
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2134
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "created_at" text;
2135
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "updated_at" text;
2136
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "id" integer;
2137
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "message_type" text;
2138
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "status" text;
2139
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2140
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "related_model" text;
2141
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "related_id" text;
2142
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "priority" integer DEFAULT 0;
2143
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "available_at" text;
2144
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2145
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "claimed_at" text;
2146
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2147
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "attempts" integer DEFAULT 0;
2148
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "max_attempts" integer DEFAULT 3;
2149
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "created_at" text;
2150
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "updated_at" text;
2151
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "payload_json" text;
2152
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "meta_json" text;
2153
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "id" text;
2154
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_usage_actual_id" text;
2155
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_id" text;
2156
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2157
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "project_id" text;
2158
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_signature" text;
2159
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2160
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
2161
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
2162
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "native_unit" text;
2163
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "native_usage_json" text DEFAULT '{}';
2164
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "observed_at" text;
2165
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "source" text DEFAULT 'provider_report';
2166
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "formula_version" text DEFAULT 'treeseed.actual-credits.v1';
2167
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "actual_credits" real;
2168
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2169
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "created_at" text;
2170
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "id" text;
2171
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "key" text;
2172
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "resource" text;
2173
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "action" text;
2174
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "scope" text;
2175
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "description" text;
2176
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "created_at" text;
2177
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "id" text;
2178
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "operation_id" text;
2179
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2180
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "kind" text;
2181
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "data_json" text DEFAULT '{}';
2182
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2183
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "id" text;
2184
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "namespace" text;
2185
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "operation" text;
2186
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "status" text;
2187
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "target" text;
2188
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2189
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "input_json" text DEFAULT '{}';
2190
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "output_json" text;
2191
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "error_json" text;
2192
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "requested_by_type" text;
2193
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
2194
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "assigned_runner_id" text;
2195
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2196
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "created_at" text;
2197
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "updated_at" text;
2198
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "started_at" text;
2199
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "finished_at" text;
2200
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "cancelled_at" text;
2201
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "id" text;
2202
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "repository_key" text;
2203
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "runner_id" text;
2204
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "workspace_path" text;
2205
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "branch" text;
2206
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "commit_sha" text;
2207
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "claim_state" text DEFAULT 'active';
2208
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2209
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2210
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "created_at" text;
2211
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "updated_at" text;
2212
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "id" text;
2213
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "project_id" text;
2214
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "model" text;
2215
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "subject_id" text;
2216
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "priority" real DEFAULT 0;
2217
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "estimated_credits" real;
2218
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2219
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "created_at" text;
2220
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "updated_at" text;
2221
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "id" text;
2222
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "project_id" text;
2223
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2224
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "snapshot_json" text;
2225
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2226
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "generated_at" text;
2227
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "created_at" text;
2228
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "updated_at" text;
2229
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "id" text;
2230
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "project_id" text;
2231
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "label" text;
2232
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "namespace" text;
2233
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "operation" text;
2234
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "execution_class" text;
2235
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "allowed_targets_json" text;
2236
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "default_dispatch_mode" text;
2237
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "approval_policy_json" text DEFAULT '{}';
2238
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "resource_scope_json" text DEFAULT '{}';
2239
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2240
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "enabled" integer DEFAULT 1;
2241
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "created_at" text;
2242
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "updated_at" text;
2243
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "id" text;
2244
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "project_id" text;
2245
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "mode" text;
2246
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "project_api_base_url" text;
2247
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "execution_owner" text;
2248
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_registration_state" text DEFAULT 'pending';
2249
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_key_prefix" text;
2250
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_key_hash" text;
2251
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_registered_at" text;
2252
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_last_seen_at" text;
2253
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2254
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "created_at" text;
2255
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "updated_at" text;
2256
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "id" text;
2257
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "project_id" text;
2258
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "environment" text;
2259
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "deployment_kind" text;
2260
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "status" text;
2261
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "source_ref" text;
2262
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "release_tag" text;
2263
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "commit_sha" text;
2264
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "triggered_by_type" text;
2265
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "triggered_by_id" text;
2266
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2267
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "started_at" text;
2268
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "finished_at" text;
2269
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "created_at" text;
2270
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "updated_at" text;
2271
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "id" text;
2272
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "project_id" text;
2273
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "environment" text;
2274
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "deployment_profile" text;
2275
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "base_url" text;
2276
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "cloudflare_account_id" text;
2277
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "pages_project_name" text;
2278
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "worker_name" text;
2279
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "r2_bucket_name" text;
2280
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "d1_database_name" text;
2281
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "queue_name" text;
2282
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "railway_project_name" text;
2283
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2284
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "created_at" text;
2285
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "updated_at" text;
2286
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "id" text;
2287
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "project_id" text;
2288
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "hosting_kind" text;
2289
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "registration" text DEFAULT 'none';
2290
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "market_base_url" text;
2291
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_owner" text;
2292
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_name" text;
2293
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_url" text;
2294
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_workflow_path" text;
2295
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2296
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "created_at" text;
2297
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "updated_at" text;
2298
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "id" text;
2299
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "project_id" text;
2300
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "environment" text;
2301
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "provider" text;
2302
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "resource_kind" text;
2303
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "logical_name" text;
2304
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "locator" text;
2305
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2306
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "created_at" text;
2307
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "updated_at" text;
2308
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "project_id" text;
2309
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "team_id" text;
2310
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "summary_json" text;
2311
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "generated_at" text;
2312
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "created_at" text;
2313
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "updated_at" text;
2314
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "id" text;
2315
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "hub_id" text;
2316
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "team_id" text;
2317
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_kind" text;
2318
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_ref" text;
2319
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_version" text;
2320
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "plan_json" text DEFAULT '{}';
2321
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'planned';
2322
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "requires_decision" integer DEFAULT 0;
2323
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "decision_id" text;
2324
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "created_by" text;
2325
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "created_at" text;
2326
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "updated_at" text;
2327
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "id" text;
2328
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "project_id" text;
2329
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "environment" text;
2330
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2331
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "kind" text;
2332
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "state" text;
2333
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "started_at" text;
2334
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "ended_at" text;
2335
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "summary_json" text;
2336
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2337
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "created_at" text;
2338
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "updated_at" text;
2339
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "id" text;
2340
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "team_id" text;
2341
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "slug" text;
2342
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "name" text;
2343
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "description" text;
2344
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2345
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "created_at" text;
2346
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "updated_at" text;
2347
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "id" text;
2348
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "team_id" text;
2349
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "project_id" text;
2350
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "job_id" text;
2351
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "host_kind" text;
2352
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "host_id" text;
2353
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "purpose" text;
2354
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2355
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2356
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
2357
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "consumed_at" text;
2358
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2359
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
2360
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
2361
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2362
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "id" text;
2363
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "job_id" text;
2364
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2365
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "kind" text;
2366
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "data_json" text;
2367
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2368
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "id" text;
2369
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "project_id" text;
2370
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "namespace" text;
2371
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "operation" text;
2372
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "status" text;
2373
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "preferred_mode" text;
2374
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "selected_target" text;
2375
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "capability_json" text;
2376
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "input_json" text;
2377
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "output_json" text;
2378
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "error_json" text;
2379
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "requested_by_type" text;
2380
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
2381
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "assigned_runner_id" text;
2382
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2383
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "created_at" text;
2384
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2385
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "started_at" text;
2386
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "finished_at" text;
2387
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "cancelled_at" text;
2388
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "id" text;
2389
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2390
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "kind" text;
2391
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "body_json" text;
2392
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "rendered_ref" text;
2393
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "sent_at" text;
2394
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "created_at" text;
2395
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "id" text;
2396
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "project_id" text;
2397
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "repository_id" text;
2398
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "runner_id" text;
2399
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2400
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "volume_identity" text;
2401
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "last_seen_commit" text;
2402
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "last_task_at" text;
2403
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "claim_state" text DEFAULT 'active';
2404
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2405
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "created_at" text;
2406
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "updated_at" text;
2407
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "id" text;
2408
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "team_id" text;
2409
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "provider" text;
2410
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "ownership" text;
2411
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "name" text;
2412
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "account_label" text;
2413
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "organization_or_owner" text;
2414
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "default_visibility" text DEFAULT 'private';
2415
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "software_repository_name_template" text DEFAULT '{hub}-site';
2416
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "content_repository_name_template" text DEFAULT '{hub}-content';
2417
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "branch_policy_json" text DEFAULT '{}';
2418
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "workflow_policy_json" text DEFAULT '{}';
2419
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2420
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "allowed_project_kinds_json" text DEFAULT '["knowledge_hub"]';
2421
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2422
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2423
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2424
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "updated_by_id" text;
2425
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
2426
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
2427
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "role_id" text;
2428
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "permission_id" text;
2429
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "created_at" text;
2430
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "id" text;
2431
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "key" text;
2432
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "description" text;
2433
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "created_at" text;
2434
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
2435
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
2436
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
2437
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2438
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "runner_id" text;
2439
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2440
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "action" text;
2441
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
2442
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2443
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
2444
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "id" integer;
2445
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "record_type" text;
2446
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "payload_json" text;
2447
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "created_at" text;
2448
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "id" integer;
2449
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "record_type" text;
2450
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "record_key" text;
2451
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "lookup_key" text;
2452
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "secondary_key" text;
2453
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "status" text;
2454
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2455
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "created_at" text;
2456
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "updated_at" text;
2457
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "payload_json" text;
2458
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "meta_json" text;
2459
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
2460
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
2461
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
2462
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "pool_name" text;
2463
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2464
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
2465
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer DEFAULT 0;
2466
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer DEFAULT 0;
2467
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
2468
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2469
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
2470
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "id" text;
2471
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "seed_name" text;
2472
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "seed_version" integer;
2473
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "environments_json" text;
2474
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "mode" text;
2475
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "state" text;
2476
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "actor_type" text;
2477
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "actor_id" text;
2478
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "manifest_hash" text;
2479
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "plan_json" text;
2480
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "result_json" text;
2481
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "error_json" text;
2482
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
2483
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2484
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "completed_at" text;
2485
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "id" text;
2486
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "service_id" text;
2487
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "name" text;
2488
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "secret_hash" text;
2489
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "roles_json" text;
2490
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "permissions_json" text;
2491
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2492
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "created_at" text;
2493
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "updated_at" text;
2494
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "last_used_at" text;
2495
+ ALTER TABLE "subscribers" ADD COLUMN IF NOT EXISTS "email" text;
2496
+ ALTER TABLE "subscribers" ADD COLUMN IF NOT EXISTS "created_at" text;
2497
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "id" text;
2498
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "project_id" text;
2499
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2500
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "task_id" text;
2501
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "phase" text;
2502
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "credits" real;
2503
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2504
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "created_at" text;
2505
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "task_signature" text;
2506
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2507
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "sample_count" integer DEFAULT 0;
2508
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "completed_sample_count" integer DEFAULT 0;
2509
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "interrupted_sample_count" integer DEFAULT 0;
2510
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "input_tokens_p50" integer;
2511
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "input_tokens_p90" integer;
2512
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "output_tokens_p50" integer;
2513
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "output_tokens_p90" integer;
2514
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "quota_minutes_p50" real;
2515
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "quota_minutes_p90" real;
2516
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "files_changed_p50" real;
2517
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "files_changed_p90" real;
2518
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_p50" real;
2519
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_p90" real;
2520
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_variance" real;
2521
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "confidence_score" real;
2522
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "outlier_count" integer DEFAULT 0;
2523
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "partial_credits" real;
2524
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "first_sample_at" text;
2525
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "last_sample_at" text;
2526
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "updated_at" text;
2527
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "id" text;
2528
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "task_id" text;
2529
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2530
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "project_id" text;
2531
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimate_phase" text;
2532
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "task_signature" text;
2533
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "confidence" text;
2534
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_credits_p50" real;
2535
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_credits_p90" real;
2536
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "reserved_credits" real;
2537
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_input_tokens_p50" integer;
2538
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_input_tokens_p90" integer;
2539
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_output_tokens_p50" integer;
2540
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_output_tokens_p90" integer;
2541
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_quota_minutes_p50" real;
2542
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_quota_minutes_p90" real;
2543
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "features_json" text DEFAULT '{}';
2544
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "created_at" text;
2545
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2546
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "id" text;
2547
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "task_id" text;
2548
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2549
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "kind" text;
2550
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "data_json" text;
2551
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2552
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "id" text;
2553
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "task_id" text;
2554
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "output_json" text;
2555
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "output_ref" text;
2556
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "created_at" text;
2557
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "id" text;
2558
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "task_id" text;
2559
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2560
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "project_id" text;
2561
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "task_signature" text;
2562
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
2563
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
2564
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "lane_id" text;
2565
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "business_model" text;
2566
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "model_name" text;
2567
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "input_tokens" integer;
2568
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "output_tokens" integer;
2569
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "cached_input_tokens" integer;
2570
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "quota_minutes" real;
2571
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "wall_minutes" real;
2572
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "files_opened" integer;
2573
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "files_changed" integer;
2574
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "diff_lines_added" integer;
2575
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "diff_lines_removed" integer;
2576
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "test_runs" integer;
2577
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "retry_count" integer;
2578
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_credits" real;
2579
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_usd" real;
2580
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "credit_formula_version" text DEFAULT 'treeseed.actual-credits.v1';
2581
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_credit_source" text DEFAULT 'central_calculator';
2582
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "native_usage_json" text DEFAULT '{}';
2583
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2584
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "created_at" text;
2585
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2586
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "id" text;
2587
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2588
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "agent_id" text;
2589
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "type" text;
2590
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "state" text;
2591
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "priority" integer DEFAULT 0;
2592
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2593
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "payload_json" text;
2594
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "payload_hash" text;
2595
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "attempt_count" integer DEFAULT 0;
2596
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "max_attempts" integer DEFAULT 3;
2597
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2598
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2599
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "available_at" text;
2600
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "last_error_code" text;
2601
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "last_error_message" text;
2602
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "graph_version" text;
2603
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "parent_task_id" text;
2604
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "created_at" text;
2605
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "started_at" text;
2606
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "completed_at" text;
2607
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "updated_at" text;
2608
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "id" text;
2609
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "team_id" text;
2610
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "name" text;
2611
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "key_prefix" text;
2612
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "key_hash" text;
2613
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "permissions_json" text;
2614
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "expires_at" text;
2615
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "last_used_at" text;
2616
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2617
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "created_at" text;
2618
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "updated_at" text;
2619
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "id" text;
2620
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "team_id" text;
2621
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "project_id" text;
2622
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "kind" text;
2623
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "state" text;
2624
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "title" text;
2625
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "summary" text;
2626
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "href" text;
2627
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "item_key" text;
2628
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2629
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "created_at" text;
2630
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "updated_at" text;
2631
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "id" text;
2632
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "team_id" text;
2633
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "email" text;
2634
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "role_key" text;
2635
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "token_prefix" text;
2636
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "token_hash" text;
2637
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
2638
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "invited_by_user_id" text;
2639
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "accepted_by_user_id" text;
2640
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "accepted_at" text;
2641
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "expires_at" text;
2642
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "created_at" text;
2643
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "updated_at" text;
2644
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "id" text;
2645
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "team_id" text;
2646
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "user_id" text;
2647
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2648
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "created_at" text;
2649
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "updated_at" text;
2650
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "id" text;
2651
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "team_membership_id" text;
2652
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "role_id" text;
2653
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "created_at" text;
2654
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "id" text;
2655
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "team_id" text;
2656
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "bucket_name" text;
2657
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "manifest_key_template" text;
2658
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "preview_root_template" text;
2659
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "public_base_url" text;
2660
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2661
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "created_at" text;
2662
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "updated_at" text;
2663
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "id" text;
2664
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "team_id" text;
2665
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "provider" text;
2666
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "ownership" text;
2667
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "name" text;
2668
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "account_label" text;
2669
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "allowed_environments_json" text DEFAULT '[]';
2670
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2671
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2672
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2673
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2674
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "updated_by_id" text;
2675
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
2676
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
2677
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "id" text;
2678
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "slug" text;
2679
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "name" text;
2680
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2681
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "created_at" text;
2682
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "updated_at" text;
2683
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "display_name" text;
2684
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "logo_url" text;
2685
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "profile_summary" text;
2686
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "id" text;
2687
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "user_id" text;
2688
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "provider" text;
2689
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "provider_subject" text;
2690
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "email" text;
2691
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "email_verified" integer DEFAULT 0;
2692
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "profile_json" text;
2693
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "created_at" text;
2694
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "updated_at" text;
2695
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "user_id" text;
2696
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "color_scheme" text DEFAULT 'fern';
2697
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "theme_mode" text DEFAULT 'system';
2698
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "created_at" text;
2699
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "updated_at" text;
2700
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "id" text;
2701
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "user_id" text;
2702
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "role_id" text;
2703
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "created_at" text;
2704
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "id" text;
2705
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "email" text;
2706
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "display_name" text;
2707
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2708
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2709
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "created_at" text;
2710
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "updated_at" text;
2711
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "username" text;
2712
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "id" text;
2713
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "user_id" text;
2714
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "identity_id" text;
2715
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "better_auth_session_id" text;
2716
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "provider" text;
2717
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "provider_subject" text;
2718
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "email" text;
2719
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "display_name" text;
2720
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "principal_json" text;
2721
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "csrf_token" text;
2722
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "ip_address" text;
2723
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "user_agent" text;
2724
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "authenticated_at" text;
2725
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "last_seen_at" text;
2726
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
2727
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2728
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
2729
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
2730
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "id" text;
2731
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "project_id" text;
2732
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "state" text;
2733
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "capacity_budget" integer DEFAULT 0;
2734
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "capacity_used" integer DEFAULT 0;
2735
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "graph_version" text;
2736
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "summary_json" text;
2737
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "started_at" text;
2738
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "ended_at" text;
2739
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "created_at" text;
2740
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "updated_at" text;
2741
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "project_id" text;
2742
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "environment" text;
2743
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "schedule_json" text;
2744
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "daily_task_credit_budget" integer DEFAULT 0;
2745
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_queued_tasks" integer DEFAULT 0;
2746
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_queued_credits" integer DEFAULT 0;
2747
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "autoscale_json" text;
2748
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "credit_weights_json" text;
2749
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2750
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "created_at" text;
2751
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "updated_at" text;
2752
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "enabled" integer DEFAULT 1;
2753
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "start_cron" text DEFAULT '0 9 * * 1-5';
2754
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "duration_minutes" integer DEFAULT 480;
2755
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_runners" integer DEFAULT 1;
2756
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_workers_per_runner" integer DEFAULT 4;
2757
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "daily_credit_budget" integer DEFAULT 0;
2758
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "closeout_grace_minutes" integer DEFAULT 15;
2759
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "id" text;
2760
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "project_id" text;
2761
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "environment" text;
2762
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2763
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "manager_id" text;
2764
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
2765
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
2766
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "expires_at" text;
2767
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2768
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "created_at" text;
2769
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "updated_at" text;
2770
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "id" text;
2771
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "project_id" text;
2772
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "environment" text;
2773
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "type" text;
2774
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'pending';
2775
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2776
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "requested_by" text;
2777
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "reason" text;
2778
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "payload_json" text;
2779
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2780
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "created_at" text;
2781
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "updated_at" text;
2782
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "id" text;
2783
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "project_id" text;
2784
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "environment" text;
2785
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "runner_id" text;
2786
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2787
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "volume_identity" text;
2788
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
2789
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "max_local_workers" integer DEFAULT 4;
2790
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "active_local_workers" integer DEFAULT 0;
2791
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "available_capacity" integer DEFAULT 4;
2792
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "last_heartbeat_at" text;
2793
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "claimed_repository_ids_json" text;
2794
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2795
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "created_at" text;
2796
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "updated_at" text;
2797
+ -- End Treeseed Market schema adoption columns
2798
+
2799
+ -- Backfill verified account emails from existing active credential rows.
2800
+ INSERT INTO user_email_addresses (
2801
+ id, user_id, email, normalized_email, status, is_primary, verification_requested_at, verified_at, created_at, updated_at
2802
+ )
2803
+ SELECT 'email_' || md5(user_id || ':' || LOWER(email)), user_id, email, LOWER(email), 'verified', 1, created_at, COALESCE(updated_at, created_at), created_at, updated_at
2804
+ FROM market_auth_credentials
2805
+ WHERE email IS NOT NULL
2806
+ AND email != ''
2807
+ AND status = 'active'
2808
+ ON CONFLICT (normalized_email) DO NOTHING;
2809
+
2810
+ CREATE INDEX IF NOT EXISTS "idx_agent_pool_registrations_pool_heartbeat" ON "agent_pool_registrations" USING btree ("pool_id","heartbeat_at");
2811
+ CREATE INDEX IF NOT EXISTS "idx_agent_pool_scale_decisions_pool_created" ON "agent_pool_scale_decisions" USING btree ("pool_id","created_at");
2812
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_agent_pools_project_environment_name" ON "agent_pools" USING btree ("project_id","environment","name");
2813
+ CREATE INDEX IF NOT EXISTS "idx_api_tokens_user_id" ON "api_tokens" USING btree ("user_id");
2814
+ CREATE INDEX IF NOT EXISTS "idx_api_tokens_prefix" ON "api_tokens" USING btree ("token_prefix");
2815
+ CREATE INDEX IF NOT EXISTS "idx_approval_requests_team_state" ON "approval_requests" USING btree ("team_id","state","created_at");
2816
+ CREATE INDEX IF NOT EXISTS "idx_approval_requests_project_workday" ON "approval_requests" USING btree ("project_id","work_day_id","state","created_at");
2817
+ CREATE INDEX IF NOT EXISTS "idx_audit_events_target" ON "audit_events" USING btree ("target_type","target_id");
2818
+ CREATE INDEX IF NOT EXISTS "idx_auth_sessions_user_id" ON "auth_sessions" USING btree ("user_id");
2819
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_account_userId" ON "better_auth_account" USING btree ("userId");
2820
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_better_auth_account_provider_account" ON "better_auth_account" USING btree ("providerId","accountId");
2821
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_session_token" ON "better_auth_session" USING btree ("token");
2822
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_session_userId" ON "better_auth_session" USING btree ("userId");
2823
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_better_auth_user_username" ON "better_auth_user" USING btree ("username");
2824
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_verification_identifier" ON "better_auth_verification" USING btree ("identifier");
2825
+ CREATE INDEX IF NOT EXISTS "idx_capacity_grants_team_project" ON "capacity_grants" USING btree ("team_id","project_id","state");
2826
+ CREATE INDEX IF NOT EXISTS "idx_capacity_grants_provider_lane" ON "capacity_grants" USING btree ("capacity_provider_id","lane_id","state");
2827
+ CREATE INDEX IF NOT EXISTS "idx_capacity_ledger_project_workday_created" ON "capacity_ledger_entries" USING btree ("project_id","work_day_id","created_at");
2828
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_api_keys_provider_status" ON "capacity_provider_api_keys" USING btree ("capacity_provider_id","status","created_at");
2829
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_api_keys_prefix" ON "capacity_provider_api_keys" USING btree ("key_prefix");
2830
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_deployments_provider_created" ON "capacity_provider_deployments" USING btree ("capacity_provider_id","created_at");
2831
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_capacity_provider_hosts_unique" ON "capacity_provider_hosts" USING btree ("capacity_provider_id","host_id","role");
2832
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_lanes_provider" ON "capacity_provider_lanes" USING btree ("capacity_provider_id","business_model","scarcity_level");
2833
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_registrations_provider_seen" ON "capacity_provider_registrations" USING btree ("capacity_provider_id","last_seen_at");
2834
+ CREATE INDEX IF NOT EXISTS "idx_capacity_providers_team_status" ON "capacity_providers" USING btree ("team_id","status","provider");
2835
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_project_workday_state" ON "capacity_reservations" USING btree ("project_id","work_day_id","state","created_at");
2836
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_provider_state" ON "capacity_reservations" USING btree ("capacity_provider_id","lane_id","state");
2837
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_execution_provider_state" ON "capacity_reservations" USING btree ("execution_provider_id","state","created_at");
2838
+ CREATE INDEX IF NOT EXISTS "idx_capacity_routing_decisions_project_workday" ON "capacity_routing_decisions" USING btree ("project_id","work_day_id","created_at");
2839
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_catalog_artifact_versions_item_version" ON "catalog_artifact_versions" USING btree ("item_id","version");
2840
+ CREATE INDEX IF NOT EXISTS "idx_catalog_artifact_versions_team_kind" ON "catalog_artifact_versions" USING btree ("team_id","kind","published_at");
2841
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_catalog_item_collaborators_subject_role" ON "catalog_item_collaborators" USING btree ("item_id","subject_type","subject_id","role");
2842
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_catalog_items_kind_slug" ON "catalog_items" USING btree ("kind","slug");
2843
+ CREATE INDEX IF NOT EXISTS "idx_catalog_items_team_kind" ON "catalog_items" USING btree ("team_id","kind","updated_at");
2844
+ CREATE INDEX IF NOT EXISTS "idx_catalog_items_visibility_listing" ON "catalog_items" USING btree ("visibility","listing_enabled","updated_at");
2845
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_credit_conversion_profiles_profile_key" ON "credit_conversion_profiles" USING btree ("task_signature","execution_profile_id","execution_provider_kind","native_unit");
2846
+ CREATE INDEX IF NOT EXISTS "idx_credit_conversion_profiles_kind_unit" ON "credit_conversion_profiles" USING btree ("execution_provider_kind","native_unit","updated_at");
2847
+ CREATE INDEX IF NOT EXISTS "idx_cursor_state_updated" ON "cursor_state" USING btree ("updated_at");
2848
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_entitlements_project" ON "entitlements" USING btree ("project_id");
2849
+ CREATE INDEX IF NOT EXISTS "idx_execution_provider_native_limits_provider_scope" ON "execution_provider_native_limits" USING btree ("execution_provider_id","scope","native_unit");
2850
+ CREATE INDEX IF NOT EXISTS "idx_execution_provider_observations_provider_observed" ON "execution_provider_observations" USING btree ("execution_provider_id","observed_at");
2851
+ CREATE INDEX IF NOT EXISTS "idx_execution_providers_team_status" ON "execution_providers" USING btree ("team_id","status","kind");
2852
+ CREATE INDEX IF NOT EXISTS "idx_execution_providers_capacity_provider" ON "execution_providers" USING btree ("capacity_provider_id","status");
2853
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_hub_launch_events_launch_seq" ON "hub_launch_events" USING btree ("launch_id","seq");
2854
+ CREATE INDEX IF NOT EXISTS "idx_hub_launches_hub_created" ON "hub_launches" USING btree ("hub_id","created_at");
2855
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_hub_repositories_hub_role" ON "hub_repositories" USING btree ("hub_id","role");
2856
+ CREATE INDEX IF NOT EXISTS "idx_hub_workspace_links_hub" ON "hub_workspace_links" USING btree ("hub_id");
2857
+ CREATE INDEX IF NOT EXISTS "idx_knowledge_packs_team_id" ON "knowledge_packs" USING btree ("team_id");
2858
+ CREATE INDEX IF NOT EXISTS "idx_lease_state_status_expires" ON "lease_state" USING btree ("status","lease_expires_at");
2859
+ CREATE INDEX IF NOT EXISTS "idx_lease_state_claimed_by" ON "lease_state" USING btree ("claimed_by","updated_at");
2860
+ CREATE INDEX IF NOT EXISTS "idx_message_queue_claimable" ON "message_queue" USING btree ("status","available_at","priority");
2861
+ CREATE INDEX IF NOT EXISTS "idx_message_queue_related" ON "message_queue" USING btree ("related_model","related_id","created_at");
2862
+ CREATE INDEX IF NOT EXISTS "idx_native_usage_observations_profile" ON "native_usage_observations" USING btree ("project_id","task_signature","execution_profile_id","created_at");
2863
+ CREATE INDEX IF NOT EXISTS "idx_native_usage_observations_provider" ON "native_usage_observations" USING btree ("execution_provider_id","created_at");
2864
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_operation_events_seq" ON "platform_operation_events" USING btree ("operation_id","seq");
2865
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_operations_idempotency" ON "platform_operations" USING btree ("namespace","operation","idempotency_key");
2866
+ CREATE INDEX IF NOT EXISTS "idx_platform_operations_runnable" ON "platform_operations" USING btree ("status","created_at");
2867
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_repository_claims_active" ON "platform_repository_claims" USING btree ("repository_key","runner_id");
2868
+ CREATE INDEX IF NOT EXISTS "idx_platform_repository_claims_runner" ON "platform_repository_claims" USING btree ("runner_id","claim_state");
2869
+ CREATE INDEX IF NOT EXISTS "idx_priority_overrides_project_priority" ON "priority_overrides" USING btree ("project_id","priority","updated_at");
2870
+ CREATE INDEX IF NOT EXISTS "idx_priority_snapshots_project_generated" ON "priority_snapshots" USING btree ("project_id","generated_at");
2871
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_capability_grants_project_operation" ON "project_capability_grants" USING btree ("project_id","namespace","operation");
2872
+ CREATE INDEX IF NOT EXISTS "idx_project_deployment_events_deployment_sequence" ON "project_deployment_events" USING btree ("deployment_id","sequence");
2873
+ CREATE INDEX IF NOT EXISTS "idx_project_deployment_events_project_created" ON "project_deployment_events" USING btree ("project_id","created_at");
2874
+ CREATE INDEX IF NOT EXISTS "idx_project_deployment_events_operation" ON "project_deployment_events" USING btree ("operation_id");
2875
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_project_created" ON "project_deployments" USING btree ("project_id","created_at");
2876
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_project_environment" ON "project_deployments" USING btree ("project_id","environment","created_at");
2877
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_project_status" ON "project_deployments" USING btree ("project_id","status","updated_at");
2878
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_operation" ON "project_deployments" USING btree ("platform_operation_id");
2879
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_team_created" ON "project_deployments" USING btree ("team_id","created_at");
2880
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_deployments_idempotency" ON "project_deployments" USING btree ("project_id","idempotency_key");
2881
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_environments_project_environment" ON "project_environments" USING btree ("project_id","environment");
2882
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_infrastructure_resource_unique" ON "project_infrastructure_resources" USING btree ("project_id","environment","provider","resource_kind","logical_name");
2883
+ CREATE INDEX IF NOT EXISTS "idx_project_summary_snapshots_team_generated" ON "project_summary_snapshots" USING btree ("team_id","generated_at");
2884
+ CREATE INDEX IF NOT EXISTS "idx_project_update_plans_hub" ON "project_update_plans" USING btree ("hub_id","created_at");
2885
+ CREATE INDEX IF NOT EXISTS "idx_project_workday_summaries_project_environment_created" ON "project_workday_summaries" USING btree ("project_id","environment","created_at");
2886
+ CREATE INDEX IF NOT EXISTS "idx_projects_team_id" ON "projects" USING btree ("team_id");
2887
+ CREATE INDEX IF NOT EXISTS "idx_provider_credential_sessions_team_host" ON "provider_credential_sessions" USING btree ("team_id","host_kind","host_id","status");
2888
+ CREATE INDEX IF NOT EXISTS "idx_provider_credential_sessions_job" ON "provider_credential_sessions" USING btree ("job_id","status");
2889
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_remote_job_events_job_seq" ON "remote_job_events" USING btree ("job_id","seq");
2890
+ CREATE INDEX IF NOT EXISTS "idx_remote_jobs_project_status" ON "remote_jobs" USING btree ("project_id","status","created_at");
2891
+ CREATE INDEX IF NOT EXISTS "idx_remote_jobs_project_idempotency" ON "remote_jobs" USING btree ("project_id","idempotency_key");
2892
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_claims_runner_repo" ON "repository_claims" USING btree ("project_id","repository_id","runner_id");
2893
+ CREATE INDEX IF NOT EXISTS "idx_repository_claims_repo_state" ON "repository_claims" USING btree ("project_id","repository_id","claim_state","updated_at");
2894
+ CREATE INDEX IF NOT EXISTS "idx_repository_hosts_team_provider" ON "repository_hosts" USING btree ("team_id","provider","status");
2895
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_hosts_team_provider_name" ON "repository_hosts" USING btree ("team_id","provider","name");
2896
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_hosts_platform_provider_name" ON "repository_hosts" USING btree ("provider","name");
2897
+ CREATE INDEX IF NOT EXISTS "idx_runner_scale_decisions_project_workday" ON "runner_scale_decisions" USING btree ("project_id","environment","work_day_id","created_at");
2898
+ CREATE INDEX IF NOT EXISTS "idx_runtime_records_type_lookup_updated" ON "runtime_records" USING btree ("record_type","lookup_key","updated_at");
2899
+ CREATE INDEX IF NOT EXISTS "idx_runtime_records_type_status_updated" ON "runtime_records" USING btree ("record_type","status","updated_at");
2900
+ CREATE INDEX IF NOT EXISTS "idx_scale_decisions_project_environment_pool_created" ON "scale_decisions" USING btree ("project_id","environment","pool_name","created_at");
2901
+ CREATE INDEX IF NOT EXISTS "idx_seed_runs_seed_created" ON "seed_runs" USING btree ("seed_name","created_at");
2902
+ CREATE INDEX IF NOT EXISTS "idx_seed_runs_state_created" ON "seed_runs" USING btree ("state","created_at");
2903
+ CREATE INDEX IF NOT EXISTS "idx_task_credit_ledger_work_day_created" ON "task_credit_ledger" USING btree ("work_day_id","created_at");
2904
+ CREATE INDEX IF NOT EXISTS "idx_task_estimates_project_signature" ON "task_estimates" USING btree ("project_id","task_signature","created_at");
2905
+ CREATE INDEX IF NOT EXISTS "idx_task_estimates_project_signature_profile" ON "task_estimates" USING btree ("project_id","task_signature","execution_profile_id","created_at");
2906
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_task_events_seq" ON "task_events" USING btree ("task_id","seq");
2907
+ CREATE INDEX IF NOT EXISTS "idx_task_usage_actuals_project_signature" ON "task_usage_actuals" USING btree ("project_id","task_signature","created_at");
2908
+ CREATE INDEX IF NOT EXISTS "idx_task_usage_actuals_project_signature_profile" ON "task_usage_actuals" USING btree ("project_id","task_signature","execution_profile_id","created_at");
2909
+ CREATE INDEX IF NOT EXISTS "idx_task_usage_actuals_execution_provider" ON "task_usage_actuals" USING btree ("execution_provider_id","created_at");
2910
+ CREATE INDEX IF NOT EXISTS "idx_tasks_runnable" ON "tasks" USING btree ("state","priority","available_at");
2911
+ CREATE INDEX IF NOT EXISTS "idx_tasks_work_day_agent" ON "tasks" USING btree ("work_day_id","agent_id","created_at");
2912
+ CREATE INDEX IF NOT EXISTS "idx_team_api_keys_prefix" ON "team_api_keys" USING btree ("key_prefix");
2913
+ CREATE INDEX IF NOT EXISTS "idx_team_inbox_items_team_created" ON "team_inbox_items" USING btree ("team_id","created_at");
2914
+ CREATE INDEX IF NOT EXISTS "idx_team_invites_team_status" ON "team_invites" USING btree ("team_id","status","created_at");
2915
+ CREATE INDEX IF NOT EXISTS "idx_team_invites_token_prefix" ON "team_invites" USING btree ("token_prefix");
2916
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_team_memberships_team_user" ON "team_memberships" USING btree ("team_id","user_id");
2917
+ CREATE INDEX IF NOT EXISTS "idx_team_web_hosts_team_provider" ON "team_web_hosts" USING btree ("team_id","provider","status");
2918
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_team_web_hosts_team_provider_name" ON "team_web_hosts" USING btree ("team_id","provider","name");
2919
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_teams_name" ON "teams" USING btree ("name");
2920
+ CREATE INDEX IF NOT EXISTS "idx_user_email_addresses_user" ON "user_email_addresses" USING btree ("user_id","status","is_primary");
2921
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_email_addresses_normalized" ON "user_email_addresses" USING btree ("normalized_email");
2922
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_identities_provider_subject" ON "user_identities" USING btree ("provider","provider_subject");
2923
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_role_bindings_user_role" ON "user_role_bindings" USING btree ("user_id","role_id");
2924
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_users_username" ON "users" USING btree ("username");
2925
+ CREATE INDEX IF NOT EXISTS "idx_web_sessions_user_id" ON "web_sessions" USING btree ("user_id");
2926
+ CREATE INDEX IF NOT EXISTS "idx_workday_manager_leases_active" ON "workday_manager_leases" USING btree ("project_id","environment","state","heartbeat_at");
2927
+ CREATE INDEX IF NOT EXISTS "idx_workday_requests_project_environment_state" ON "workday_requests" USING btree ("project_id","environment","state","created_at");
2928
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_worker_runners_identity" ON "worker_runners" USING btree ("project_id","environment","runner_id");
2929
+ CREATE INDEX IF NOT EXISTS "idx_worker_runners_state_capacity" ON "worker_runners" USING btree ("project_id","environment","state","available_capacity");