@treeseed/sdk 0.10.10 → 0.10.12

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.
@@ -0,0 +1,2863 @@
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" integer,
139
+ "refreshTokenExpiresAt" integer,
140
+ "scope" text,
141
+ "password" text,
142
+ "createdAt" integer NOT NULL,
143
+ "updatedAt" integer NOT NULL
144
+ );
145
+
146
+ CREATE TABLE IF NOT EXISTS "better_auth_session" (
147
+ "id" text PRIMARY KEY NOT NULL,
148
+ "expiresAt" integer NOT NULL,
149
+ "token" text NOT NULL,
150
+ "createdAt" integer NOT NULL,
151
+ "updatedAt" integer 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" integer NOT NULL,
165
+ "updatedAt" integer 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" integer NOT NULL,
177
+ "createdAt" integer NOT NULL,
178
+ "updatedAt" integer 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_deployments" (
848
+ "id" text PRIMARY KEY NOT NULL,
849
+ "project_id" text NOT NULL,
850
+ "environment" text NOT NULL,
851
+ "deployment_kind" text NOT NULL,
852
+ "status" text NOT NULL,
853
+ "source_ref" text,
854
+ "release_tag" text,
855
+ "commit_sha" text,
856
+ "triggered_by_type" text,
857
+ "triggered_by_id" text,
858
+ "metadata_json" text,
859
+ "started_at" text,
860
+ "finished_at" text,
861
+ "created_at" text NOT NULL,
862
+ "updated_at" text NOT NULL
863
+ );
864
+
865
+ CREATE TABLE IF NOT EXISTS "project_environments" (
866
+ "id" text PRIMARY KEY NOT NULL,
867
+ "project_id" text NOT NULL,
868
+ "environment" text NOT NULL,
869
+ "deployment_profile" text NOT NULL,
870
+ "base_url" text,
871
+ "cloudflare_account_id" text,
872
+ "pages_project_name" text,
873
+ "worker_name" text,
874
+ "r2_bucket_name" text,
875
+ "d1_database_name" text,
876
+ "queue_name" text,
877
+ "railway_project_name" text,
878
+ "metadata_json" text,
879
+ "created_at" text NOT NULL,
880
+ "updated_at" text NOT NULL
881
+ );
882
+
883
+ CREATE TABLE IF NOT EXISTS "project_hosting" (
884
+ "id" text PRIMARY KEY NOT NULL,
885
+ "project_id" text NOT NULL,
886
+ "hosting_kind" text NOT NULL,
887
+ "registration" text DEFAULT 'none' NOT NULL,
888
+ "market_base_url" text,
889
+ "source_repo_owner" text,
890
+ "source_repo_name" text,
891
+ "source_repo_url" text,
892
+ "source_repo_workflow_path" text,
893
+ "metadata_json" text,
894
+ "created_at" text NOT NULL,
895
+ "updated_at" text NOT NULL,
896
+ CONSTRAINT "project_hosting_project_id_unique" UNIQUE("project_id")
897
+ );
898
+
899
+ CREATE TABLE IF NOT EXISTS "project_infrastructure_resources" (
900
+ "id" text PRIMARY KEY NOT NULL,
901
+ "project_id" text NOT NULL,
902
+ "environment" text NOT NULL,
903
+ "provider" text NOT NULL,
904
+ "resource_kind" text NOT NULL,
905
+ "logical_name" text NOT NULL,
906
+ "locator" 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_summary_snapshots" (
913
+ "project_id" text PRIMARY KEY NOT NULL,
914
+ "team_id" text NOT NULL,
915
+ "summary_json" text NOT NULL,
916
+ "generated_at" text NOT NULL,
917
+ "created_at" text NOT NULL,
918
+ "updated_at" text NOT NULL
919
+ );
920
+
921
+ CREATE TABLE IF NOT EXISTS "project_update_plans" (
922
+ "id" text PRIMARY KEY NOT NULL,
923
+ "hub_id" text NOT NULL,
924
+ "team_id" text NOT NULL,
925
+ "source_kind" text NOT NULL,
926
+ "source_ref" text,
927
+ "source_version" text,
928
+ "plan_json" text DEFAULT '{}' NOT NULL,
929
+ "state" text DEFAULT 'planned' NOT NULL,
930
+ "requires_decision" integer DEFAULT 0 NOT NULL,
931
+ "decision_id" text,
932
+ "created_by" text,
933
+ "created_at" text NOT NULL,
934
+ "updated_at" text NOT NULL
935
+ );
936
+
937
+ CREATE TABLE IF NOT EXISTS "project_workday_summaries" (
938
+ "id" text PRIMARY KEY NOT NULL,
939
+ "project_id" text NOT NULL,
940
+ "environment" text NOT NULL,
941
+ "work_day_id" text NOT NULL,
942
+ "kind" text NOT NULL,
943
+ "state" text,
944
+ "started_at" text,
945
+ "ended_at" text,
946
+ "summary_json" text NOT NULL,
947
+ "metadata_json" text NOT NULL,
948
+ "created_at" text NOT NULL,
949
+ "updated_at" text NOT NULL
950
+ );
951
+
952
+ CREATE TABLE IF NOT EXISTS "projects" (
953
+ "id" text PRIMARY KEY NOT NULL,
954
+ "team_id" text NOT NULL,
955
+ "slug" text NOT NULL,
956
+ "name" text NOT NULL,
957
+ "description" text,
958
+ "metadata_json" text,
959
+ "created_at" text NOT NULL,
960
+ "updated_at" text NOT NULL,
961
+ CONSTRAINT "projects_slug_unique" UNIQUE("slug")
962
+ );
963
+
964
+ CREATE TABLE IF NOT EXISTS "provider_credential_sessions" (
965
+ "id" text PRIMARY KEY NOT NULL,
966
+ "team_id" text NOT NULL,
967
+ "project_id" text,
968
+ "job_id" text,
969
+ "host_kind" text NOT NULL,
970
+ "host_id" text NOT NULL,
971
+ "purpose" text NOT NULL,
972
+ "encrypted_payload_json" text NOT NULL,
973
+ "status" text DEFAULT 'active' NOT NULL,
974
+ "expires_at" text NOT NULL,
975
+ "consumed_at" text,
976
+ "created_by_id" text,
977
+ "created_at" text NOT NULL,
978
+ "updated_at" text NOT NULL,
979
+ "metadata_json" text DEFAULT '{}' NOT NULL
980
+ );
981
+
982
+ CREATE TABLE IF NOT EXISTS "remote_job_events" (
983
+ "id" text PRIMARY KEY NOT NULL,
984
+ "job_id" text NOT NULL,
985
+ "seq" integer NOT NULL,
986
+ "kind" text NOT NULL,
987
+ "data_json" text,
988
+ "created_at" text NOT NULL
989
+ );
990
+
991
+ CREATE TABLE IF NOT EXISTS "remote_jobs" (
992
+ "id" text PRIMARY KEY NOT NULL,
993
+ "project_id" text NOT NULL,
994
+ "namespace" text NOT NULL,
995
+ "operation" text NOT NULL,
996
+ "status" text NOT NULL,
997
+ "preferred_mode" text NOT NULL,
998
+ "selected_target" text NOT NULL,
999
+ "capability_json" text NOT NULL,
1000
+ "input_json" text NOT NULL,
1001
+ "output_json" text,
1002
+ "error_json" text,
1003
+ "requested_by_type" text NOT NULL,
1004
+ "requested_by_id" text,
1005
+ "assigned_runner_id" text,
1006
+ "idempotency_key" text,
1007
+ "created_at" text NOT NULL,
1008
+ "updated_at" text NOT NULL,
1009
+ "started_at" text,
1010
+ "finished_at" text,
1011
+ "cancelled_at" text
1012
+ );
1013
+
1014
+ CREATE TABLE IF NOT EXISTS "reports" (
1015
+ "id" text PRIMARY KEY NOT NULL,
1016
+ "work_day_id" text NOT NULL,
1017
+ "kind" text NOT NULL,
1018
+ "body_json" text NOT NULL,
1019
+ "rendered_ref" text,
1020
+ "sent_at" text,
1021
+ "created_at" text NOT NULL
1022
+ );
1023
+
1024
+ CREATE TABLE IF NOT EXISTS "repository_claims" (
1025
+ "id" text PRIMARY KEY NOT NULL,
1026
+ "project_id" text NOT NULL,
1027
+ "repository_id" text NOT NULL,
1028
+ "runner_id" text NOT NULL,
1029
+ "runner_service_name" text NOT NULL,
1030
+ "volume_identity" text NOT NULL,
1031
+ "last_seen_commit" text,
1032
+ "last_task_at" text,
1033
+ "claim_state" text DEFAULT 'active' NOT NULL,
1034
+ "metadata_json" text NOT NULL,
1035
+ "created_at" text NOT NULL,
1036
+ "updated_at" text NOT NULL
1037
+ );
1038
+
1039
+ CREATE TABLE IF NOT EXISTS "repository_hosts" (
1040
+ "id" text PRIMARY KEY NOT NULL,
1041
+ "team_id" text,
1042
+ "provider" text NOT NULL,
1043
+ "ownership" text NOT NULL,
1044
+ "name" text NOT NULL,
1045
+ "account_label" text,
1046
+ "organization_or_owner" text NOT NULL,
1047
+ "default_visibility" text DEFAULT 'private' NOT NULL,
1048
+ "software_repository_name_template" text DEFAULT '{hub}-site' NOT NULL,
1049
+ "content_repository_name_template" text DEFAULT '{hub}-content' NOT NULL,
1050
+ "branch_policy_json" text DEFAULT '{}' NOT NULL,
1051
+ "workflow_policy_json" text DEFAULT '{}' NOT NULL,
1052
+ "encrypted_payload_json" text,
1053
+ "allowed_project_kinds_json" text DEFAULT '["knowledge_hub"]' NOT NULL,
1054
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1055
+ "status" text DEFAULT 'active' NOT NULL,
1056
+ "created_by_id" text,
1057
+ "updated_by_id" text,
1058
+ "created_at" text NOT NULL,
1059
+ "updated_at" text NOT NULL
1060
+ );
1061
+
1062
+ CREATE TABLE IF NOT EXISTS "role_permissions" (
1063
+ "role_id" text,
1064
+ "permission_id" text,
1065
+ "created_at" text NOT NULL,
1066
+ CONSTRAINT "role_permissions_role_id_permission_id_pk" PRIMARY KEY("role_id","permission_id")
1067
+ );
1068
+
1069
+ CREATE TABLE IF NOT EXISTS "roles" (
1070
+ "id" text PRIMARY KEY NOT NULL,
1071
+ "key" text NOT NULL,
1072
+ "description" text,
1073
+ "created_at" text NOT NULL,
1074
+ CONSTRAINT "roles_key_unique" UNIQUE("key")
1075
+ );
1076
+
1077
+ CREATE TABLE IF NOT EXISTS "runner_scale_decisions" (
1078
+ "id" text PRIMARY KEY NOT NULL,
1079
+ "project_id" text NOT NULL,
1080
+ "environment" text NOT NULL,
1081
+ "work_day_id" text,
1082
+ "runner_id" text,
1083
+ "runner_service_name" text,
1084
+ "action" text NOT NULL,
1085
+ "reason" text NOT NULL,
1086
+ "metadata_json" text NOT NULL,
1087
+ "created_at" text NOT NULL
1088
+ );
1089
+
1090
+ CREATE TABLE IF NOT EXISTS "runtime_envelopes" (
1091
+ "id" serial PRIMARY KEY NOT NULL,
1092
+ "record_type" text NOT NULL,
1093
+ "payload_json" text NOT NULL,
1094
+ "created_at" text NOT NULL
1095
+ );
1096
+
1097
+ CREATE TABLE IF NOT EXISTS "runtime_records" (
1098
+ "id" serial PRIMARY KEY NOT NULL,
1099
+ "record_type" text NOT NULL,
1100
+ "record_key" text NOT NULL,
1101
+ "lookup_key" text,
1102
+ "secondary_key" text,
1103
+ "status" text NOT NULL,
1104
+ "schema_version" integer DEFAULT 1 NOT NULL,
1105
+ "created_at" text NOT NULL,
1106
+ "updated_at" text NOT NULL,
1107
+ "payload_json" text NOT NULL,
1108
+ "meta_json" text NOT NULL
1109
+ );
1110
+
1111
+ CREATE TABLE IF NOT EXISTS "scale_decisions" (
1112
+ "id" text PRIMARY KEY NOT NULL,
1113
+ "project_id" text NOT NULL,
1114
+ "environment" text NOT NULL,
1115
+ "pool_name" text NOT NULL,
1116
+ "work_day_id" text,
1117
+ "desired_workers" integer NOT NULL,
1118
+ "observed_queue_depth" integer DEFAULT 0 NOT NULL,
1119
+ "observed_active_leases" integer DEFAULT 0 NOT NULL,
1120
+ "reason" text NOT NULL,
1121
+ "metadata_json" text NOT NULL,
1122
+ "created_at" text NOT NULL
1123
+ );
1124
+
1125
+ CREATE TABLE IF NOT EXISTS "seed_runs" (
1126
+ "id" text PRIMARY KEY NOT NULL,
1127
+ "seed_name" text NOT NULL,
1128
+ "seed_version" integer NOT NULL,
1129
+ "environments_json" text NOT NULL,
1130
+ "mode" text NOT NULL,
1131
+ "state" text NOT NULL,
1132
+ "actor_type" text,
1133
+ "actor_id" text,
1134
+ "manifest_hash" text NOT NULL,
1135
+ "plan_json" text NOT NULL,
1136
+ "result_json" text,
1137
+ "error_json" text,
1138
+ "created_at" text NOT NULL,
1139
+ "updated_at" text NOT NULL,
1140
+ "completed_at" text
1141
+ );
1142
+
1143
+ CREATE TABLE IF NOT EXISTS "service_credentials" (
1144
+ "id" text PRIMARY KEY NOT NULL,
1145
+ "service_id" text NOT NULL,
1146
+ "name" text NOT NULL,
1147
+ "secret_hash" text NOT NULL,
1148
+ "roles_json" text NOT NULL,
1149
+ "permissions_json" text NOT NULL,
1150
+ "revoked_at" text,
1151
+ "created_at" text NOT NULL,
1152
+ "updated_at" text NOT NULL,
1153
+ "last_used_at" text,
1154
+ CONSTRAINT "service_credentials_service_id_unique" UNIQUE("service_id")
1155
+ );
1156
+
1157
+ CREATE TABLE IF NOT EXISTS "subscribers" (
1158
+ "email" text PRIMARY KEY NOT NULL,
1159
+ "created_at" text NOT NULL
1160
+ );
1161
+
1162
+ CREATE TABLE IF NOT EXISTS "task_credit_ledger" (
1163
+ "id" text PRIMARY KEY NOT NULL,
1164
+ "project_id" text NOT NULL,
1165
+ "work_day_id" text NOT NULL,
1166
+ "task_id" text,
1167
+ "phase" text NOT NULL,
1168
+ "credits" real NOT NULL,
1169
+ "metadata_json" text NOT NULL,
1170
+ "created_at" text NOT NULL
1171
+ );
1172
+
1173
+ CREATE TABLE IF NOT EXISTS "task_estimate_profiles" (
1174
+ "task_signature" text,
1175
+ "execution_profile_id" text DEFAULT 'standard-code-model',
1176
+ "sample_count" integer DEFAULT 0 NOT NULL,
1177
+ "completed_sample_count" integer DEFAULT 0 NOT NULL,
1178
+ "interrupted_sample_count" integer DEFAULT 0 NOT NULL,
1179
+ "input_tokens_p50" integer,
1180
+ "input_tokens_p90" integer,
1181
+ "output_tokens_p50" integer,
1182
+ "output_tokens_p90" integer,
1183
+ "quota_minutes_p50" real,
1184
+ "quota_minutes_p90" real,
1185
+ "files_changed_p50" real,
1186
+ "files_changed_p90" real,
1187
+ "credits_p50" real,
1188
+ "credits_p90" real,
1189
+ "credits_variance" real,
1190
+ "confidence_score" real,
1191
+ "outlier_count" integer DEFAULT 0 NOT NULL,
1192
+ "partial_credits" real,
1193
+ "first_sample_at" text,
1194
+ "last_sample_at" text,
1195
+ "updated_at" text NOT NULL,
1196
+ CONSTRAINT "task_estimate_profiles_task_signature_execution_profile_id_pk" PRIMARY KEY("task_signature","execution_profile_id")
1197
+ );
1198
+
1199
+ CREATE TABLE IF NOT EXISTS "task_estimates" (
1200
+ "id" text PRIMARY KEY NOT NULL,
1201
+ "task_id" text,
1202
+ "work_day_id" text,
1203
+ "project_id" text NOT NULL,
1204
+ "estimate_phase" text NOT NULL,
1205
+ "task_signature" text NOT NULL,
1206
+ "confidence" text NOT NULL,
1207
+ "estimated_credits_p50" real NOT NULL,
1208
+ "estimated_credits_p90" real NOT NULL,
1209
+ "reserved_credits" real NOT NULL,
1210
+ "estimated_input_tokens_p50" integer,
1211
+ "estimated_input_tokens_p90" integer,
1212
+ "estimated_output_tokens_p50" integer,
1213
+ "estimated_output_tokens_p90" integer,
1214
+ "estimated_quota_minutes_p50" real,
1215
+ "estimated_quota_minutes_p90" real,
1216
+ "features_json" text DEFAULT '{}' NOT NULL,
1217
+ "created_at" text NOT NULL,
1218
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL
1219
+ );
1220
+
1221
+ CREATE TABLE IF NOT EXISTS "task_events" (
1222
+ "id" text PRIMARY KEY NOT NULL,
1223
+ "task_id" text NOT NULL,
1224
+ "seq" integer NOT NULL,
1225
+ "kind" text NOT NULL,
1226
+ "data_json" text NOT NULL,
1227
+ "created_at" text NOT NULL
1228
+ );
1229
+
1230
+ CREATE TABLE IF NOT EXISTS "task_outputs" (
1231
+ "id" text PRIMARY KEY NOT NULL,
1232
+ "task_id" text NOT NULL,
1233
+ "output_json" text NOT NULL,
1234
+ "output_ref" text,
1235
+ "created_at" text NOT NULL
1236
+ );
1237
+
1238
+ CREATE TABLE IF NOT EXISTS "task_usage_actuals" (
1239
+ "id" text PRIMARY KEY NOT NULL,
1240
+ "task_id" text,
1241
+ "work_day_id" text,
1242
+ "project_id" text NOT NULL,
1243
+ "task_signature" text NOT NULL,
1244
+ "capacity_provider_id" text,
1245
+ "execution_provider_id" text,
1246
+ "lane_id" text,
1247
+ "business_model" text NOT NULL,
1248
+ "model_name" text,
1249
+ "input_tokens" integer,
1250
+ "output_tokens" integer,
1251
+ "cached_input_tokens" integer,
1252
+ "quota_minutes" real,
1253
+ "wall_minutes" real,
1254
+ "files_opened" integer,
1255
+ "files_changed" integer,
1256
+ "diff_lines_added" integer,
1257
+ "diff_lines_removed" integer,
1258
+ "test_runs" integer,
1259
+ "retry_count" integer,
1260
+ "actual_credits" real NOT NULL,
1261
+ "actual_usd" real,
1262
+ "credit_formula_version" text DEFAULT 'treeseed.actual-credits.v1' NOT NULL,
1263
+ "actual_credit_source" text DEFAULT 'central_calculator' NOT NULL,
1264
+ "native_usage_json" text DEFAULT '{}' NOT NULL,
1265
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1266
+ "created_at" text NOT NULL,
1267
+ "execution_profile_id" text DEFAULT 'standard-code-model' NOT NULL
1268
+ );
1269
+
1270
+ CREATE TABLE IF NOT EXISTS "tasks" (
1271
+ "id" text PRIMARY KEY NOT NULL,
1272
+ "work_day_id" text NOT NULL,
1273
+ "agent_id" text NOT NULL,
1274
+ "type" text NOT NULL,
1275
+ "state" text NOT NULL,
1276
+ "priority" integer DEFAULT 0 NOT NULL,
1277
+ "idempotency_key" text NOT NULL,
1278
+ "payload_json" text NOT NULL,
1279
+ "payload_hash" text,
1280
+ "attempt_count" integer DEFAULT 0 NOT NULL,
1281
+ "max_attempts" integer DEFAULT 3 NOT NULL,
1282
+ "claimed_by" text,
1283
+ "lease_expires_at" text,
1284
+ "available_at" text NOT NULL,
1285
+ "last_error_code" text,
1286
+ "last_error_message" text,
1287
+ "graph_version" text,
1288
+ "parent_task_id" text,
1289
+ "created_at" text NOT NULL,
1290
+ "started_at" text,
1291
+ "completed_at" text,
1292
+ "updated_at" text NOT NULL,
1293
+ CONSTRAINT "tasks_idempotency_key_unique" UNIQUE("idempotency_key")
1294
+ );
1295
+
1296
+ CREATE TABLE IF NOT EXISTS "team_api_keys" (
1297
+ "id" text PRIMARY KEY NOT NULL,
1298
+ "team_id" text NOT NULL,
1299
+ "name" text NOT NULL,
1300
+ "key_prefix" text NOT NULL,
1301
+ "key_hash" text NOT NULL,
1302
+ "permissions_json" text NOT NULL,
1303
+ "expires_at" text,
1304
+ "last_used_at" text,
1305
+ "revoked_at" text,
1306
+ "created_at" text NOT NULL,
1307
+ "updated_at" text NOT NULL
1308
+ );
1309
+
1310
+ CREATE TABLE IF NOT EXISTS "team_inbox_items" (
1311
+ "id" text PRIMARY KEY NOT NULL,
1312
+ "team_id" text NOT NULL,
1313
+ "project_id" text,
1314
+ "kind" text NOT NULL,
1315
+ "state" text NOT NULL,
1316
+ "title" text NOT NULL,
1317
+ "summary" text,
1318
+ "href" text,
1319
+ "item_key" text,
1320
+ "metadata_json" text DEFAULT '{}' NOT NULL,
1321
+ "created_at" text NOT NULL,
1322
+ "updated_at" text NOT NULL
1323
+ );
1324
+
1325
+ CREATE TABLE IF NOT EXISTS "team_invites" (
1326
+ "id" text PRIMARY KEY NOT NULL,
1327
+ "team_id" text NOT NULL,
1328
+ "email" text NOT NULL,
1329
+ "role_key" text NOT NULL,
1330
+ "token_prefix" text NOT NULL,
1331
+ "token_hash" text NOT NULL,
1332
+ "status" text DEFAULT 'pending' NOT NULL,
1333
+ "invited_by_user_id" text,
1334
+ "accepted_by_user_id" text,
1335
+ "accepted_at" text,
1336
+ "expires_at" text NOT NULL,
1337
+ "created_at" text NOT NULL,
1338
+ "updated_at" text NOT NULL
1339
+ );
1340
+
1341
+ CREATE TABLE IF NOT EXISTS "team_memberships" (
1342
+ "id" text PRIMARY KEY NOT NULL,
1343
+ "team_id" text NOT NULL,
1344
+ "user_id" text NOT NULL,
1345
+ "status" text DEFAULT 'active' NOT NULL,
1346
+ "created_at" text NOT NULL,
1347
+ "updated_at" text NOT NULL
1348
+ );
1349
+
1350
+ CREATE TABLE IF NOT EXISTS "team_role_bindings" (
1351
+ "id" text PRIMARY KEY NOT NULL,
1352
+ "team_membership_id" text NOT NULL,
1353
+ "role_id" text NOT NULL,
1354
+ "created_at" text NOT NULL
1355
+ );
1356
+
1357
+ CREATE TABLE IF NOT EXISTS "team_storage_locators" (
1358
+ "id" text PRIMARY KEY NOT NULL,
1359
+ "team_id" text NOT NULL,
1360
+ "bucket_name" text NOT NULL,
1361
+ "manifest_key_template" text NOT NULL,
1362
+ "preview_root_template" text NOT NULL,
1363
+ "public_base_url" text,
1364
+ "metadata_json" text,
1365
+ "created_at" text NOT NULL,
1366
+ "updated_at" text NOT NULL,
1367
+ CONSTRAINT "team_storage_locators_team_id_unique" UNIQUE("team_id")
1368
+ );
1369
+
1370
+ CREATE TABLE IF NOT EXISTS "team_web_hosts" (
1371
+ "id" text PRIMARY KEY NOT NULL,
1372
+ "team_id" text NOT NULL,
1373
+ "provider" text NOT NULL,
1374
+ "ownership" text NOT NULL,
1375
+ "name" text NOT NULL,
1376
+ "account_label" text,
1377
+ "allowed_environments_json" text DEFAULT '[]' NOT NULL,
1378
+ "status" text DEFAULT 'active' NOT NULL,
1379
+ "encrypted_payload_json" text,
1380
+ "metadata_json" text,
1381
+ "created_by_id" text,
1382
+ "updated_by_id" text,
1383
+ "created_at" text NOT NULL,
1384
+ "updated_at" text NOT NULL
1385
+ );
1386
+
1387
+ CREATE TABLE IF NOT EXISTS "teams" (
1388
+ "id" text PRIMARY KEY NOT NULL,
1389
+ "slug" text NOT NULL,
1390
+ "name" text NOT NULL,
1391
+ "metadata_json" text,
1392
+ "created_at" text NOT NULL,
1393
+ "updated_at" text NOT NULL,
1394
+ "display_name" text,
1395
+ "logo_url" text,
1396
+ "profile_summary" text,
1397
+ CONSTRAINT "teams_slug_unique" UNIQUE("slug")
1398
+ );
1399
+
1400
+ CREATE TABLE IF NOT EXISTS "user_identities" (
1401
+ "id" text PRIMARY KEY NOT NULL,
1402
+ "user_id" text NOT NULL,
1403
+ "provider" text NOT NULL,
1404
+ "provider_subject" text NOT NULL,
1405
+ "email" text,
1406
+ "email_verified" integer DEFAULT 0 NOT NULL,
1407
+ "profile_json" text,
1408
+ "created_at" text NOT NULL,
1409
+ "updated_at" text NOT NULL
1410
+ );
1411
+
1412
+ CREATE TABLE IF NOT EXISTS "user_preferences" (
1413
+ "user_id" text PRIMARY KEY NOT NULL,
1414
+ "color_scheme" text DEFAULT 'fern' NOT NULL,
1415
+ "theme_mode" text DEFAULT 'system' NOT NULL,
1416
+ "created_at" text NOT NULL,
1417
+ "updated_at" text NOT NULL
1418
+ );
1419
+
1420
+ CREATE TABLE IF NOT EXISTS "user_role_bindings" (
1421
+ "id" text PRIMARY KEY NOT NULL,
1422
+ "user_id" text NOT NULL,
1423
+ "role_id" text NOT NULL,
1424
+ "created_at" text NOT NULL
1425
+ );
1426
+
1427
+ CREATE TABLE IF NOT EXISTS "users" (
1428
+ "id" text PRIMARY KEY NOT NULL,
1429
+ "email" text,
1430
+ "display_name" text,
1431
+ "status" text DEFAULT 'active' NOT NULL,
1432
+ "metadata_json" text,
1433
+ "created_at" text NOT NULL,
1434
+ "updated_at" text NOT NULL,
1435
+ "username" text
1436
+ );
1437
+
1438
+ CREATE TABLE IF NOT EXISTS "web_sessions" (
1439
+ "id" text PRIMARY KEY NOT NULL,
1440
+ "user_id" text NOT NULL,
1441
+ "identity_id" text,
1442
+ "better_auth_session_id" text,
1443
+ "provider" text NOT NULL,
1444
+ "provider_subject" text NOT NULL,
1445
+ "email" text,
1446
+ "display_name" text,
1447
+ "principal_json" text NOT NULL,
1448
+ "csrf_token" text NOT NULL,
1449
+ "ip_address" text,
1450
+ "user_agent" text,
1451
+ "authenticated_at" text NOT NULL,
1452
+ "last_seen_at" text,
1453
+ "expires_at" text NOT NULL,
1454
+ "revoked_at" text,
1455
+ "created_at" text NOT NULL,
1456
+ "updated_at" text NOT NULL
1457
+ );
1458
+
1459
+ CREATE TABLE IF NOT EXISTS "work_days" (
1460
+ "id" text PRIMARY KEY NOT NULL,
1461
+ "project_id" text NOT NULL,
1462
+ "state" text NOT NULL,
1463
+ "capacity_budget" integer DEFAULT 0 NOT NULL,
1464
+ "capacity_used" integer DEFAULT 0 NOT NULL,
1465
+ "graph_version" text,
1466
+ "summary_json" text,
1467
+ "started_at" text NOT NULL,
1468
+ "ended_at" text,
1469
+ "created_at" text NOT NULL,
1470
+ "updated_at" text NOT NULL
1471
+ );
1472
+
1473
+ CREATE TABLE IF NOT EXISTS "work_policies" (
1474
+ "project_id" text,
1475
+ "environment" text,
1476
+ "schedule_json" text NOT NULL,
1477
+ "daily_task_credit_budget" integer DEFAULT 0 NOT NULL,
1478
+ "max_queued_tasks" integer DEFAULT 0 NOT NULL,
1479
+ "max_queued_credits" integer DEFAULT 0 NOT NULL,
1480
+ "autoscale_json" text NOT NULL,
1481
+ "credit_weights_json" text NOT NULL,
1482
+ "metadata_json" text NOT NULL,
1483
+ "created_at" text NOT NULL,
1484
+ "updated_at" text NOT NULL,
1485
+ "enabled" integer DEFAULT 1 NOT NULL,
1486
+ "start_cron" text DEFAULT '0 9 * * 1-5' NOT NULL,
1487
+ "duration_minutes" integer DEFAULT 480 NOT NULL,
1488
+ "max_runners" integer DEFAULT 1 NOT NULL,
1489
+ "max_workers_per_runner" integer DEFAULT 4 NOT NULL,
1490
+ "daily_credit_budget" integer DEFAULT 0 NOT NULL,
1491
+ "closeout_grace_minutes" integer DEFAULT 15 NOT NULL,
1492
+ CONSTRAINT "work_policies_project_id_environment_pk" PRIMARY KEY("project_id","environment")
1493
+ );
1494
+
1495
+ CREATE TABLE IF NOT EXISTS "workday_manager_leases" (
1496
+ "id" text PRIMARY KEY NOT NULL,
1497
+ "project_id" text NOT NULL,
1498
+ "environment" text NOT NULL,
1499
+ "work_day_id" text,
1500
+ "manager_id" text NOT NULL,
1501
+ "state" text DEFAULT 'active' NOT NULL,
1502
+ "heartbeat_at" text NOT NULL,
1503
+ "expires_at" text NOT NULL,
1504
+ "metadata_json" text NOT NULL,
1505
+ "created_at" text NOT NULL,
1506
+ "updated_at" text NOT NULL
1507
+ );
1508
+
1509
+ CREATE TABLE IF NOT EXISTS "workday_requests" (
1510
+ "id" text PRIMARY KEY NOT NULL,
1511
+ "project_id" text NOT NULL,
1512
+ "environment" text NOT NULL,
1513
+ "type" text NOT NULL,
1514
+ "state" text DEFAULT 'pending' NOT NULL,
1515
+ "work_day_id" text,
1516
+ "requested_by" text,
1517
+ "reason" text,
1518
+ "payload_json" text NOT NULL,
1519
+ "metadata_json" text NOT NULL,
1520
+ "created_at" text NOT NULL,
1521
+ "updated_at" text NOT NULL
1522
+ );
1523
+
1524
+ CREATE TABLE IF NOT EXISTS "worker_runners" (
1525
+ "id" text PRIMARY KEY NOT NULL,
1526
+ "project_id" text NOT NULL,
1527
+ "environment" text NOT NULL,
1528
+ "runner_id" text NOT NULL,
1529
+ "runner_service_name" text NOT NULL,
1530
+ "volume_identity" text NOT NULL,
1531
+ "state" text DEFAULT 'active' NOT NULL,
1532
+ "max_local_workers" integer DEFAULT 4 NOT NULL,
1533
+ "active_local_workers" integer DEFAULT 0 NOT NULL,
1534
+ "available_capacity" integer DEFAULT 4 NOT NULL,
1535
+ "last_heartbeat_at" text,
1536
+ "claimed_repository_ids_json" text NOT NULL,
1537
+ "metadata_json" text NOT NULL,
1538
+ "created_at" text NOT NULL,
1539
+ "updated_at" text NOT NULL
1540
+ );
1541
+
1542
+
1543
+ -- Treeseed Market schema adoption columns
1544
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "id" integer;
1545
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "type" text;
1546
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "payload_json" text;
1547
+ ALTER TABLE "agent_messages" ADD COLUMN IF NOT EXISTS "created_at" text;
1548
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "id" text;
1549
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "pool_id" text;
1550
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "project_id" text;
1551
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "runner_id" text;
1552
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "manager_id" text;
1553
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "service_name" text;
1554
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
1555
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
1556
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer;
1557
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer;
1558
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1559
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "created_at" text;
1560
+ ALTER TABLE "agent_pool_registrations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1561
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
1562
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "pool_id" text;
1563
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
1564
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
1565
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
1566
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer DEFAULT 0;
1567
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer DEFAULT 0;
1568
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1569
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
1570
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1571
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
1572
+ ALTER TABLE "agent_pool_scale_decisions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1573
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "id" text;
1574
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "project_id" text;
1575
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "team_id" text;
1576
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "environment" text;
1577
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "name" text;
1578
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "registration_identity" text;
1579
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "service_base_url" text;
1580
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
1581
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "min_workers" integer DEFAULT 0;
1582
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "max_workers" integer DEFAULT 1;
1583
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "target_queue_depth" integer DEFAULT 1;
1584
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "cooldown_seconds" integer DEFAULT 60;
1585
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1586
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "created_at" text;
1587
+ ALTER TABLE "agent_pools" ADD COLUMN IF NOT EXISTS "updated_at" text;
1588
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "run_id" text;
1589
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "agent_slug" text;
1590
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "status" text;
1591
+ ALTER TABLE "agent_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
1592
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "id" text;
1593
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "user_id" text;
1594
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "kind" text;
1595
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "name" text;
1596
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "token_prefix" text;
1597
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "token_hash" text;
1598
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "scopes_json" text;
1599
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "expires_at" text;
1600
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "last_used_at" text;
1601
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1602
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1603
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "created_at" text;
1604
+ ALTER TABLE "api_tokens" ADD COLUMN IF NOT EXISTS "updated_at" text;
1605
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "id" text;
1606
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "team_id" text;
1607
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "project_id" text;
1608
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1609
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "task_id" text;
1610
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "kind" text;
1611
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'pending';
1612
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "severity" text DEFAULT 'medium';
1613
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "requested_by_type" text DEFAULT 'worker';
1614
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
1615
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "title" text;
1616
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "summary" text;
1617
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "options_json" text DEFAULT '[]';
1618
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "recommendation_json" text DEFAULT '{}';
1619
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "policy_snapshot_json" text DEFAULT '{}';
1620
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "expires_at" text;
1621
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_by_type" text;
1622
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_by_id" text;
1623
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decided_at" text;
1624
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "decision_json" text;
1625
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1626
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "created_at" text;
1627
+ ALTER TABLE "approval_requests" ADD COLUMN IF NOT EXISTS "updated_at" text;
1628
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "id" text;
1629
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "actor_type" text;
1630
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "actor_id" text;
1631
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "event_type" text;
1632
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "target_type" text;
1633
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "target_id" text;
1634
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "data_json" text;
1635
+ ALTER TABLE "audit_events" ADD COLUMN IF NOT EXISTS "created_at" text;
1636
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "id" text;
1637
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "user_id" text;
1638
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "session_type" text;
1639
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "refresh_token_hash" text;
1640
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "scopes_json" text;
1641
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
1642
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1643
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "data_json" text;
1644
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
1645
+ ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1646
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "id" text;
1647
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accountId" text;
1648
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "providerId" text;
1649
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "userId" text;
1650
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accessToken" text;
1651
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "refreshToken" text;
1652
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "idToken" text;
1653
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "accessTokenExpiresAt" integer;
1654
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "refreshTokenExpiresAt" integer;
1655
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "scope" text;
1656
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "password" text;
1657
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1658
+ ALTER TABLE "better_auth_account" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1659
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "id" text;
1660
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "expiresAt" integer;
1661
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "token" text;
1662
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1663
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1664
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "ipAddress" text;
1665
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "userAgent" text;
1666
+ ALTER TABLE "better_auth_session" ADD COLUMN IF NOT EXISTS "userId" text;
1667
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "id" text;
1668
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "name" text;
1669
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "email" text;
1670
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "emailVerified" integer DEFAULT 0;
1671
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "image" text;
1672
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1673
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1674
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "username" text;
1675
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "firstName" text;
1676
+ ALTER TABLE "better_auth_user" ADD COLUMN IF NOT EXISTS "lastName" text;
1677
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "id" text;
1678
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "identifier" text;
1679
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "value" text;
1680
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "expiresAt" integer;
1681
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "createdAt" integer;
1682
+ ALTER TABLE "better_auth_verification" ADD COLUMN IF NOT EXISTS "updatedAt" integer;
1683
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "id" text;
1684
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1685
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "lane_id" text;
1686
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "grant_scope" text DEFAULT 'team';
1687
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "team_id" text;
1688
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "project_id" text;
1689
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "environment" text;
1690
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
1691
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "daily_credit_limit" real;
1692
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "weekly_credit_limit" real;
1693
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "monthly_credit_limit" real;
1694
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "daily_usd_limit" real;
1695
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "weekly_quota_minutes" real;
1696
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "monthly_provider_units" real;
1697
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "priority_weight" real DEFAULT 1;
1698
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "overflow_policy" text DEFAULT 'soft_grant';
1699
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1700
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "created_at" text;
1701
+ ALTER TABLE "capacity_grants" ADD COLUMN IF NOT EXISTS "updated_at" text;
1702
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "id" text;
1703
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1704
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "lane_id" text;
1705
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "reservation_id" text;
1706
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "team_id" text;
1707
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "project_id" text;
1708
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1709
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "task_id" text;
1710
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "phase" text;
1711
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "credits" real;
1712
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "provider_units" real;
1713
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "usd" real;
1714
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "source" text;
1715
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1716
+ ALTER TABLE "capacity_ledger_entries" ADD COLUMN IF NOT EXISTS "created_at" text;
1717
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "id" text;
1718
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1719
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "team_id" text;
1720
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "name" text;
1721
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "key_prefix" text;
1722
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "key_hash" text;
1723
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "scopes_json" text DEFAULT '[]';
1724
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
1725
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "last_used_at" text;
1726
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "rotated_from_key_id" text;
1727
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "expires_at" text;
1728
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "revoked_at" text;
1729
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "created_by_id" text;
1730
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "created_at" text;
1731
+ ALTER TABLE "capacity_provider_api_keys" ADD COLUMN IF NOT EXISTS "updated_at" text;
1732
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "id" text;
1733
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "team_id" text;
1734
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1735
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "launch_mode" text;
1736
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "host_kind" text;
1737
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "host_id" text;
1738
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "status" text;
1739
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "image_ref" text;
1740
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "service_refs_json" text DEFAULT '{}';
1741
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "env_refs_json" text DEFAULT '{}';
1742
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "result_json" text DEFAULT '{}';
1743
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "error_json" text;
1744
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "created_by_id" text;
1745
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "created_at" text;
1746
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "updated_at" text;
1747
+ ALTER TABLE "capacity_provider_deployments" ADD COLUMN IF NOT EXISTS "completed_at" text;
1748
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "id" text;
1749
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1750
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "host_id" text;
1751
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "role" text;
1752
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "required" integer DEFAULT 1;
1753
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1754
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
1755
+ ALTER TABLE "capacity_provider_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
1756
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "id" text;
1757
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1758
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "name" text;
1759
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "business_model" text DEFAULT 'custom';
1760
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "model_family" text;
1761
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "model_class" text;
1762
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "region_policy" text;
1763
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "unit" text DEFAULT 'treeseed_credit';
1764
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "scarcity_level" text DEFAULT 'medium';
1765
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "hard_limits_json" text DEFAULT '{}';
1766
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "routing_policy_json" text DEFAULT '{}';
1767
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1768
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "created_at" text;
1769
+ ALTER TABLE "capacity_provider_lanes" ADD COLUMN IF NOT EXISTS "updated_at" text;
1770
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "id" text;
1771
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1772
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "team_id" text;
1773
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "runtime_version" text;
1774
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "market_id" text;
1775
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "capabilities_json" text DEFAULT '[]';
1776
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "budgets_json" text DEFAULT '{}';
1777
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "health_json" text DEFAULT '{}';
1778
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'online';
1779
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "registered_at" text;
1780
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "last_seen_at" text;
1781
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "disconnected_at" text;
1782
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "created_at" text;
1783
+ ALTER TABLE "capacity_provider_registrations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1784
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "id" text;
1785
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "team_id" text;
1786
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "owner_team_id" text;
1787
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "name" text;
1788
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "kind" text;
1789
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
1790
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "provider" text;
1791
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "billing_scope" text DEFAULT 'team';
1792
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "monthly_credit_budget" real DEFAULT 0;
1793
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "daily_credit_budget" real DEFAULT 0;
1794
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "credit_budget_mode" text DEFAULT 'derived';
1795
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workdays" integer DEFAULT 1;
1796
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workers" integer DEFAULT 1;
1797
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "capacity_model_json" text DEFAULT '{}';
1798
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1799
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "created_at" text;
1800
+ ALTER TABLE "capacity_providers" ADD COLUMN IF NOT EXISTS "updated_at" text;
1801
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "id" text;
1802
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1803
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1804
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "lane_id" text;
1805
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "team_id" text;
1806
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "project_id" text;
1807
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1808
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "task_id" text;
1809
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'reserved';
1810
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_credits" real;
1811
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_credits" real DEFAULT 0;
1812
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "native_unit" text;
1813
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_native_amount" real;
1814
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_native_amount" real;
1815
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_provider_units" real;
1816
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_provider_units" real;
1817
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "reserved_usd" real;
1818
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "consumed_usd" real;
1819
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "expires_at" text;
1820
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1821
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "created_at" text;
1822
+ ALTER TABLE "capacity_reservations" ADD COLUMN IF NOT EXISTS "updated_at" text;
1823
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "id" text;
1824
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "task_id" text;
1825
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1826
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
1827
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_provider_id" text;
1828
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_lane_id" text;
1829
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "selected_model" text;
1830
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "decision" text DEFAULT 'selected';
1831
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
1832
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "candidate_json" text DEFAULT '[]';
1833
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "score_json" text DEFAULT '{}';
1834
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1835
+ ALTER TABLE "capacity_routing_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
1836
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "id" text;
1837
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "item_id" text;
1838
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "team_id" text;
1839
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "kind" text;
1840
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "version" text;
1841
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "content_key" text;
1842
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "manifest_key" text;
1843
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1844
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "published_at" text;
1845
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "created_at" text;
1846
+ ALTER TABLE "catalog_artifact_versions" ADD COLUMN IF NOT EXISTS "updated_at" text;
1847
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "id" text;
1848
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "item_id" text;
1849
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "subject_type" text;
1850
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "subject_id" text;
1851
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "role" text;
1852
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1853
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "created_at" text;
1854
+ ALTER TABLE "catalog_item_collaborators" ADD COLUMN IF NOT EXISTS "updated_at" text;
1855
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "id" text;
1856
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "team_id" text;
1857
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "kind" text;
1858
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "slug" text;
1859
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "title" text;
1860
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "summary" text;
1861
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "visibility" text;
1862
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "listing_enabled" integer DEFAULT 0;
1863
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "offer_mode" text;
1864
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "manifest_key" text;
1865
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "artifact_key" text;
1866
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "search_text" text;
1867
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1868
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "created_at" text;
1869
+ ALTER TABLE "catalog_items" ADD COLUMN IF NOT EXISTS "updated_at" text;
1870
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "id" integer;
1871
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "email" text;
1872
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "message" text;
1873
+ ALTER TABLE "contact_submissions" ADD COLUMN IF NOT EXISTS "created_at" text;
1874
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "id" text;
1875
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "task_signature" text;
1876
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
1877
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "execution_provider_kind" text;
1878
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_unit" text;
1879
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "sample_count" integer DEFAULT 0;
1880
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "completed_sample_count" integer DEFAULT 0;
1881
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "interrupted_sample_count" integer DEFAULT 0;
1882
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_units_per_credit_p50" real;
1883
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "native_units_per_credit_p90" real;
1884
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "credits_per_native_unit_p50" real;
1885
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "credits_per_native_unit_p90" real;
1886
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "actual_credits_p50" real;
1887
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "actual_credits_p90" real;
1888
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'low';
1889
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "formula_version" text;
1890
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1891
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "created_at" text;
1892
+ ALTER TABLE "credit_conversion_profiles" ADD COLUMN IF NOT EXISTS "updated_at" text;
1893
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "agent_slug" text;
1894
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "cursor_key" text;
1895
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "status" text;
1896
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
1897
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "updated_at" text;
1898
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "payload_json" text;
1899
+ ALTER TABLE "cursor_state" ADD COLUMN IF NOT EXISTS "meta_json" text;
1900
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "id" text;
1901
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "device_code" text;
1902
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "user_code" text;
1903
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "requested_scopes_json" text;
1904
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "expires_at" text;
1905
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "interval_seconds" integer;
1906
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "status" text;
1907
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "user_id" text;
1908
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "created_at" text;
1909
+ ALTER TABLE "device_codes" ADD COLUMN IF NOT EXISTS "updated_at" text;
1910
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "id" text;
1911
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "team_id" text;
1912
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "project_id" text;
1913
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "tier" text;
1914
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "status" text;
1915
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "metadata_json" text;
1916
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "created_at" text;
1917
+ ALTER TABLE "entitlements" ADD COLUMN IF NOT EXISTS "updated_at" text;
1918
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "id" text;
1919
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1920
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "scope" text;
1921
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "native_unit" text;
1922
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "limit_amount" real;
1923
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reserve_buffer_percent" real DEFAULT 0;
1924
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reset_cadence" text;
1925
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "reset_at" text;
1926
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'estimated';
1927
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "source" text DEFAULT 'configured';
1928
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1929
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "created_at" text;
1930
+ ALTER TABLE "execution_provider_native_limits" ADD COLUMN IF NOT EXISTS "updated_at" text;
1931
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "id" text;
1932
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
1933
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "observed_at" text;
1934
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "health" text DEFAULT 'unknown';
1935
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "active_workers" integer;
1936
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "queued_tasks" integer;
1937
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "throttle_state" text;
1938
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "native_remaining_json" text DEFAULT '{}';
1939
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "reset_at" text;
1940
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "confidence" text DEFAULT 'estimated';
1941
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1942
+ ALTER TABLE "execution_provider_observations" ADD COLUMN IF NOT EXISTS "created_at" text;
1943
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "id" text;
1944
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "team_id" text;
1945
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
1946
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "name" text;
1947
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "kind" text;
1948
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
1949
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "native_unit" text;
1950
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "quota_visibility" text DEFAULT 'opaque';
1951
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "max_concurrent_workers" integer DEFAULT 1;
1952
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "reset_cadence" text;
1953
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "config_json" text DEFAULT '{}';
1954
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1955
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "created_at" text;
1956
+ ALTER TABLE "execution_providers" ADD COLUMN IF NOT EXISTS "updated_at" text;
1957
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "id" text;
1958
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "work_day_id" text;
1959
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "corpus_hash" text;
1960
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "graph_version" text;
1961
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "query_json" text;
1962
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "seed_ids_json" text;
1963
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "selected_node_ids_json" text;
1964
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "stats_json" text;
1965
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "snapshot_ref" text;
1966
+ ALTER TABLE "graph_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
1967
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "id" text;
1968
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "hub_id" text;
1969
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "team_id" text;
1970
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "content_repository_id" text;
1971
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "production_source" text;
1972
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "overlay_policy" text;
1973
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_bucket_name" text;
1974
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_manifest_key" text;
1975
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "r2_public_base_url" text;
1976
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "latest_publish_id" text;
1977
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "latest_content_version" text;
1978
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
1979
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "created_at" text;
1980
+ ALTER TABLE "hub_content_sources" ADD COLUMN IF NOT EXISTS "updated_at" text;
1981
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "id" text;
1982
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "launch_id" text;
1983
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "seq" integer;
1984
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "phase" text;
1985
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "status" text;
1986
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "title" text;
1987
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "summary" text;
1988
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "started_at" text;
1989
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "finished_at" text;
1990
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "error_json" text;
1991
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "data_json" text DEFAULT '{}';
1992
+ ALTER TABLE "hub_launch_events" ADD COLUMN IF NOT EXISTS "created_at" text;
1993
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "id" text;
1994
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "hub_id" text;
1995
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "team_id" text;
1996
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "job_id" text;
1997
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "intent_json" text;
1998
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "plan_json" text DEFAULT '{}';
1999
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "state" text;
2000
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "current_phase" text;
2001
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "last_successful_phase" text;
2002
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "result_json" text;
2003
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "error_json" text;
2004
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "created_at" text;
2005
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "updated_at" text;
2006
+ ALTER TABLE "hub_launches" ADD COLUMN IF NOT EXISTS "completed_at" text;
2007
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "id" text;
2008
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "hub_id" text;
2009
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "team_id" text;
2010
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "role" text;
2011
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "repository_host_id" text;
2012
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "provider" text;
2013
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "owner" text;
2014
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "name" text;
2015
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "url" text;
2016
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "default_branch" text;
2017
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "current_branch" text;
2018
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'queued';
2019
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "access_policy_json" text DEFAULT '{}';
2020
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "release_policy_json" text DEFAULT '{}';
2021
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "publish_policy_json" text DEFAULT '{}';
2022
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "submodule_path" text;
2023
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2024
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "created_at" text;
2025
+ ALTER TABLE "hub_repositories" ADD COLUMN IF NOT EXISTS "updated_at" text;
2026
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "id" text;
2027
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "hub_id" text;
2028
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "team_id" text;
2029
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_repository_host_id" text;
2030
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_owner" text;
2031
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_name" text;
2032
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_url" text;
2033
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "parent_branch" text;
2034
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "hub_mount_path" text;
2035
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "software_submodule_path" text;
2036
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "content_submodule_path" text;
2037
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "update_submodule_pointers_enabled" integer DEFAULT 0;
2038
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "access_policy_json" text DEFAULT '{}';
2039
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2040
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "created_at" text;
2041
+ ALTER TABLE "hub_workspace_links" ADD COLUMN IF NOT EXISTS "updated_at" text;
2042
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "id" text;
2043
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "team_id" text;
2044
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "slug" text;
2045
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "name" text;
2046
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "summary" text;
2047
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "source_kind" text;
2048
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "source_ref" text;
2049
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "install_strategy" text;
2050
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "visibility" text;
2051
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2052
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "created_at" text;
2053
+ ALTER TABLE "knowledge_packs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2054
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "model" text;
2055
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "item_key" text;
2056
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "status" text;
2057
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2058
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2059
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "claimed_at" text;
2060
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2061
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "created_at" text;
2062
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "updated_at" text;
2063
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "payload_json" text;
2064
+ ALTER TABLE "lease_state" ADD COLUMN IF NOT EXISTS "meta_json" text;
2065
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "user_id" text;
2066
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "email" text;
2067
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "username" text;
2068
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "password_hash" text;
2069
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2070
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "created_at" text;
2071
+ ALTER TABLE "market_auth_credentials" ADD COLUMN IF NOT EXISTS "updated_at" text;
2072
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "id" text;
2073
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "user_id" text;
2074
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "token_hash" text;
2075
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "expires_at" text;
2076
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "used_at" text;
2077
+ ALTER TABLE "market_auth_password_resets" ADD COLUMN IF NOT EXISTS "created_at" text;
2078
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "id" text;
2079
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "runner_key" text;
2080
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "name" text;
2081
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "environment" text;
2082
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'online';
2083
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "version" text;
2084
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "capabilities_json" text DEFAULT '[]';
2085
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "active_job_count" integer DEFAULT 0;
2086
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "max_concurrent_jobs" integer DEFAULT 1;
2087
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
2088
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2089
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "created_at" text;
2090
+ ALTER TABLE "market_operation_runners" ADD COLUMN IF NOT EXISTS "updated_at" text;
2091
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "id" integer;
2092
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "message_type" text;
2093
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "status" text;
2094
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2095
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "related_model" text;
2096
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "related_id" text;
2097
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "priority" integer DEFAULT 0;
2098
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "available_at" text;
2099
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2100
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "claimed_at" text;
2101
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2102
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "attempts" integer DEFAULT 0;
2103
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "max_attempts" integer DEFAULT 3;
2104
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "created_at" text;
2105
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "updated_at" text;
2106
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "payload_json" text;
2107
+ ALTER TABLE "message_queue" ADD COLUMN IF NOT EXISTS "meta_json" text;
2108
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "id" text;
2109
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_usage_actual_id" text;
2110
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_id" text;
2111
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2112
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "project_id" text;
2113
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "task_signature" text;
2114
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2115
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
2116
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
2117
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "native_unit" text;
2118
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "native_usage_json" text DEFAULT '{}';
2119
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "observed_at" text;
2120
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "source" text DEFAULT 'provider_report';
2121
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "formula_version" text DEFAULT 'treeseed.actual-credits.v1';
2122
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "actual_credits" real;
2123
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2124
+ ALTER TABLE "native_usage_observations" ADD COLUMN IF NOT EXISTS "created_at" text;
2125
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "id" text;
2126
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "key" text;
2127
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "resource" text;
2128
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "action" text;
2129
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "scope" text;
2130
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "description" text;
2131
+ ALTER TABLE "permissions" ADD COLUMN IF NOT EXISTS "created_at" text;
2132
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "id" text;
2133
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "operation_id" text;
2134
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2135
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "kind" text;
2136
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "data_json" text DEFAULT '{}';
2137
+ ALTER TABLE "platform_operation_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2138
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "id" text;
2139
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "namespace" text;
2140
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "operation" text;
2141
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "status" text;
2142
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "target" text;
2143
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2144
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "input_json" text DEFAULT '{}';
2145
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "output_json" text;
2146
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "error_json" text;
2147
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "requested_by_type" text;
2148
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
2149
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "assigned_runner_id" text;
2150
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2151
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "created_at" text;
2152
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "updated_at" text;
2153
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "started_at" text;
2154
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "finished_at" text;
2155
+ ALTER TABLE "platform_operations" ADD COLUMN IF NOT EXISTS "cancelled_at" text;
2156
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "id" text;
2157
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "repository_key" text;
2158
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "runner_id" text;
2159
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "workspace_path" text;
2160
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "branch" text;
2161
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "commit_sha" text;
2162
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "claim_state" text DEFAULT 'active';
2163
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2164
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2165
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "created_at" text;
2166
+ ALTER TABLE "platform_repository_claims" ADD COLUMN IF NOT EXISTS "updated_at" text;
2167
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "id" text;
2168
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "project_id" text;
2169
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "model" text;
2170
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "subject_id" text;
2171
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "priority" real DEFAULT 0;
2172
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "estimated_credits" real;
2173
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2174
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "created_at" text;
2175
+ ALTER TABLE "priority_overrides" ADD COLUMN IF NOT EXISTS "updated_at" text;
2176
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "id" text;
2177
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "project_id" text;
2178
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2179
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "snapshot_json" text;
2180
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2181
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "generated_at" text;
2182
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "created_at" text;
2183
+ ALTER TABLE "priority_snapshots" ADD COLUMN IF NOT EXISTS "updated_at" text;
2184
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "id" text;
2185
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "project_id" text;
2186
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "label" text;
2187
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "namespace" text;
2188
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "operation" text;
2189
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "execution_class" text;
2190
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "allowed_targets_json" text;
2191
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "default_dispatch_mode" text;
2192
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "approval_policy_json" text DEFAULT '{}';
2193
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "resource_scope_json" text DEFAULT '{}';
2194
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2195
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "enabled" integer DEFAULT 1;
2196
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "created_at" text;
2197
+ ALTER TABLE "project_capability_grants" ADD COLUMN IF NOT EXISTS "updated_at" text;
2198
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "id" text;
2199
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "project_id" text;
2200
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "mode" text;
2201
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "project_api_base_url" text;
2202
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "execution_owner" text;
2203
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_registration_state" text DEFAULT 'pending';
2204
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_key_prefix" text;
2205
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_key_hash" text;
2206
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_registered_at" text;
2207
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "runner_last_seen_at" text;
2208
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2209
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "created_at" text;
2210
+ ALTER TABLE "project_connections" ADD COLUMN IF NOT EXISTS "updated_at" text;
2211
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "id" text;
2212
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "project_id" text;
2213
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "environment" text;
2214
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "deployment_kind" text;
2215
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "status" text;
2216
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "source_ref" text;
2217
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "release_tag" text;
2218
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "commit_sha" text;
2219
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "triggered_by_type" text;
2220
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "triggered_by_id" text;
2221
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2222
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "started_at" text;
2223
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "finished_at" text;
2224
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "created_at" text;
2225
+ ALTER TABLE "project_deployments" ADD COLUMN IF NOT EXISTS "updated_at" text;
2226
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "id" text;
2227
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "project_id" text;
2228
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "environment" text;
2229
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "deployment_profile" text;
2230
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "base_url" text;
2231
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "cloudflare_account_id" text;
2232
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "pages_project_name" text;
2233
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "worker_name" text;
2234
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "r2_bucket_name" text;
2235
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "d1_database_name" text;
2236
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "queue_name" text;
2237
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "railway_project_name" text;
2238
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2239
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "created_at" text;
2240
+ ALTER TABLE "project_environments" ADD COLUMN IF NOT EXISTS "updated_at" text;
2241
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "id" text;
2242
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "project_id" text;
2243
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "hosting_kind" text;
2244
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "registration" text DEFAULT 'none';
2245
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "market_base_url" text;
2246
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_owner" text;
2247
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_name" text;
2248
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_url" text;
2249
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "source_repo_workflow_path" text;
2250
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2251
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "created_at" text;
2252
+ ALTER TABLE "project_hosting" ADD COLUMN IF NOT EXISTS "updated_at" text;
2253
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "id" text;
2254
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "project_id" text;
2255
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "environment" text;
2256
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "provider" text;
2257
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "resource_kind" text;
2258
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "logical_name" text;
2259
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "locator" text;
2260
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2261
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "created_at" text;
2262
+ ALTER TABLE "project_infrastructure_resources" ADD COLUMN IF NOT EXISTS "updated_at" text;
2263
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "project_id" text;
2264
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "team_id" text;
2265
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "summary_json" text;
2266
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "generated_at" text;
2267
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "created_at" text;
2268
+ ALTER TABLE "project_summary_snapshots" ADD COLUMN IF NOT EXISTS "updated_at" text;
2269
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "id" text;
2270
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "hub_id" text;
2271
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "team_id" text;
2272
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_kind" text;
2273
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_ref" text;
2274
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "source_version" text;
2275
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "plan_json" text DEFAULT '{}';
2276
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'planned';
2277
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "requires_decision" integer DEFAULT 0;
2278
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "decision_id" text;
2279
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "created_by" text;
2280
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "created_at" text;
2281
+ ALTER TABLE "project_update_plans" ADD COLUMN IF NOT EXISTS "updated_at" text;
2282
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "id" text;
2283
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "project_id" text;
2284
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "environment" text;
2285
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2286
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "kind" text;
2287
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "state" text;
2288
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "started_at" text;
2289
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "ended_at" text;
2290
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "summary_json" text;
2291
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2292
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "created_at" text;
2293
+ ALTER TABLE "project_workday_summaries" ADD COLUMN IF NOT EXISTS "updated_at" text;
2294
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "id" text;
2295
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "team_id" text;
2296
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "slug" text;
2297
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "name" text;
2298
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "description" text;
2299
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2300
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "created_at" text;
2301
+ ALTER TABLE "projects" ADD COLUMN IF NOT EXISTS "updated_at" text;
2302
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "id" text;
2303
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "team_id" text;
2304
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "project_id" text;
2305
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "job_id" text;
2306
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "host_kind" text;
2307
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "host_id" text;
2308
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "purpose" text;
2309
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2310
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2311
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
2312
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "consumed_at" text;
2313
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2314
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
2315
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
2316
+ ALTER TABLE "provider_credential_sessions" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2317
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "id" text;
2318
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "job_id" text;
2319
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2320
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "kind" text;
2321
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "data_json" text;
2322
+ ALTER TABLE "remote_job_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2323
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "id" text;
2324
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "project_id" text;
2325
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "namespace" text;
2326
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "operation" text;
2327
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "status" text;
2328
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "preferred_mode" text;
2329
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "selected_target" text;
2330
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "capability_json" text;
2331
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "input_json" text;
2332
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "output_json" text;
2333
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "error_json" text;
2334
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "requested_by_type" text;
2335
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "requested_by_id" text;
2336
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "assigned_runner_id" text;
2337
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2338
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "created_at" text;
2339
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2340
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "started_at" text;
2341
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "finished_at" text;
2342
+ ALTER TABLE "remote_jobs" ADD COLUMN IF NOT EXISTS "cancelled_at" text;
2343
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "id" text;
2344
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2345
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "kind" text;
2346
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "body_json" text;
2347
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "rendered_ref" text;
2348
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "sent_at" text;
2349
+ ALTER TABLE "reports" ADD COLUMN IF NOT EXISTS "created_at" text;
2350
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "id" text;
2351
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "project_id" text;
2352
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "repository_id" text;
2353
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "runner_id" text;
2354
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2355
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "volume_identity" text;
2356
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "last_seen_commit" text;
2357
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "last_task_at" text;
2358
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "claim_state" text DEFAULT 'active';
2359
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2360
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "created_at" text;
2361
+ ALTER TABLE "repository_claims" ADD COLUMN IF NOT EXISTS "updated_at" text;
2362
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "id" text;
2363
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "team_id" text;
2364
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "provider" text;
2365
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "ownership" text;
2366
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "name" text;
2367
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "account_label" text;
2368
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "organization_or_owner" text;
2369
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "default_visibility" text DEFAULT 'private';
2370
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "software_repository_name_template" text DEFAULT '{hub}-site';
2371
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "content_repository_name_template" text DEFAULT '{hub}-content';
2372
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "branch_policy_json" text DEFAULT '{}';
2373
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "workflow_policy_json" text DEFAULT '{}';
2374
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2375
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "allowed_project_kinds_json" text DEFAULT '["knowledge_hub"]';
2376
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2377
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2378
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2379
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "updated_by_id" text;
2380
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
2381
+ ALTER TABLE "repository_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
2382
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "role_id" text;
2383
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "permission_id" text;
2384
+ ALTER TABLE "role_permissions" ADD COLUMN IF NOT EXISTS "created_at" text;
2385
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "id" text;
2386
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "key" text;
2387
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "description" text;
2388
+ ALTER TABLE "roles" ADD COLUMN IF NOT EXISTS "created_at" text;
2389
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
2390
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
2391
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
2392
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2393
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "runner_id" text;
2394
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2395
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "action" text;
2396
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
2397
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2398
+ ALTER TABLE "runner_scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
2399
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "id" integer;
2400
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "record_type" text;
2401
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "payload_json" text;
2402
+ ALTER TABLE "runtime_envelopes" ADD COLUMN IF NOT EXISTS "created_at" text;
2403
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "id" integer;
2404
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "record_type" text;
2405
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "record_key" text;
2406
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "lookup_key" text;
2407
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "secondary_key" text;
2408
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "status" text;
2409
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "schema_version" integer DEFAULT 1;
2410
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "created_at" text;
2411
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "updated_at" text;
2412
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "payload_json" text;
2413
+ ALTER TABLE "runtime_records" ADD COLUMN IF NOT EXISTS "meta_json" text;
2414
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "id" text;
2415
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "project_id" text;
2416
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "environment" text;
2417
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "pool_name" text;
2418
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2419
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "desired_workers" integer;
2420
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "observed_queue_depth" integer DEFAULT 0;
2421
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "observed_active_leases" integer DEFAULT 0;
2422
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "reason" text;
2423
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2424
+ ALTER TABLE "scale_decisions" ADD COLUMN IF NOT EXISTS "created_at" text;
2425
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "id" text;
2426
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "seed_name" text;
2427
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "seed_version" integer;
2428
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "environments_json" text;
2429
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "mode" text;
2430
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "state" text;
2431
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "actor_type" text;
2432
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "actor_id" text;
2433
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "manifest_hash" text;
2434
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "plan_json" text;
2435
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "result_json" text;
2436
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "error_json" text;
2437
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "created_at" text;
2438
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "updated_at" text;
2439
+ ALTER TABLE "seed_runs" ADD COLUMN IF NOT EXISTS "completed_at" text;
2440
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "id" text;
2441
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "service_id" text;
2442
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "name" text;
2443
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "secret_hash" text;
2444
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "roles_json" text;
2445
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "permissions_json" text;
2446
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2447
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "created_at" text;
2448
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "updated_at" text;
2449
+ ALTER TABLE "service_credentials" ADD COLUMN IF NOT EXISTS "last_used_at" text;
2450
+ ALTER TABLE "subscribers" ADD COLUMN IF NOT EXISTS "email" text;
2451
+ ALTER TABLE "subscribers" ADD COLUMN IF NOT EXISTS "created_at" text;
2452
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "id" text;
2453
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "project_id" text;
2454
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2455
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "task_id" text;
2456
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "phase" text;
2457
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "credits" real;
2458
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2459
+ ALTER TABLE "task_credit_ledger" ADD COLUMN IF NOT EXISTS "created_at" text;
2460
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "task_signature" text;
2461
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2462
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "sample_count" integer DEFAULT 0;
2463
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "completed_sample_count" integer DEFAULT 0;
2464
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "interrupted_sample_count" integer DEFAULT 0;
2465
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "input_tokens_p50" integer;
2466
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "input_tokens_p90" integer;
2467
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "output_tokens_p50" integer;
2468
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "output_tokens_p90" integer;
2469
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "quota_minutes_p50" real;
2470
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "quota_minutes_p90" real;
2471
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "files_changed_p50" real;
2472
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "files_changed_p90" real;
2473
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_p50" real;
2474
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_p90" real;
2475
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "credits_variance" real;
2476
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "confidence_score" real;
2477
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "outlier_count" integer DEFAULT 0;
2478
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "partial_credits" real;
2479
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "first_sample_at" text;
2480
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "last_sample_at" text;
2481
+ ALTER TABLE "task_estimate_profiles" ADD COLUMN IF NOT EXISTS "updated_at" text;
2482
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "id" text;
2483
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "task_id" text;
2484
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2485
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "project_id" text;
2486
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimate_phase" text;
2487
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "task_signature" text;
2488
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "confidence" text;
2489
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_credits_p50" real;
2490
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_credits_p90" real;
2491
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "reserved_credits" real;
2492
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_input_tokens_p50" integer;
2493
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_input_tokens_p90" integer;
2494
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_output_tokens_p50" integer;
2495
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_output_tokens_p90" integer;
2496
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_quota_minutes_p50" real;
2497
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "estimated_quota_minutes_p90" real;
2498
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "features_json" text DEFAULT '{}';
2499
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "created_at" text;
2500
+ ALTER TABLE "task_estimates" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2501
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "id" text;
2502
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "task_id" text;
2503
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "seq" integer;
2504
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "kind" text;
2505
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "data_json" text;
2506
+ ALTER TABLE "task_events" ADD COLUMN IF NOT EXISTS "created_at" text;
2507
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "id" text;
2508
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "task_id" text;
2509
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "output_json" text;
2510
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "output_ref" text;
2511
+ ALTER TABLE "task_outputs" ADD COLUMN IF NOT EXISTS "created_at" text;
2512
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "id" text;
2513
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "task_id" text;
2514
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2515
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "project_id" text;
2516
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "task_signature" text;
2517
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "capacity_provider_id" text;
2518
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "execution_provider_id" text;
2519
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "lane_id" text;
2520
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "business_model" text;
2521
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "model_name" text;
2522
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "input_tokens" integer;
2523
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "output_tokens" integer;
2524
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "cached_input_tokens" integer;
2525
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "quota_minutes" real;
2526
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "wall_minutes" real;
2527
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "files_opened" integer;
2528
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "files_changed" integer;
2529
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "diff_lines_added" integer;
2530
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "diff_lines_removed" integer;
2531
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "test_runs" integer;
2532
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "retry_count" integer;
2533
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_credits" real;
2534
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_usd" real;
2535
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "credit_formula_version" text DEFAULT 'treeseed.actual-credits.v1';
2536
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "actual_credit_source" text DEFAULT 'central_calculator';
2537
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "native_usage_json" text DEFAULT '{}';
2538
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2539
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "created_at" text;
2540
+ ALTER TABLE "task_usage_actuals" ADD COLUMN IF NOT EXISTS "execution_profile_id" text DEFAULT 'standard-code-model';
2541
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "id" text;
2542
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2543
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "agent_id" text;
2544
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "type" text;
2545
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "state" text;
2546
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "priority" integer DEFAULT 0;
2547
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "idempotency_key" text;
2548
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "payload_json" text;
2549
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "payload_hash" text;
2550
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "attempt_count" integer DEFAULT 0;
2551
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "max_attempts" integer DEFAULT 3;
2552
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "claimed_by" text;
2553
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "lease_expires_at" text;
2554
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "available_at" text;
2555
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "last_error_code" text;
2556
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "last_error_message" text;
2557
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "graph_version" text;
2558
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "parent_task_id" text;
2559
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "created_at" text;
2560
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "started_at" text;
2561
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "completed_at" text;
2562
+ ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "updated_at" text;
2563
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "id" text;
2564
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "team_id" text;
2565
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "name" text;
2566
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "key_prefix" text;
2567
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "key_hash" text;
2568
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "permissions_json" text;
2569
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "expires_at" text;
2570
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "last_used_at" text;
2571
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2572
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "created_at" text;
2573
+ ALTER TABLE "team_api_keys" ADD COLUMN IF NOT EXISTS "updated_at" text;
2574
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "id" text;
2575
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "team_id" text;
2576
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "project_id" text;
2577
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "kind" text;
2578
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "state" text;
2579
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "title" text;
2580
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "summary" text;
2581
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "href" text;
2582
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "item_key" text;
2583
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "metadata_json" text DEFAULT '{}';
2584
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "created_at" text;
2585
+ ALTER TABLE "team_inbox_items" ADD COLUMN IF NOT EXISTS "updated_at" text;
2586
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "id" text;
2587
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "team_id" text;
2588
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "email" text;
2589
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "role_key" text;
2590
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "token_prefix" text;
2591
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "token_hash" text;
2592
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'pending';
2593
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "invited_by_user_id" text;
2594
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "accepted_by_user_id" text;
2595
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "accepted_at" text;
2596
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "expires_at" text;
2597
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "created_at" text;
2598
+ ALTER TABLE "team_invites" ADD COLUMN IF NOT EXISTS "updated_at" text;
2599
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "id" text;
2600
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "team_id" text;
2601
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "user_id" text;
2602
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2603
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "created_at" text;
2604
+ ALTER TABLE "team_memberships" ADD COLUMN IF NOT EXISTS "updated_at" text;
2605
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "id" text;
2606
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "team_membership_id" text;
2607
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "role_id" text;
2608
+ ALTER TABLE "team_role_bindings" ADD COLUMN IF NOT EXISTS "created_at" text;
2609
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "id" text;
2610
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "team_id" text;
2611
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "bucket_name" text;
2612
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "manifest_key_template" text;
2613
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "preview_root_template" text;
2614
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "public_base_url" text;
2615
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2616
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "created_at" text;
2617
+ ALTER TABLE "team_storage_locators" ADD COLUMN IF NOT EXISTS "updated_at" text;
2618
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "id" text;
2619
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "team_id" text;
2620
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "provider" text;
2621
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "ownership" text;
2622
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "name" text;
2623
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "account_label" text;
2624
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "allowed_environments_json" text DEFAULT '[]';
2625
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2626
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "encrypted_payload_json" text;
2627
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2628
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "created_by_id" text;
2629
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "updated_by_id" text;
2630
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "created_at" text;
2631
+ ALTER TABLE "team_web_hosts" ADD COLUMN IF NOT EXISTS "updated_at" text;
2632
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "id" text;
2633
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "slug" text;
2634
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "name" text;
2635
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2636
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "created_at" text;
2637
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "updated_at" text;
2638
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "display_name" text;
2639
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "logo_url" text;
2640
+ ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "profile_summary" text;
2641
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "id" text;
2642
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "user_id" text;
2643
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "provider" text;
2644
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "provider_subject" text;
2645
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "email" text;
2646
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "email_verified" integer DEFAULT 0;
2647
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "profile_json" text;
2648
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "created_at" text;
2649
+ ALTER TABLE "user_identities" ADD COLUMN IF NOT EXISTS "updated_at" text;
2650
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "user_id" text;
2651
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "color_scheme" text DEFAULT 'fern';
2652
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "theme_mode" text DEFAULT 'system';
2653
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "created_at" text;
2654
+ ALTER TABLE "user_preferences" ADD COLUMN IF NOT EXISTS "updated_at" text;
2655
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "id" text;
2656
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "user_id" text;
2657
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "role_id" text;
2658
+ ALTER TABLE "user_role_bindings" ADD COLUMN IF NOT EXISTS "created_at" text;
2659
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "id" text;
2660
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "email" text;
2661
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "display_name" text;
2662
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "status" text DEFAULT 'active';
2663
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2664
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "created_at" text;
2665
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "updated_at" text;
2666
+ ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "username" text;
2667
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "id" text;
2668
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "user_id" text;
2669
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "identity_id" text;
2670
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "better_auth_session_id" text;
2671
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "provider" text;
2672
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "provider_subject" text;
2673
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "email" text;
2674
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "display_name" text;
2675
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "principal_json" text;
2676
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "csrf_token" text;
2677
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "ip_address" text;
2678
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "user_agent" text;
2679
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "authenticated_at" text;
2680
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "last_seen_at" text;
2681
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "expires_at" text;
2682
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "revoked_at" text;
2683
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "created_at" text;
2684
+ ALTER TABLE "web_sessions" ADD COLUMN IF NOT EXISTS "updated_at" text;
2685
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "id" text;
2686
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "project_id" text;
2687
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "state" text;
2688
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "capacity_budget" integer DEFAULT 0;
2689
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "capacity_used" integer DEFAULT 0;
2690
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "graph_version" text;
2691
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "summary_json" text;
2692
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "started_at" text;
2693
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "ended_at" text;
2694
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "created_at" text;
2695
+ ALTER TABLE "work_days" ADD COLUMN IF NOT EXISTS "updated_at" text;
2696
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "project_id" text;
2697
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "environment" text;
2698
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "schedule_json" text;
2699
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "daily_task_credit_budget" integer DEFAULT 0;
2700
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_queued_tasks" integer DEFAULT 0;
2701
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_queued_credits" integer DEFAULT 0;
2702
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "autoscale_json" text;
2703
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "credit_weights_json" text;
2704
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2705
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "created_at" text;
2706
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "updated_at" text;
2707
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "enabled" integer DEFAULT 1;
2708
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "start_cron" text DEFAULT '0 9 * * 1-5';
2709
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "duration_minutes" integer DEFAULT 480;
2710
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_runners" integer DEFAULT 1;
2711
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "max_workers_per_runner" integer DEFAULT 4;
2712
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "daily_credit_budget" integer DEFAULT 0;
2713
+ ALTER TABLE "work_policies" ADD COLUMN IF NOT EXISTS "closeout_grace_minutes" integer DEFAULT 15;
2714
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "id" text;
2715
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "project_id" text;
2716
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "environment" text;
2717
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2718
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "manager_id" text;
2719
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
2720
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "heartbeat_at" text;
2721
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "expires_at" text;
2722
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2723
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "created_at" text;
2724
+ ALTER TABLE "workday_manager_leases" ADD COLUMN IF NOT EXISTS "updated_at" text;
2725
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "id" text;
2726
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "project_id" text;
2727
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "environment" text;
2728
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "type" text;
2729
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'pending';
2730
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "work_day_id" text;
2731
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "requested_by" text;
2732
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "reason" text;
2733
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "payload_json" text;
2734
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2735
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "created_at" text;
2736
+ ALTER TABLE "workday_requests" ADD COLUMN IF NOT EXISTS "updated_at" text;
2737
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "id" text;
2738
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "project_id" text;
2739
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "environment" text;
2740
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "runner_id" text;
2741
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "runner_service_name" text;
2742
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "volume_identity" text;
2743
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "state" text DEFAULT 'active';
2744
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "max_local_workers" integer DEFAULT 4;
2745
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "active_local_workers" integer DEFAULT 0;
2746
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "available_capacity" integer DEFAULT 4;
2747
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "last_heartbeat_at" text;
2748
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "claimed_repository_ids_json" text;
2749
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "metadata_json" text;
2750
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "created_at" text;
2751
+ ALTER TABLE "worker_runners" ADD COLUMN IF NOT EXISTS "updated_at" text;
2752
+ -- End Treeseed Market schema adoption columns
2753
+
2754
+ CREATE INDEX IF NOT EXISTS "idx_agent_pool_registrations_pool_heartbeat" ON "agent_pool_registrations" USING btree ("pool_id","heartbeat_at");
2755
+ CREATE INDEX IF NOT EXISTS "idx_agent_pool_scale_decisions_pool_created" ON "agent_pool_scale_decisions" USING btree ("pool_id","created_at");
2756
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_agent_pools_project_environment_name" ON "agent_pools" USING btree ("project_id","environment","name");
2757
+ CREATE INDEX IF NOT EXISTS "idx_api_tokens_user_id" ON "api_tokens" USING btree ("user_id");
2758
+ CREATE INDEX IF NOT EXISTS "idx_api_tokens_prefix" ON "api_tokens" USING btree ("token_prefix");
2759
+ CREATE INDEX IF NOT EXISTS "idx_approval_requests_team_state" ON "approval_requests" USING btree ("team_id","state","created_at");
2760
+ CREATE INDEX IF NOT EXISTS "idx_approval_requests_project_workday" ON "approval_requests" USING btree ("project_id","work_day_id","state","created_at");
2761
+ CREATE INDEX IF NOT EXISTS "idx_audit_events_target" ON "audit_events" USING btree ("target_type","target_id");
2762
+ CREATE INDEX IF NOT EXISTS "idx_auth_sessions_user_id" ON "auth_sessions" USING btree ("user_id");
2763
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_account_userId" ON "better_auth_account" USING btree ("userId");
2764
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_better_auth_account_provider_account" ON "better_auth_account" USING btree ("providerId","accountId");
2765
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_session_token" ON "better_auth_session" USING btree ("token");
2766
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_session_userId" ON "better_auth_session" USING btree ("userId");
2767
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_better_auth_user_username" ON "better_auth_user" USING btree ("username");
2768
+ CREATE INDEX IF NOT EXISTS "idx_better_auth_verification_identifier" ON "better_auth_verification" USING btree ("identifier");
2769
+ CREATE INDEX IF NOT EXISTS "idx_capacity_grants_team_project" ON "capacity_grants" USING btree ("team_id","project_id","state");
2770
+ CREATE INDEX IF NOT EXISTS "idx_capacity_grants_provider_lane" ON "capacity_grants" USING btree ("capacity_provider_id","lane_id","state");
2771
+ CREATE INDEX IF NOT EXISTS "idx_capacity_ledger_project_workday_created" ON "capacity_ledger_entries" USING btree ("project_id","work_day_id","created_at");
2772
+ 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");
2773
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_api_keys_prefix" ON "capacity_provider_api_keys" USING btree ("key_prefix");
2774
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_deployments_provider_created" ON "capacity_provider_deployments" USING btree ("capacity_provider_id","created_at");
2775
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_capacity_provider_hosts_unique" ON "capacity_provider_hosts" USING btree ("capacity_provider_id","host_id","role");
2776
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_lanes_provider" ON "capacity_provider_lanes" USING btree ("capacity_provider_id","business_model","scarcity_level");
2777
+ CREATE INDEX IF NOT EXISTS "idx_capacity_provider_registrations_provider_seen" ON "capacity_provider_registrations" USING btree ("capacity_provider_id","last_seen_at");
2778
+ CREATE INDEX IF NOT EXISTS "idx_capacity_providers_team_status" ON "capacity_providers" USING btree ("team_id","status","provider");
2779
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_project_workday_state" ON "capacity_reservations" USING btree ("project_id","work_day_id","state","created_at");
2780
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_provider_state" ON "capacity_reservations" USING btree ("capacity_provider_id","lane_id","state");
2781
+ CREATE INDEX IF NOT EXISTS "idx_capacity_reservations_execution_provider_state" ON "capacity_reservations" USING btree ("execution_provider_id","state","created_at");
2782
+ CREATE INDEX IF NOT EXISTS "idx_capacity_routing_decisions_project_workday" ON "capacity_routing_decisions" USING btree ("project_id","work_day_id","created_at");
2783
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_catalog_artifact_versions_item_version" ON "catalog_artifact_versions" USING btree ("item_id","version");
2784
+ CREATE INDEX IF NOT EXISTS "idx_catalog_artifact_versions_team_kind" ON "catalog_artifact_versions" USING btree ("team_id","kind","published_at");
2785
+ 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");
2786
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_catalog_items_kind_slug" ON "catalog_items" USING btree ("kind","slug");
2787
+ CREATE INDEX IF NOT EXISTS "idx_catalog_items_team_kind" ON "catalog_items" USING btree ("team_id","kind","updated_at");
2788
+ CREATE INDEX IF NOT EXISTS "idx_catalog_items_visibility_listing" ON "catalog_items" USING btree ("visibility","listing_enabled","updated_at");
2789
+ 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");
2790
+ CREATE INDEX IF NOT EXISTS "idx_credit_conversion_profiles_kind_unit" ON "credit_conversion_profiles" USING btree ("execution_provider_kind","native_unit","updated_at");
2791
+ CREATE INDEX IF NOT EXISTS "idx_cursor_state_updated" ON "cursor_state" USING btree ("updated_at");
2792
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_entitlements_project" ON "entitlements" USING btree ("project_id");
2793
+ 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");
2794
+ CREATE INDEX IF NOT EXISTS "idx_execution_provider_observations_provider_observed" ON "execution_provider_observations" USING btree ("execution_provider_id","observed_at");
2795
+ CREATE INDEX IF NOT EXISTS "idx_execution_providers_team_status" ON "execution_providers" USING btree ("team_id","status","kind");
2796
+ CREATE INDEX IF NOT EXISTS "idx_execution_providers_capacity_provider" ON "execution_providers" USING btree ("capacity_provider_id","status");
2797
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_hub_launch_events_launch_seq" ON "hub_launch_events" USING btree ("launch_id","seq");
2798
+ CREATE INDEX IF NOT EXISTS "idx_hub_launches_hub_created" ON "hub_launches" USING btree ("hub_id","created_at");
2799
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_hub_repositories_hub_role" ON "hub_repositories" USING btree ("hub_id","role");
2800
+ CREATE INDEX IF NOT EXISTS "idx_hub_workspace_links_hub" ON "hub_workspace_links" USING btree ("hub_id");
2801
+ CREATE INDEX IF NOT EXISTS "idx_knowledge_packs_team_id" ON "knowledge_packs" USING btree ("team_id");
2802
+ CREATE INDEX IF NOT EXISTS "idx_lease_state_status_expires" ON "lease_state" USING btree ("status","lease_expires_at");
2803
+ CREATE INDEX IF NOT EXISTS "idx_lease_state_claimed_by" ON "lease_state" USING btree ("claimed_by","updated_at");
2804
+ CREATE INDEX IF NOT EXISTS "idx_message_queue_claimable" ON "message_queue" USING btree ("status","available_at","priority");
2805
+ CREATE INDEX IF NOT EXISTS "idx_message_queue_related" ON "message_queue" USING btree ("related_model","related_id","created_at");
2806
+ 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");
2807
+ CREATE INDEX IF NOT EXISTS "idx_native_usage_observations_provider" ON "native_usage_observations" USING btree ("execution_provider_id","created_at");
2808
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_operation_events_seq" ON "platform_operation_events" USING btree ("operation_id","seq");
2809
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_operations_idempotency" ON "platform_operations" USING btree ("namespace","operation","idempotency_key");
2810
+ CREATE INDEX IF NOT EXISTS "idx_platform_operations_runnable" ON "platform_operations" USING btree ("status","created_at");
2811
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_platform_repository_claims_active" ON "platform_repository_claims" USING btree ("repository_key","runner_id");
2812
+ CREATE INDEX IF NOT EXISTS "idx_platform_repository_claims_runner" ON "platform_repository_claims" USING btree ("runner_id","claim_state");
2813
+ CREATE INDEX IF NOT EXISTS "idx_priority_overrides_project_priority" ON "priority_overrides" USING btree ("project_id","priority","updated_at");
2814
+ CREATE INDEX IF NOT EXISTS "idx_priority_snapshots_project_generated" ON "priority_snapshots" USING btree ("project_id","generated_at");
2815
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_capability_grants_project_operation" ON "project_capability_grants" USING btree ("project_id","namespace","operation");
2816
+ CREATE INDEX IF NOT EXISTS "idx_project_deployments_project_environment" ON "project_deployments" USING btree ("project_id","environment","created_at");
2817
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_project_environments_project_environment" ON "project_environments" USING btree ("project_id","environment");
2818
+ 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");
2819
+ CREATE INDEX IF NOT EXISTS "idx_project_summary_snapshots_team_generated" ON "project_summary_snapshots" USING btree ("team_id","generated_at");
2820
+ CREATE INDEX IF NOT EXISTS "idx_project_update_plans_hub" ON "project_update_plans" USING btree ("hub_id","created_at");
2821
+ CREATE INDEX IF NOT EXISTS "idx_project_workday_summaries_project_environment_created" ON "project_workday_summaries" USING btree ("project_id","environment","created_at");
2822
+ CREATE INDEX IF NOT EXISTS "idx_projects_team_id" ON "projects" USING btree ("team_id");
2823
+ CREATE INDEX IF NOT EXISTS "idx_provider_credential_sessions_team_host" ON "provider_credential_sessions" USING btree ("team_id","host_kind","host_id","status");
2824
+ CREATE INDEX IF NOT EXISTS "idx_provider_credential_sessions_job" ON "provider_credential_sessions" USING btree ("job_id","status");
2825
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_remote_job_events_job_seq" ON "remote_job_events" USING btree ("job_id","seq");
2826
+ CREATE INDEX IF NOT EXISTS "idx_remote_jobs_project_status" ON "remote_jobs" USING btree ("project_id","status","created_at");
2827
+ CREATE INDEX IF NOT EXISTS "idx_remote_jobs_project_idempotency" ON "remote_jobs" USING btree ("project_id","idempotency_key");
2828
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_claims_runner_repo" ON "repository_claims" USING btree ("project_id","repository_id","runner_id");
2829
+ CREATE INDEX IF NOT EXISTS "idx_repository_claims_repo_state" ON "repository_claims" USING btree ("project_id","repository_id","claim_state","updated_at");
2830
+ CREATE INDEX IF NOT EXISTS "idx_repository_hosts_team_provider" ON "repository_hosts" USING btree ("team_id","provider","status");
2831
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_hosts_team_provider_name" ON "repository_hosts" USING btree ("team_id","provider","name");
2832
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_repository_hosts_platform_provider_name" ON "repository_hosts" USING btree ("provider","name");
2833
+ 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");
2834
+ CREATE INDEX IF NOT EXISTS "idx_runtime_records_type_lookup_updated" ON "runtime_records" USING btree ("record_type","lookup_key","updated_at");
2835
+ CREATE INDEX IF NOT EXISTS "idx_runtime_records_type_status_updated" ON "runtime_records" USING btree ("record_type","status","updated_at");
2836
+ CREATE INDEX IF NOT EXISTS "idx_scale_decisions_project_environment_pool_created" ON "scale_decisions" USING btree ("project_id","environment","pool_name","created_at");
2837
+ CREATE INDEX IF NOT EXISTS "idx_seed_runs_seed_created" ON "seed_runs" USING btree ("seed_name","created_at");
2838
+ CREATE INDEX IF NOT EXISTS "idx_seed_runs_state_created" ON "seed_runs" USING btree ("state","created_at");
2839
+ CREATE INDEX IF NOT EXISTS "idx_task_credit_ledger_work_day_created" ON "task_credit_ledger" USING btree ("work_day_id","created_at");
2840
+ CREATE INDEX IF NOT EXISTS "idx_task_estimates_project_signature" ON "task_estimates" USING btree ("project_id","task_signature","created_at");
2841
+ 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");
2842
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_task_events_seq" ON "task_events" USING btree ("task_id","seq");
2843
+ CREATE INDEX IF NOT EXISTS "idx_task_usage_actuals_project_signature" ON "task_usage_actuals" USING btree ("project_id","task_signature","created_at");
2844
+ 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");
2845
+ CREATE INDEX IF NOT EXISTS "idx_task_usage_actuals_execution_provider" ON "task_usage_actuals" USING btree ("execution_provider_id","created_at");
2846
+ CREATE INDEX IF NOT EXISTS "idx_tasks_runnable" ON "tasks" USING btree ("state","priority","available_at");
2847
+ CREATE INDEX IF NOT EXISTS "idx_tasks_work_day_agent" ON "tasks" USING btree ("work_day_id","agent_id","created_at");
2848
+ CREATE INDEX IF NOT EXISTS "idx_team_api_keys_prefix" ON "team_api_keys" USING btree ("key_prefix");
2849
+ CREATE INDEX IF NOT EXISTS "idx_team_inbox_items_team_created" ON "team_inbox_items" USING btree ("team_id","created_at");
2850
+ CREATE INDEX IF NOT EXISTS "idx_team_invites_team_status" ON "team_invites" USING btree ("team_id","status","created_at");
2851
+ CREATE INDEX IF NOT EXISTS "idx_team_invites_token_prefix" ON "team_invites" USING btree ("token_prefix");
2852
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_team_memberships_team_user" ON "team_memberships" USING btree ("team_id","user_id");
2853
+ CREATE INDEX IF NOT EXISTS "idx_team_web_hosts_team_provider" ON "team_web_hosts" USING btree ("team_id","provider","status");
2854
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_team_web_hosts_team_provider_name" ON "team_web_hosts" USING btree ("team_id","provider","name");
2855
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_teams_name" ON "teams" USING btree ("name");
2856
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_identities_provider_subject" ON "user_identities" USING btree ("provider","provider_subject");
2857
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_role_bindings_user_role" ON "user_role_bindings" USING btree ("user_id","role_id");
2858
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_users_username" ON "users" USING btree ("username");
2859
+ CREATE INDEX IF NOT EXISTS "idx_web_sessions_user_id" ON "web_sessions" USING btree ("user_id");
2860
+ CREATE INDEX IF NOT EXISTS "idx_workday_manager_leases_active" ON "workday_manager_leases" USING btree ("project_id","environment","state","heartbeat_at");
2861
+ CREATE INDEX IF NOT EXISTS "idx_workday_requests_project_environment_state" ON "workday_requests" USING btree ("project_id","environment","state","created_at");
2862
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_worker_runners_identity" ON "worker_runners" USING btree ("project_id","environment","runner_id");
2863
+ CREATE INDEX IF NOT EXISTS "idx_worker_runners_state_capacity" ON "worker_runners" USING btree ("project_id","environment","state","available_capacity");