@fidelios/db 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/package.json +1 -1
  2. package/dist/migrations/migrations/0000_mature_masked_marvel.sql +0 -208
  3. package/dist/migrations/migrations/0001_fast_northstar.sql +0 -87
  4. package/dist/migrations/migrations/0002_big_zaladane.sql +0 -1
  5. package/dist/migrations/migrations/0003_shallow_quentin_quire.sql +0 -5
  6. package/dist/migrations/migrations/0004_issue_identifiers.sql +0 -28
  7. package/dist/migrations/migrations/0005_chief_luke_cage.sql +0 -19
  8. package/dist/migrations/migrations/0006_overjoyed_mister_sinister.sql +0 -36
  9. package/dist/migrations/migrations/0007_new_quentin_quire.sql +0 -20
  10. package/dist/migrations/migrations/0008_amused_zzzax.sql +0 -1
  11. package/dist/migrations/migrations/0009_fast_jackal.sql +0 -36
  12. package/dist/migrations/migrations/0010_stale_justin_hammer.sql +0 -37
  13. package/dist/migrations/migrations/0011_windy_corsair.sql +0 -18
  14. package/dist/migrations/migrations/0012_perpetual_ser_duncan.sql +0 -2
  15. package/dist/migrations/migrations/0013_dashing_wasp.sql +0 -4
  16. package/dist/migrations/migrations/0014_many_mikhail_rasputin.sql +0 -135
  17. package/dist/migrations/migrations/0015_project_color_archived.sql +0 -2
  18. package/dist/migrations/migrations/0016_agent_icon.sql +0 -1
  19. package/dist/migrations/migrations/0017_tiresome_gabe_jones.sql +0 -51
  20. package/dist/migrations/migrations/0018_flat_sleepwalker.sql +0 -26
  21. package/dist/migrations/migrations/0019_public_victor_mancha.sql +0 -18
  22. package/dist/migrations/migrations/0020_white_anita_blake.sql +0 -1
  23. package/dist/migrations/migrations/0021_chief_vindicator.sql +0 -1
  24. package/dist/migrations/migrations/0022_company_brand_color.sql +0 -1
  25. package/dist/migrations/migrations/0023_fair_lethal_legion.sql +0 -3
  26. package/dist/migrations/migrations/0024_far_beast.sql +0 -2
  27. package/dist/migrations/migrations/0025_nasty_salo.sql +0 -15
  28. package/dist/migrations/migrations/0026_lying_pete_wisdom.sql +0 -39
  29. package/dist/migrations/migrations/0027_tranquil_tenebrous.sql +0 -2
  30. package/dist/migrations/migrations/0028_harsh_goliath.sql +0 -54
  31. package/dist/migrations/migrations/0029_plugin_tables.sql +0 -177
  32. package/dist/migrations/migrations/0030_rich_magneto.sql +0 -12
  33. package/dist/migrations/migrations/0031_zippy_magma.sql +0 -51
  34. package/dist/migrations/migrations/0032_pretty_doctor_octopus.sql +0 -102
  35. package/dist/migrations/migrations/0033_shiny_black_tarantula.sql +0 -2
  36. package/dist/migrations/migrations/0034_fat_dormammu.sql +0 -2
  37. package/dist/migrations/migrations/0035_marvelous_satana.sql +0 -91
  38. package/dist/migrations/migrations/0036_cheerful_nitro.sql +0 -9
  39. package/dist/migrations/migrations/0037_friendly_eddie_brock.sql +0 -29
  40. package/dist/migrations/migrations/0038_careless_iron_monger.sql +0 -5
  41. package/dist/migrations/migrations/0039_fat_magneto.sql +0 -161
  42. package/dist/migrations/migrations/0040_eager_shotgun.sql +0 -5
  43. package/dist/migrations/migrations/0041_curly_maria_hill.sql +0 -1
  44. package/dist/migrations/migrations/0042_spotty_the_renegades.sql +0 -26
  45. package/dist/migrations/migrations/0043_reflective_captain_universe.sql +0 -6
  46. package/dist/migrations/migrations/0044_illegal_toad.sql +0 -56
  47. package/dist/migrations/migrations/0045_workable_shockwave.sql +0 -17
  48. package/dist/migrations/migrations/meta/0000_snapshot.json +0 -1743
  49. package/dist/migrations/migrations/meta/0001_snapshot.json +0 -2441
  50. package/dist/migrations/migrations/meta/0002_snapshot.json +0 -2454
  51. package/dist/migrations/migrations/meta/0003_snapshot.json +0 -2502
  52. package/dist/migrations/migrations/meta/0005_snapshot.json +0 -2719
  53. package/dist/migrations/migrations/meta/0006_snapshot.json +0 -3048
  54. package/dist/migrations/migrations/meta/0007_snapshot.json +0 -3258
  55. package/dist/migrations/migrations/meta/0008_snapshot.json +0 -3264
  56. package/dist/migrations/migrations/meta/0009_snapshot.json +0 -3587
  57. package/dist/migrations/migrations/meta/0010_snapshot.json +0 -3929
  58. package/dist/migrations/migrations/meta/0011_snapshot.json +0 -4068
  59. package/dist/migrations/migrations/meta/0012_snapshot.json +0 -4087
  60. package/dist/migrations/migrations/meta/0013_snapshot.json +0 -4118
  61. package/dist/migrations/migrations/meta/0014_snapshot.json +0 -5187
  62. package/dist/migrations/migrations/meta/0017_snapshot.json +0 -5215
  63. package/dist/migrations/migrations/meta/0018_snapshot.json +0 -5450
  64. package/dist/migrations/migrations/meta/0019_snapshot.json +0 -5603
  65. package/dist/migrations/migrations/meta/0020_snapshot.json +0 -5603
  66. package/dist/migrations/migrations/meta/0021_snapshot.json +0 -5609
  67. package/dist/migrations/migrations/meta/0023_snapshot.json +0 -5633
  68. package/dist/migrations/migrations/meta/0024_snapshot.json +0 -5693
  69. package/dist/migrations/migrations/meta/0025_snapshot.json +0 -5849
  70. package/dist/migrations/migrations/meta/0027_snapshot.json +0 -6205
  71. package/dist/migrations/migrations/meta/0028_snapshot.json +0 -6710
  72. package/dist/migrations/migrations/meta/0029_snapshot.json +0 -7899
  73. package/dist/migrations/migrations/meta/0030_snapshot.json +0 -8003
  74. package/dist/migrations/migrations/meta/0031_snapshot.json +0 -7242
  75. package/dist/migrations/migrations/meta/0032_snapshot.json +0 -7733
  76. package/dist/migrations/migrations/meta/0033_snapshot.json +0 -9038
  77. package/dist/migrations/migrations/meta/0034_snapshot.json +0 -9039
  78. package/dist/migrations/migrations/meta/0035_snapshot.json +0 -9959
  79. package/dist/migrations/migrations/meta/0036_snapshot.json +0 -10023
  80. package/dist/migrations/migrations/meta/0037_snapshot.json +0 -10263
  81. package/dist/migrations/migrations/meta/0038_snapshot.json +0 -11350
  82. package/dist/migrations/migrations/meta/0039_snapshot.json +0 -10308
  83. package/dist/migrations/migrations/meta/0040_snapshot.json +0 -10481
  84. package/dist/migrations/migrations/meta/0041_snapshot.json +0 -11393
  85. package/dist/migrations/migrations/meta/0044_snapshot.json +0 -11701
  86. package/dist/migrations/migrations/meta/0045_snapshot.json +0 -11857
  87. package/dist/migrations/migrations/meta/_journal.json +0 -328
@@ -1,51 +0,0 @@
1
- CREATE TABLE "finance_events" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "agent_id" uuid,
5
- "issue_id" uuid,
6
- "project_id" uuid,
7
- "goal_id" uuid,
8
- "heartbeat_run_id" uuid,
9
- "cost_event_id" uuid,
10
- "billing_code" text,
11
- "description" text,
12
- "event_kind" text NOT NULL,
13
- "direction" text DEFAULT 'debit' NOT NULL,
14
- "biller" text NOT NULL,
15
- "provider" text,
16
- "execution_adapter_type" text,
17
- "pricing_tier" text,
18
- "region" text,
19
- "model" text,
20
- "quantity" integer,
21
- "unit" text,
22
- "amount_cents" integer NOT NULL,
23
- "currency" text DEFAULT 'USD' NOT NULL,
24
- "estimated" boolean DEFAULT false NOT NULL,
25
- "external_invoice_id" text,
26
- "metadata_json" jsonb,
27
- "occurred_at" timestamp with time zone NOT NULL,
28
- "created_at" timestamp with time zone DEFAULT now() NOT NULL
29
- );
30
- --> statement-breakpoint
31
- ALTER TABLE "cost_events" ADD COLUMN "heartbeat_run_id" uuid;--> statement-breakpoint
32
- ALTER TABLE "cost_events" ADD COLUMN "biller" text DEFAULT 'unknown' NOT NULL;--> statement-breakpoint
33
- ALTER TABLE "cost_events" ADD COLUMN "billing_type" text DEFAULT 'unknown' NOT NULL;--> statement-breakpoint
34
- ALTER TABLE "cost_events" ADD COLUMN "cached_input_tokens" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
35
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
36
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
37
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
38
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
39
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_goal_id_goals_id_fk" FOREIGN KEY ("goal_id") REFERENCES "public"."goals"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
40
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_heartbeat_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("heartbeat_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
41
- ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_cost_event_id_cost_events_id_fk" FOREIGN KEY ("cost_event_id") REFERENCES "public"."cost_events"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
42
- CREATE INDEX "finance_events_company_occurred_idx" ON "finance_events" USING btree ("company_id","occurred_at");--> statement-breakpoint
43
- CREATE INDEX "finance_events_company_biller_occurred_idx" ON "finance_events" USING btree ("company_id","biller","occurred_at");--> statement-breakpoint
44
- CREATE INDEX "finance_events_company_kind_occurred_idx" ON "finance_events" USING btree ("company_id","event_kind","occurred_at");--> statement-breakpoint
45
- CREATE INDEX "finance_events_company_direction_occurred_idx" ON "finance_events" USING btree ("company_id","direction","occurred_at");--> statement-breakpoint
46
- CREATE INDEX "finance_events_company_heartbeat_run_idx" ON "finance_events" USING btree ("company_id","heartbeat_run_id");--> statement-breakpoint
47
- CREATE INDEX "finance_events_company_cost_event_idx" ON "finance_events" USING btree ("company_id","cost_event_id");--> statement-breakpoint
48
- ALTER TABLE "cost_events" ADD CONSTRAINT "cost_events_heartbeat_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("heartbeat_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
49
- CREATE INDEX "cost_events_company_provider_occurred_idx" ON "cost_events" USING btree ("company_id","provider","occurred_at");--> statement-breakpoint
50
- CREATE INDEX "cost_events_company_biller_occurred_idx" ON "cost_events" USING btree ("company_id","biller","occurred_at");--> statement-breakpoint
51
- CREATE INDEX "cost_events_company_heartbeat_run_idx" ON "cost_events" USING btree ("company_id","heartbeat_run_id");
@@ -1,102 +0,0 @@
1
- CREATE TABLE "budget_incidents" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "policy_id" uuid NOT NULL,
5
- "scope_type" text NOT NULL,
6
- "scope_id" uuid NOT NULL,
7
- "metric" text NOT NULL,
8
- "window_kind" text NOT NULL,
9
- "window_start" timestamp with time zone NOT NULL,
10
- "window_end" timestamp with time zone NOT NULL,
11
- "threshold_type" text NOT NULL,
12
- "amount_limit" integer NOT NULL,
13
- "amount_observed" integer NOT NULL,
14
- "status" text DEFAULT 'open' NOT NULL,
15
- "approval_id" uuid,
16
- "resolved_at" timestamp with time zone,
17
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
18
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
19
- );
20
- --> statement-breakpoint
21
- CREATE TABLE "budget_policies" (
22
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
23
- "company_id" uuid NOT NULL,
24
- "scope_type" text NOT NULL,
25
- "scope_id" uuid NOT NULL,
26
- "metric" text DEFAULT 'billed_cents' NOT NULL,
27
- "window_kind" text NOT NULL,
28
- "amount" integer DEFAULT 0 NOT NULL,
29
- "warn_percent" integer DEFAULT 80 NOT NULL,
30
- "hard_stop_enabled" boolean DEFAULT true NOT NULL,
31
- "notify_enabled" boolean DEFAULT true NOT NULL,
32
- "is_active" boolean DEFAULT true NOT NULL,
33
- "created_by_user_id" text,
34
- "updated_by_user_id" text,
35
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
36
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
37
- );
38
- --> statement-breakpoint
39
- ALTER TABLE "agents" ADD COLUMN "pause_reason" text;--> statement-breakpoint
40
- ALTER TABLE "agents" ADD COLUMN "paused_at" timestamp with time zone;--> statement-breakpoint
41
- ALTER TABLE "projects" ADD COLUMN "pause_reason" text;--> statement-breakpoint
42
- ALTER TABLE "projects" ADD COLUMN "paused_at" timestamp with time zone;--> statement-breakpoint
43
- INSERT INTO "budget_policies" (
44
- "company_id",
45
- "scope_type",
46
- "scope_id",
47
- "metric",
48
- "window_kind",
49
- "amount",
50
- "warn_percent",
51
- "hard_stop_enabled",
52
- "notify_enabled",
53
- "is_active"
54
- )
55
- SELECT
56
- "id",
57
- 'company',
58
- "id",
59
- 'billed_cents',
60
- 'calendar_month_utc',
61
- "budget_monthly_cents",
62
- 80,
63
- true,
64
- true,
65
- true
66
- FROM "companies"
67
- WHERE "budget_monthly_cents" > 0;--> statement-breakpoint
68
- INSERT INTO "budget_policies" (
69
- "company_id",
70
- "scope_type",
71
- "scope_id",
72
- "metric",
73
- "window_kind",
74
- "amount",
75
- "warn_percent",
76
- "hard_stop_enabled",
77
- "notify_enabled",
78
- "is_active"
79
- )
80
- SELECT
81
- "company_id",
82
- 'agent',
83
- "id",
84
- 'billed_cents',
85
- 'calendar_month_utc',
86
- "budget_monthly_cents",
87
- 80,
88
- true,
89
- true,
90
- true
91
- FROM "agents"
92
- WHERE "budget_monthly_cents" > 0;--> statement-breakpoint
93
- ALTER TABLE "budget_incidents" ADD CONSTRAINT "budget_incidents_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
94
- ALTER TABLE "budget_incidents" ADD CONSTRAINT "budget_incidents_policy_id_budget_policies_id_fk" FOREIGN KEY ("policy_id") REFERENCES "public"."budget_policies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
95
- ALTER TABLE "budget_incidents" ADD CONSTRAINT "budget_incidents_approval_id_approvals_id_fk" FOREIGN KEY ("approval_id") REFERENCES "public"."approvals"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
96
- ALTER TABLE "budget_policies" ADD CONSTRAINT "budget_policies_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
97
- CREATE INDEX "budget_incidents_company_status_idx" ON "budget_incidents" USING btree ("company_id","status");--> statement-breakpoint
98
- CREATE INDEX "budget_incidents_company_scope_idx" ON "budget_incidents" USING btree ("company_id","scope_type","scope_id","status");--> statement-breakpoint
99
- CREATE UNIQUE INDEX "budget_incidents_policy_window_threshold_idx" ON "budget_incidents" USING btree ("policy_id","window_start","threshold_type");--> statement-breakpoint
100
- CREATE INDEX "budget_policies_company_scope_active_idx" ON "budget_policies" USING btree ("company_id","scope_type","scope_id","is_active");--> statement-breakpoint
101
- CREATE INDEX "budget_policies_company_window_idx" ON "budget_policies" USING btree ("company_id","window_kind","metric");--> statement-breakpoint
102
- CREATE UNIQUE INDEX "budget_policies_company_scope_metric_unique_idx" ON "budget_policies" USING btree ("company_id","scope_type","scope_id","metric","window_kind");
@@ -1,2 +0,0 @@
1
- ALTER TABLE "companies" ADD COLUMN "pause_reason" text;--> statement-breakpoint
2
- ALTER TABLE "companies" ADD COLUMN "paused_at" timestamp with time zone;
@@ -1,2 +0,0 @@
1
- DROP INDEX "budget_incidents_policy_window_threshold_idx";--> statement-breakpoint
2
- CREATE UNIQUE INDEX "budget_incidents_policy_window_threshold_idx" ON "budget_incidents" USING btree ("policy_id","window_start","threshold_type") WHERE "budget_incidents"."status" <> 'dismissed';
@@ -1,91 +0,0 @@
1
- CREATE TABLE "execution_workspaces" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "project_id" uuid NOT NULL,
5
- "project_workspace_id" uuid,
6
- "source_issue_id" uuid,
7
- "mode" text NOT NULL,
8
- "strategy_type" text NOT NULL,
9
- "name" text NOT NULL,
10
- "status" text DEFAULT 'active' NOT NULL,
11
- "cwd" text,
12
- "repo_url" text,
13
- "base_ref" text,
14
- "branch_name" text,
15
- "provider_type" text DEFAULT 'local_fs' NOT NULL,
16
- "provider_ref" text,
17
- "derived_from_execution_workspace_id" uuid,
18
- "last_used_at" timestamp with time zone DEFAULT now() NOT NULL,
19
- "opened_at" timestamp with time zone DEFAULT now() NOT NULL,
20
- "closed_at" timestamp with time zone,
21
- "cleanup_eligible_at" timestamp with time zone,
22
- "cleanup_reason" text,
23
- "metadata" jsonb,
24
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
25
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
26
- );
27
- --> statement-breakpoint
28
- CREATE TABLE "issue_work_products" (
29
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
30
- "company_id" uuid NOT NULL,
31
- "project_id" uuid,
32
- "issue_id" uuid NOT NULL,
33
- "execution_workspace_id" uuid,
34
- "runtime_service_id" uuid,
35
- "type" text NOT NULL,
36
- "provider" text NOT NULL,
37
- "external_id" text,
38
- "title" text NOT NULL,
39
- "url" text,
40
- "status" text NOT NULL,
41
- "review_state" text DEFAULT 'none' NOT NULL,
42
- "is_primary" boolean DEFAULT false NOT NULL,
43
- "health_status" text DEFAULT 'unknown' NOT NULL,
44
- "summary" text,
45
- "metadata" jsonb,
46
- "created_by_run_id" uuid,
47
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
48
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
49
- );
50
- --> statement-breakpoint
51
- ALTER TABLE "issues" ADD COLUMN "project_workspace_id" uuid;--> statement-breakpoint
52
- ALTER TABLE "issues" ADD COLUMN "execution_workspace_id" uuid;--> statement-breakpoint
53
- ALTER TABLE "issues" ADD COLUMN "execution_workspace_preference" text;--> statement-breakpoint
54
- ALTER TABLE "project_workspaces" ADD COLUMN "source_type" text DEFAULT 'local_path' NOT NULL;--> statement-breakpoint
55
- ALTER TABLE "project_workspaces" ADD COLUMN "default_ref" text;--> statement-breakpoint
56
- ALTER TABLE "project_workspaces" ADD COLUMN "visibility" text DEFAULT 'default' NOT NULL;--> statement-breakpoint
57
- ALTER TABLE "project_workspaces" ADD COLUMN "setup_command" text;--> statement-breakpoint
58
- ALTER TABLE "project_workspaces" ADD COLUMN "cleanup_command" text;--> statement-breakpoint
59
- ALTER TABLE "project_workspaces" ADD COLUMN "remote_provider" text;--> statement-breakpoint
60
- ALTER TABLE "project_workspaces" ADD COLUMN "remote_workspace_ref" text;--> statement-breakpoint
61
- ALTER TABLE "project_workspaces" ADD COLUMN "shared_workspace_key" text;--> statement-breakpoint
62
- ALTER TABLE "workspace_runtime_services" ADD COLUMN "execution_workspace_id" uuid;--> statement-breakpoint
63
- ALTER TABLE "execution_workspaces" ADD CONSTRAINT "execution_workspaces_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
64
- ALTER TABLE "execution_workspaces" ADD CONSTRAINT "execution_workspaces_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
65
- ALTER TABLE "execution_workspaces" ADD CONSTRAINT "execution_workspaces_project_workspace_id_project_workspaces_id_fk" FOREIGN KEY ("project_workspace_id") REFERENCES "public"."project_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
66
- ALTER TABLE "execution_workspaces" ADD CONSTRAINT "execution_workspaces_source_issue_id_issues_id_fk" FOREIGN KEY ("source_issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
67
- ALTER TABLE "execution_workspaces" ADD CONSTRAINT "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("derived_from_execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
68
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
69
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
70
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
71
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
72
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_runtime_service_id_workspace_runtime_services_id_fk" FOREIGN KEY ("runtime_service_id") REFERENCES "public"."workspace_runtime_services"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
73
- ALTER TABLE "issue_work_products" ADD CONSTRAINT "issue_work_products_created_by_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("created_by_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
74
- CREATE INDEX "execution_workspaces_company_project_status_idx" ON "execution_workspaces" USING btree ("company_id","project_id","status");--> statement-breakpoint
75
- CREATE INDEX "execution_workspaces_company_project_workspace_status_idx" ON "execution_workspaces" USING btree ("company_id","project_workspace_id","status");--> statement-breakpoint
76
- CREATE INDEX "execution_workspaces_company_source_issue_idx" ON "execution_workspaces" USING btree ("company_id","source_issue_id");--> statement-breakpoint
77
- CREATE INDEX "execution_workspaces_company_last_used_idx" ON "execution_workspaces" USING btree ("company_id","last_used_at");--> statement-breakpoint
78
- CREATE INDEX "execution_workspaces_company_branch_idx" ON "execution_workspaces" USING btree ("company_id","branch_name");--> statement-breakpoint
79
- CREATE INDEX "issue_work_products_company_issue_type_idx" ON "issue_work_products" USING btree ("company_id","issue_id","type");--> statement-breakpoint
80
- CREATE INDEX "issue_work_products_company_execution_workspace_type_idx" ON "issue_work_products" USING btree ("company_id","execution_workspace_id","type");--> statement-breakpoint
81
- CREATE INDEX "issue_work_products_company_provider_external_id_idx" ON "issue_work_products" USING btree ("company_id","provider","external_id");--> statement-breakpoint
82
- CREATE INDEX "issue_work_products_company_updated_idx" ON "issue_work_products" USING btree ("company_id","updated_at");--> statement-breakpoint
83
- ALTER TABLE "issues" ADD CONSTRAINT "issues_project_workspace_id_project_workspaces_id_fk" FOREIGN KEY ("project_workspace_id") REFERENCES "public"."project_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
84
- ALTER TABLE "issues" ADD CONSTRAINT "issues_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
85
- ALTER TABLE "workspace_runtime_services" ADD CONSTRAINT "workspace_runtime_services_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
86
- CREATE INDEX "issues_company_project_workspace_idx" ON "issues" USING btree ("company_id","project_workspace_id");--> statement-breakpoint
87
- CREATE INDEX "issues_company_execution_workspace_idx" ON "issues" USING btree ("company_id","execution_workspace_id");--> statement-breakpoint
88
- CREATE INDEX "project_workspaces_project_source_type_idx" ON "project_workspaces" USING btree ("project_id","source_type");--> statement-breakpoint
89
- CREATE INDEX "project_workspaces_company_shared_key_idx" ON "project_workspaces" USING btree ("company_id","shared_workspace_key");--> statement-breakpoint
90
- CREATE UNIQUE INDEX "project_workspaces_project_remote_ref_idx" ON "project_workspaces" USING btree ("project_id","remote_provider","remote_workspace_ref");--> statement-breakpoint
91
- CREATE INDEX "workspace_runtime_services_company_execution_workspace_status_idx" ON "workspace_runtime_services" USING btree ("company_id","execution_workspace_id","status");
@@ -1,9 +0,0 @@
1
- CREATE TABLE "instance_settings" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "singleton_key" text DEFAULT 'default' NOT NULL,
4
- "experimental" jsonb DEFAULT '{}'::jsonb NOT NULL,
5
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
6
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
7
- );
8
- --> statement-breakpoint
9
- CREATE UNIQUE INDEX "instance_settings_singleton_key_idx" ON "instance_settings" USING btree ("singleton_key");
@@ -1,29 +0,0 @@
1
- CREATE TABLE "workspace_operations" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "execution_workspace_id" uuid,
5
- "heartbeat_run_id" uuid,
6
- "phase" text NOT NULL,
7
- "command" text,
8
- "cwd" text,
9
- "status" text DEFAULT 'running' NOT NULL,
10
- "exit_code" integer,
11
- "log_store" text,
12
- "log_ref" text,
13
- "log_bytes" bigint,
14
- "log_sha256" text,
15
- "log_compressed" boolean DEFAULT false NOT NULL,
16
- "stdout_excerpt" text,
17
- "stderr_excerpt" text,
18
- "metadata" jsonb,
19
- "started_at" timestamp with time zone DEFAULT now() NOT NULL,
20
- "finished_at" timestamp with time zone,
21
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
22
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
23
- );
24
- --> statement-breakpoint
25
- ALTER TABLE "workspace_operations" ADD CONSTRAINT "workspace_operations_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
26
- ALTER TABLE "workspace_operations" ADD CONSTRAINT "workspace_operations_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
27
- ALTER TABLE "workspace_operations" ADD CONSTRAINT "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("heartbeat_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
28
- CREATE INDEX "workspace_operations_company_run_started_idx" ON "workspace_operations" USING btree ("company_id","heartbeat_run_id","started_at");--> statement-breakpoint
29
- CREATE INDEX "workspace_operations_company_workspace_started_idx" ON "workspace_operations" USING btree ("company_id","execution_workspace_id","started_at");
@@ -1,5 +0,0 @@
1
- ALTER TABLE "heartbeat_runs" ADD COLUMN "process_pid" integer;--> statement-breakpoint
2
- ALTER TABLE "heartbeat_runs" ADD COLUMN "process_started_at" timestamp with time zone;--> statement-breakpoint
3
- ALTER TABLE "heartbeat_runs" ADD COLUMN "retry_of_run_id" uuid;--> statement-breakpoint
4
- ALTER TABLE "heartbeat_runs" ADD COLUMN "process_loss_retry_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
5
- ALTER TABLE "heartbeat_runs" ADD CONSTRAINT "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("retry_of_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;
@@ -1,161 +0,0 @@
1
- CREATE TABLE IF NOT EXISTS "routine_runs" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "routine_id" uuid NOT NULL,
5
- "trigger_id" uuid,
6
- "source" text NOT NULL,
7
- "status" text DEFAULT 'received' NOT NULL,
8
- "triggered_at" timestamp with time zone DEFAULT now() NOT NULL,
9
- "idempotency_key" text,
10
- "trigger_payload" jsonb,
11
- "linked_issue_id" uuid,
12
- "coalesced_into_run_id" uuid,
13
- "failure_reason" text,
14
- "completed_at" timestamp with time zone,
15
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
16
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
17
- );
18
- --> statement-breakpoint
19
- CREATE TABLE IF NOT EXISTS "routine_triggers" (
20
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
21
- "company_id" uuid NOT NULL,
22
- "routine_id" uuid NOT NULL,
23
- "kind" text NOT NULL,
24
- "label" text,
25
- "enabled" boolean DEFAULT true NOT NULL,
26
- "cron_expression" text,
27
- "timezone" text,
28
- "next_run_at" timestamp with time zone,
29
- "last_fired_at" timestamp with time zone,
30
- "public_id" text,
31
- "secret_id" uuid,
32
- "signing_mode" text,
33
- "replay_window_sec" integer,
34
- "last_rotated_at" timestamp with time zone,
35
- "last_result" text,
36
- "created_by_agent_id" uuid,
37
- "created_by_user_id" text,
38
- "updated_by_agent_id" uuid,
39
- "updated_by_user_id" text,
40
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
41
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
42
- );
43
- --> statement-breakpoint
44
- CREATE TABLE IF NOT EXISTS "routines" (
45
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
46
- "company_id" uuid NOT NULL,
47
- "project_id" uuid NOT NULL,
48
- "goal_id" uuid,
49
- "parent_issue_id" uuid,
50
- "title" text NOT NULL,
51
- "description" text,
52
- "assignee_agent_id" uuid NOT NULL,
53
- "priority" text DEFAULT 'medium' NOT NULL,
54
- "status" text DEFAULT 'active' NOT NULL,
55
- "concurrency_policy" text DEFAULT 'coalesce_if_active' NOT NULL,
56
- "catch_up_policy" text DEFAULT 'skip_missed' NOT NULL,
57
- "created_by_agent_id" uuid,
58
- "created_by_user_id" text,
59
- "updated_by_agent_id" uuid,
60
- "updated_by_user_id" text,
61
- "last_triggered_at" timestamp with time zone,
62
- "last_enqueued_at" timestamp with time zone,
63
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
64
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
65
- );
66
- --> statement-breakpoint
67
- ALTER TABLE "issues" ADD COLUMN IF NOT EXISTS "origin_kind" text DEFAULT 'manual' NOT NULL;--> statement-breakpoint
68
- ALTER TABLE "issues" ADD COLUMN IF NOT EXISTS "origin_id" text;--> statement-breakpoint
69
- ALTER TABLE "issues" ADD COLUMN IF NOT EXISTS "origin_run_id" text;--> statement-breakpoint
70
- DO $$ BEGIN
71
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_runs_company_id_companies_id_fk') THEN
72
- ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE cascade ON UPDATE no action;
73
- END IF;
74
- END $$;--> statement-breakpoint
75
- DO $$ BEGIN
76
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_runs_routine_id_routines_id_fk') THEN
77
- ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_routine_id_routines_id_fk" FOREIGN KEY ("routine_id") REFERENCES "public"."routines"("id") ON DELETE cascade ON UPDATE no action;
78
- END IF;
79
- END $$;--> statement-breakpoint
80
- DO $$ BEGIN
81
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_runs_trigger_id_routine_triggers_id_fk') THEN
82
- ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_trigger_id_routine_triggers_id_fk" FOREIGN KEY ("trigger_id") REFERENCES "public"."routine_triggers"("id") ON DELETE set null ON UPDATE no action;
83
- END IF;
84
- END $$;--> statement-breakpoint
85
- DO $$ BEGIN
86
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_runs_linked_issue_id_issues_id_fk') THEN
87
- ALTER TABLE "routine_runs" ADD CONSTRAINT "routine_runs_linked_issue_id_issues_id_fk" FOREIGN KEY ("linked_issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;
88
- END IF;
89
- END $$;--> statement-breakpoint
90
- DO $$ BEGIN
91
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_triggers_company_id_companies_id_fk') THEN
92
- ALTER TABLE "routine_triggers" ADD CONSTRAINT "routine_triggers_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE cascade ON UPDATE no action;
93
- END IF;
94
- END $$;--> statement-breakpoint
95
- DO $$ BEGIN
96
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_triggers_routine_id_routines_id_fk') THEN
97
- ALTER TABLE "routine_triggers" ADD CONSTRAINT "routine_triggers_routine_id_routines_id_fk" FOREIGN KEY ("routine_id") REFERENCES "public"."routines"("id") ON DELETE cascade ON UPDATE no action;
98
- END IF;
99
- END $$;--> statement-breakpoint
100
- DO $$ BEGIN
101
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_triggers_secret_id_company_secrets_id_fk') THEN
102
- ALTER TABLE "routine_triggers" ADD CONSTRAINT "routine_triggers_secret_id_company_secrets_id_fk" FOREIGN KEY ("secret_id") REFERENCES "public"."company_secrets"("id") ON DELETE set null ON UPDATE no action;
103
- END IF;
104
- END $$;--> statement-breakpoint
105
- DO $$ BEGIN
106
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_triggers_created_by_agent_id_agents_id_fk') THEN
107
- ALTER TABLE "routine_triggers" ADD CONSTRAINT "routine_triggers_created_by_agent_id_agents_id_fk" FOREIGN KEY ("created_by_agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;
108
- END IF;
109
- END $$;--> statement-breakpoint
110
- DO $$ BEGIN
111
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routine_triggers_updated_by_agent_id_agents_id_fk') THEN
112
- ALTER TABLE "routine_triggers" ADD CONSTRAINT "routine_triggers_updated_by_agent_id_agents_id_fk" FOREIGN KEY ("updated_by_agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;
113
- END IF;
114
- END $$;--> statement-breakpoint
115
- DO $$ BEGIN
116
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_company_id_companies_id_fk') THEN
117
- ALTER TABLE "routines" ADD CONSTRAINT "routines_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE cascade ON UPDATE no action;
118
- END IF;
119
- END $$;--> statement-breakpoint
120
- DO $$ BEGIN
121
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_project_id_projects_id_fk') THEN
122
- ALTER TABLE "routines" ADD CONSTRAINT "routines_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;
123
- END IF;
124
- END $$;--> statement-breakpoint
125
- DO $$ BEGIN
126
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_goal_id_goals_id_fk') THEN
127
- ALTER TABLE "routines" ADD CONSTRAINT "routines_goal_id_goals_id_fk" FOREIGN KEY ("goal_id") REFERENCES "public"."goals"("id") ON DELETE set null ON UPDATE no action;
128
- END IF;
129
- END $$;--> statement-breakpoint
130
- DO $$ BEGIN
131
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_parent_issue_id_issues_id_fk') THEN
132
- ALTER TABLE "routines" ADD CONSTRAINT "routines_parent_issue_id_issues_id_fk" FOREIGN KEY ("parent_issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;
133
- END IF;
134
- END $$;--> statement-breakpoint
135
- DO $$ BEGIN
136
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_assignee_agent_id_agents_id_fk') THEN
137
- ALTER TABLE "routines" ADD CONSTRAINT "routines_assignee_agent_id_agents_id_fk" FOREIGN KEY ("assignee_agent_id") REFERENCES "public"."agents"("id") ON DELETE no action ON UPDATE no action;
138
- END IF;
139
- END $$;--> statement-breakpoint
140
- DO $$ BEGIN
141
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_created_by_agent_id_agents_id_fk') THEN
142
- ALTER TABLE "routines" ADD CONSTRAINT "routines_created_by_agent_id_agents_id_fk" FOREIGN KEY ("created_by_agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;
143
- END IF;
144
- END $$;--> statement-breakpoint
145
- DO $$ BEGIN
146
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'routines_updated_by_agent_id_agents_id_fk') THEN
147
- ALTER TABLE "routines" ADD CONSTRAINT "routines_updated_by_agent_id_agents_id_fk" FOREIGN KEY ("updated_by_agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;
148
- END IF;
149
- END $$;--> statement-breakpoint
150
- CREATE INDEX IF NOT EXISTS "routine_runs_company_routine_idx" ON "routine_runs" USING btree ("company_id","routine_id","created_at");--> statement-breakpoint
151
- CREATE INDEX IF NOT EXISTS "routine_runs_trigger_idx" ON "routine_runs" USING btree ("trigger_id","created_at");--> statement-breakpoint
152
- CREATE INDEX IF NOT EXISTS "routine_runs_linked_issue_idx" ON "routine_runs" USING btree ("linked_issue_id");--> statement-breakpoint
153
- CREATE INDEX IF NOT EXISTS "routine_runs_trigger_idempotency_idx" ON "routine_runs" USING btree ("trigger_id","idempotency_key");--> statement-breakpoint
154
- CREATE INDEX IF NOT EXISTS "routine_triggers_company_routine_idx" ON "routine_triggers" USING btree ("company_id","routine_id");--> statement-breakpoint
155
- CREATE INDEX IF NOT EXISTS "routine_triggers_company_kind_idx" ON "routine_triggers" USING btree ("company_id","kind");--> statement-breakpoint
156
- CREATE INDEX IF NOT EXISTS "routine_triggers_next_run_idx" ON "routine_triggers" USING btree ("next_run_at");--> statement-breakpoint
157
- CREATE INDEX IF NOT EXISTS "routine_triggers_public_id_idx" ON "routine_triggers" USING btree ("public_id");--> statement-breakpoint
158
- CREATE INDEX IF NOT EXISTS "routines_company_status_idx" ON "routines" USING btree ("company_id","status");--> statement-breakpoint
159
- CREATE INDEX IF NOT EXISTS "routines_company_assignee_idx" ON "routines" USING btree ("company_id","assignee_agent_id");--> statement-breakpoint
160
- CREATE INDEX IF NOT EXISTS "routines_company_project_idx" ON "routines" USING btree ("company_id","project_id");--> statement-breakpoint
161
- CREATE INDEX IF NOT EXISTS "issues_company_origin_idx" ON "issues" USING btree ("company_id","origin_kind","origin_id");
@@ -1,5 +0,0 @@
1
- CREATE UNIQUE INDEX IF NOT EXISTS "issues_open_routine_execution_uq" ON "issues" USING btree ("company_id","origin_kind","origin_id") WHERE "issues"."origin_kind" = 'routine_execution'
2
- and "issues"."origin_id" is not null
3
- and "issues"."hidden_at" is null
4
- and "issues"."status" in ('backlog', 'todo', 'in_progress', 'in_review', 'blocked');--> statement-breakpoint
5
- CREATE UNIQUE INDEX IF NOT EXISTS "routine_triggers_public_id_uq" ON "routine_triggers" USING btree ("public_id");
@@ -1 +0,0 @@
1
- ALTER TABLE "instance_settings" ADD COLUMN IF NOT EXISTS "general" jsonb DEFAULT '{}'::jsonb NOT NULL;
@@ -1,26 +0,0 @@
1
- CREATE TABLE IF NOT EXISTS "company_skills" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "key" text NOT NULL,
5
- "slug" text NOT NULL,
6
- "name" text NOT NULL,
7
- "description" text,
8
- "markdown" text NOT NULL,
9
- "source_type" text DEFAULT 'local_path' NOT NULL,
10
- "source_locator" text,
11
- "source_ref" text,
12
- "trust_level" text DEFAULT 'markdown_only' NOT NULL,
13
- "compatibility" text DEFAULT 'compatible' NOT NULL,
14
- "file_inventory" jsonb DEFAULT '[]'::jsonb NOT NULL,
15
- "metadata" jsonb,
16
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
17
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
18
- );
19
- --> statement-breakpoint
20
- DO $$ BEGIN
21
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'company_skills_company_id_companies_id_fk') THEN
22
- ALTER TABLE "company_skills" ADD CONSTRAINT "company_skills_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;
23
- END IF;
24
- END $$;--> statement-breakpoint
25
- CREATE UNIQUE INDEX IF NOT EXISTS "company_skills_company_key_idx" ON "company_skills" USING btree ("company_id","key");--> statement-breakpoint
26
- CREATE INDEX IF NOT EXISTS "company_skills_company_name_idx" ON "company_skills" USING btree ("company_id","name");
@@ -1,6 +0,0 @@
1
- DROP INDEX IF EXISTS "issues_open_routine_execution_uq";--> statement-breakpoint
2
- CREATE UNIQUE INDEX IF NOT EXISTS "issues_open_routine_execution_uq" ON "issues" USING btree ("company_id","origin_kind","origin_id") WHERE "issues"."origin_kind" = 'routine_execution'
3
- and "issues"."origin_id" is not null
4
- and "issues"."hidden_at" is null
5
- and "issues"."execution_run_id" is not null
6
- and "issues"."status" in ('backlog', 'todo', 'in_progress', 'in_review', 'blocked');
@@ -1,56 +0,0 @@
1
- CREATE TABLE IF NOT EXISTS "board_api_keys" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "user_id" text NOT NULL,
4
- "name" text NOT NULL,
5
- "key_hash" text NOT NULL,
6
- "last_used_at" timestamp with time zone,
7
- "revoked_at" timestamp with time zone,
8
- "expires_at" timestamp with time zone,
9
- "created_at" timestamp with time zone DEFAULT now() NOT NULL
10
- );
11
- --> statement-breakpoint
12
- CREATE TABLE IF NOT EXISTS "cli_auth_challenges" (
13
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
14
- "secret_hash" text NOT NULL,
15
- "command" text NOT NULL,
16
- "client_name" text,
17
- "requested_access" text DEFAULT 'board' NOT NULL,
18
- "requested_company_id" uuid,
19
- "pending_key_hash" text NOT NULL,
20
- "pending_key_name" text NOT NULL,
21
- "approved_by_user_id" text,
22
- "board_api_key_id" uuid,
23
- "approved_at" timestamp with time zone,
24
- "cancelled_at" timestamp with time zone,
25
- "expires_at" timestamp with time zone NOT NULL,
26
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
27
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
28
- );
29
- --> statement-breakpoint
30
- ALTER TABLE "instance_settings" ADD COLUMN IF NOT EXISTS "general" jsonb DEFAULT '{}'::jsonb NOT NULL;--> statement-breakpoint
31
- DO $$ BEGIN
32
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'board_api_keys_user_id_user_id_fk') THEN
33
- ALTER TABLE "board_api_keys" ADD CONSTRAINT "board_api_keys_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
34
- END IF;
35
- END $$;--> statement-breakpoint
36
- DO $$ BEGIN
37
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cli_auth_challenges_requested_company_id_companies_id_fk') THEN
38
- ALTER TABLE "cli_auth_challenges" ADD CONSTRAINT "cli_auth_challenges_requested_company_id_companies_id_fk" FOREIGN KEY ("requested_company_id") REFERENCES "public"."companies"("id") ON DELETE set null ON UPDATE no action;
39
- END IF;
40
- END $$;--> statement-breakpoint
41
- DO $$ BEGIN
42
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cli_auth_challenges_approved_by_user_id_user_id_fk') THEN
43
- ALTER TABLE "cli_auth_challenges" ADD CONSTRAINT "cli_auth_challenges_approved_by_user_id_user_id_fk" FOREIGN KEY ("approved_by_user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;
44
- END IF;
45
- END $$;--> statement-breakpoint
46
- DO $$ BEGIN
47
- IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cli_auth_challenges_board_api_key_id_board_api_keys_id_fk') THEN
48
- ALTER TABLE "cli_auth_challenges" ADD CONSTRAINT "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk" FOREIGN KEY ("board_api_key_id") REFERENCES "public"."board_api_keys"("id") ON DELETE set null ON UPDATE no action;
49
- END IF;
50
- END $$;--> statement-breakpoint
51
- DROP INDEX IF EXISTS "board_api_keys_key_hash_idx";--> statement-breakpoint
52
- CREATE UNIQUE INDEX IF NOT EXISTS "board_api_keys_key_hash_idx" ON "board_api_keys" USING btree ("key_hash");--> statement-breakpoint
53
- CREATE INDEX IF NOT EXISTS "board_api_keys_user_idx" ON "board_api_keys" USING btree ("user_id");--> statement-breakpoint
54
- CREATE INDEX IF NOT EXISTS "cli_auth_challenges_secret_hash_idx" ON "cli_auth_challenges" USING btree ("secret_hash");--> statement-breakpoint
55
- CREATE INDEX IF NOT EXISTS "cli_auth_challenges_approved_by_idx" ON "cli_auth_challenges" USING btree ("approved_by_user_id");--> statement-breakpoint
56
- CREATE INDEX IF NOT EXISTS "cli_auth_challenges_requested_company_idx" ON "cli_auth_challenges" USING btree ("requested_company_id");
@@ -1,17 +0,0 @@
1
- CREATE TABLE "issue_inbox_archives" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
- "company_id" uuid NOT NULL,
4
- "issue_id" uuid NOT NULL,
5
- "user_id" text NOT NULL,
6
- "archived_at" timestamp with time zone DEFAULT now() NOT NULL,
7
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
8
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL
9
- );
10
- --> statement-breakpoint
11
- DROP INDEX "board_api_keys_key_hash_idx";--> statement-breakpoint
12
- ALTER TABLE "issue_inbox_archives" ADD CONSTRAINT "issue_inbox_archives_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
13
- ALTER TABLE "issue_inbox_archives" ADD CONSTRAINT "issue_inbox_archives_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
14
- CREATE INDEX "issue_inbox_archives_company_issue_idx" ON "issue_inbox_archives" USING btree ("company_id","issue_id");--> statement-breakpoint
15
- CREATE INDEX "issue_inbox_archives_company_user_idx" ON "issue_inbox_archives" USING btree ("company_id","user_id");--> statement-breakpoint
16
- CREATE UNIQUE INDEX "issue_inbox_archives_company_issue_user_idx" ON "issue_inbox_archives" USING btree ("company_id","issue_id","user_id");--> statement-breakpoint
17
- CREATE UNIQUE INDEX "board_api_keys_key_hash_idx" ON "board_api_keys" USING btree ("key_hash");