@hyperfixation/db 0.1.0

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app-state.d.ts +12 -0
  3. package/dist/app-state.js +18 -0
  4. package/dist/boot-checks.d.ts +56 -0
  5. package/dist/boot-checks.js +228 -0
  6. package/dist/classify.d.ts +6 -0
  7. package/dist/classify.js +75 -0
  8. package/dist/control-plane.d.ts +75 -0
  9. package/dist/control-plane.js +155 -0
  10. package/dist/delete-guard.d.ts +32 -0
  11. package/dist/delete-guard.js +62 -0
  12. package/dist/fenced-client.d.ts +35 -0
  13. package/dist/fenced-client.js +153 -0
  14. package/dist/grant-ro.d.ts +23 -0
  15. package/dist/grant-ro.js +49 -0
  16. package/dist/index.d.ts +12 -0
  17. package/dist/index.js +10 -0
  18. package/dist/internal/control-pool.d.ts +20 -0
  19. package/dist/internal/control-pool.js +17 -0
  20. package/dist/loader.d.ts +15 -0
  21. package/dist/loader.js +82 -0
  22. package/dist/migrate.d.ts +54 -0
  23. package/dist/migrate.js +143 -0
  24. package/dist/migration-policy.d.ts +14 -0
  25. package/dist/migration-policy.js +85 -0
  26. package/dist/migrator.d.ts +9 -0
  27. package/dist/migrator.js +9 -0
  28. package/dist/roles.d.ts +47 -0
  29. package/dist/roles.js +112 -0
  30. package/dist/schema/app.d.ts +235 -0
  31. package/dist/schema/app.js +23 -0
  32. package/dist/schema/approvals.d.ts +352 -0
  33. package/dist/schema/approvals.js +43 -0
  34. package/dist/schema/auth.d.ts +1272 -0
  35. package/dist/schema/auth.js +120 -0
  36. package/dist/schema/index.d.ts +7 -0
  37. package/dist/schema/index.js +7 -0
  38. package/dist/schema/ledger.d.ts +722 -0
  39. package/dist/schema/ledger.js +68 -0
  40. package/dist/schema/machinery.d.ts +1343 -0
  41. package/dist/schema/machinery.js +146 -0
  42. package/dist/schema/records.d.ts +15 -0
  43. package/dist/schema/records.js +16 -0
  44. package/dist/schema/runs.d.ts +213 -0
  45. package/dist/schema/runs.js +26 -0
  46. package/dist/step-pool.d.ts +26 -0
  47. package/dist/step-pool.js +57 -0
  48. package/migrations/0000_core_schema.sql +185 -0
  49. package/migrations/0001_llm_call_reservation_index.sql +4 -0
  50. package/migrations/0002_approvals.sql +25 -0
  51. package/migrations/0003_auth_invitation.sql +13 -0
  52. package/migrations/0004_machinery.sql +105 -0
  53. package/migrations/0005_nullable_activity_task_record.sql +4 -0
  54. package/migrations/0006_activity_score_key.sql +5 -0
  55. package/migrations/0007_score_spec_name.sql +3 -0
  56. package/migrations/meta/0000_snapshot.json +1238 -0
  57. package/migrations/meta/0001_snapshot.json +1238 -0
  58. package/migrations/meta/0002_snapshot.json +1426 -0
  59. package/migrations/meta/0003_snapshot.json +1516 -0
  60. package/migrations/meta/0004_snapshot.json +2353 -0
  61. package/migrations/meta/0005_snapshot.json +2353 -0
  62. package/migrations/meta/0006_snapshot.json +2415 -0
  63. package/migrations/meta/0007_snapshot.json +2427 -0
  64. package/migrations/meta/_journal.json +62 -0
  65. package/package.json +58 -0
@@ -0,0 +1,185 @@
1
+ CREATE TABLE "hf_app_state" (
2
+ "id" integer PRIMARY KEY DEFAULT 1 NOT NULL,
3
+ "paused" boolean DEFAULT false NOT NULL,
4
+ "paused_by" text,
5
+ "budget_usd" numeric(12, 4) NOT NULL,
6
+ "read_token_hash" text,
7
+ "write_token_hash" text,
8
+ CONSTRAINT "hf_app_state_singleton" CHECK ("hf_app_state"."id" = 1)
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE TABLE "hf_audit" (
12
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_audit_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
13
+ "actor_id" text,
14
+ "action" text NOT NULL,
15
+ "target_type" text,
16
+ "target_id" text,
17
+ "meta" jsonb,
18
+ "at" timestamp with time zone DEFAULT now() NOT NULL
19
+ );
20
+ --> statement-breakpoint
21
+ CREATE TABLE "hf_account" (
22
+ "id" text PRIMARY KEY NOT NULL,
23
+ "account_id" text NOT NULL,
24
+ "provider_id" text NOT NULL,
25
+ "user_id" text NOT NULL,
26
+ "access_token" text,
27
+ "refresh_token" text,
28
+ "id_token" text,
29
+ "access_token_expires_at" timestamp with time zone,
30
+ "refresh_token_expires_at" timestamp with time zone,
31
+ "scope" text,
32
+ "password" text,
33
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
34
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
35
+ );
36
+ --> statement-breakpoint
37
+ CREATE TABLE "hf_member" (
38
+ "id" text PRIMARY KEY NOT NULL,
39
+ "organization_id" text NOT NULL,
40
+ "user_id" text NOT NULL,
41
+ "role" text DEFAULT 'member' NOT NULL,
42
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
43
+ );
44
+ --> statement-breakpoint
45
+ CREATE TABLE "hf_organization" (
46
+ "id" text PRIMARY KEY NOT NULL,
47
+ "name" text NOT NULL,
48
+ "slug" text NOT NULL,
49
+ "logo" text,
50
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
51
+ "metadata" text,
52
+ CONSTRAINT "hf_organization_slug_unique" UNIQUE("slug")
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE TABLE "hf_passkey" (
56
+ "id" text PRIMARY KEY NOT NULL,
57
+ "name" text,
58
+ "public_key" text NOT NULL,
59
+ "user_id" text NOT NULL,
60
+ "credential_id" text NOT NULL,
61
+ "counter" integer NOT NULL,
62
+ "device_type" text NOT NULL,
63
+ "backed_up" boolean NOT NULL,
64
+ "transports" text,
65
+ "created_at" timestamp with time zone DEFAULT now(),
66
+ "aaguid" text
67
+ );
68
+ --> statement-breakpoint
69
+ CREATE TABLE "hf_session" (
70
+ "id" text PRIMARY KEY NOT NULL,
71
+ "expires_at" timestamp with time zone NOT NULL,
72
+ "token" text NOT NULL,
73
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
74
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
75
+ "ip_address" text,
76
+ "user_agent" text,
77
+ "user_id" text NOT NULL,
78
+ "active_organization_id" text,
79
+ "impersonated_by" text,
80
+ "factor" text DEFAULT 'code' NOT NULL,
81
+ CONSTRAINT "hf_session_token_unique" UNIQUE("token")
82
+ );
83
+ --> statement-breakpoint
84
+ CREATE TABLE "hf_user" (
85
+ "id" text PRIMARY KEY NOT NULL,
86
+ "name" text NOT NULL,
87
+ "email" text NOT NULL,
88
+ "email_verified" boolean DEFAULT false NOT NULL,
89
+ "image" text,
90
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
91
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
92
+ "role" text,
93
+ "banned" boolean DEFAULT false,
94
+ "ban_reason" text,
95
+ "ban_expires" timestamp with time zone,
96
+ CONSTRAINT "hf_user_email_unique" UNIQUE("email")
97
+ );
98
+ --> statement-breakpoint
99
+ CREATE TABLE "hf_verification" (
100
+ "id" text PRIMARY KEY NOT NULL,
101
+ "identifier" text NOT NULL,
102
+ "value" text NOT NULL,
103
+ "expires_at" timestamp with time zone NOT NULL,
104
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
105
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
106
+ );
107
+ --> statement-breakpoint
108
+ CREATE TABLE "hf_action_log" (
109
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_action_log_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
110
+ "run_id" text NOT NULL,
111
+ "key" text NOT NULL,
112
+ "workflow_id" text NOT NULL,
113
+ "channel" text NOT NULL,
114
+ "idempotency_key" text NOT NULL,
115
+ "status" text NOT NULL,
116
+ "external_id" text,
117
+ "approval_id" bigint,
118
+ "record_type" text,
119
+ "record_id" text,
120
+ "request" jsonb,
121
+ "response" jsonb,
122
+ "started_at" timestamp with time zone DEFAULT now() NOT NULL,
123
+ "finished_at" timestamp with time zone
124
+ );
125
+ --> statement-breakpoint
126
+ CREATE TABLE "hf_budget_period" (
127
+ "period" text PRIMARY KEY NOT NULL,
128
+ "budget_usd" numeric(12, 4) NOT NULL,
129
+ "spent_usd" numeric(12, 4) DEFAULT '0' NOT NULL,
130
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
131
+ CONSTRAINT "hf_budget_period_spent_non_negative" CHECK ("hf_budget_period"."spent_usd" >= 0)
132
+ );
133
+ --> statement-breakpoint
134
+ CREATE TABLE "hf_llm_call" (
135
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_llm_call_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
136
+ "run_id" text NOT NULL,
137
+ "key" text NOT NULL,
138
+ "workflow_id" text NOT NULL,
139
+ "period" text NOT NULL,
140
+ "step_name" text,
141
+ "prompt_name" text,
142
+ "prompt_hash" text,
143
+ "input_hash" text NOT NULL,
144
+ "model" text,
145
+ "status" text NOT NULL,
146
+ "input" jsonb,
147
+ "output" jsonb,
148
+ "tokens_in" integer,
149
+ "tokens_out" integer,
150
+ "estimated_cost_usd" numeric(12, 6) NOT NULL,
151
+ "cost_usd" numeric(12, 6),
152
+ "possible_double_charge" boolean DEFAULT false NOT NULL,
153
+ "latency_ms" integer,
154
+ "trace_id" text,
155
+ "started_at" timestamp with time zone DEFAULT now() NOT NULL,
156
+ "finished_at" timestamp with time zone
157
+ );
158
+ --> statement-breakpoint
159
+ CREATE TABLE "hf_run" (
160
+ "run_id" text PRIMARY KEY NOT NULL,
161
+ "flow" text NOT NULL,
162
+ "input" jsonb,
163
+ "status" text NOT NULL,
164
+ "attempt" integer DEFAULT 1 NOT NULL,
165
+ "current_workflow_id" text NOT NULL,
166
+ "version" text,
167
+ "record_type" text,
168
+ "record_id" text,
169
+ "error" text,
170
+ "started_at" timestamp with time zone DEFAULT now() NOT NULL,
171
+ "finished_at" timestamp with time zone,
172
+ CONSTRAINT "hf_run_current_workflow_id_unique" UNIQUE("current_workflow_id"),
173
+ CONSTRAINT "hf_run_attempt_positive" CHECK ("hf_run"."attempt" >= 1)
174
+ );
175
+ --> statement-breakpoint
176
+ ALTER TABLE "hf_account" ADD CONSTRAINT "hf_account_user_id_hf_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hf_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
177
+ ALTER TABLE "hf_member" ADD CONSTRAINT "hf_member_organization_id_hf_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hf_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
178
+ ALTER TABLE "hf_member" ADD CONSTRAINT "hf_member_user_id_hf_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hf_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
179
+ ALTER TABLE "hf_passkey" ADD CONSTRAINT "hf_passkey_user_id_hf_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hf_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
180
+ ALTER TABLE "hf_session" ADD CONSTRAINT "hf_session_user_id_hf_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hf_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
181
+ CREATE UNIQUE INDEX "hf_action_log_run_key_uq" ON "hf_action_log" USING btree ("run_id","key");--> statement-breakpoint
182
+ CREATE UNIQUE INDEX "hf_llm_call_run_key_uq" ON "hf_llm_call" USING btree ("run_id","key");--> statement-breakpoint
183
+ CREATE INDEX "hf_llm_call_period_status_idx" ON "hf_llm_call" USING btree ("period","status");--> statement-breakpoint
184
+ CREATE INDEX "hf_run_status_idx" ON "hf_run" USING btree ("status");--> statement-breakpoint
185
+ CREATE INDEX "hf_run_record_idx" ON "hf_run" USING btree ("record_type","record_id");
@@ -0,0 +1,4 @@
1
+ CREATE INDEX "hf_llm_call_reservation_idx"
2
+ ON "hf_llm_call" USING btree ("period", "run_id", "workflow_id")
3
+ INCLUDE ("estimated_cost_usd")
4
+ WHERE "status" = 'started';
@@ -0,0 +1,25 @@
1
+ CREATE TABLE "hf_approval" (
2
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_approval_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
3
+ "run_id" text NOT NULL,
4
+ "key" text NOT NULL,
5
+ "workflow_id" text NOT NULL,
6
+ "type" text NOT NULL,
7
+ "record_type" text,
8
+ "record_id" text,
9
+ "draft" jsonb,
10
+ "edited_draft" jsonb,
11
+ "status" text NOT NULL,
12
+ "assignee_id" text,
13
+ "decided_by" text,
14
+ "decided_at" timestamp with time zone,
15
+ "decided_via" text,
16
+ "decision_key" text,
17
+ "resume_workflow_id" text,
18
+ "notified_at" timestamp with time zone,
19
+ "expires_at" timestamp with time zone,
20
+ "batch_id" text,
21
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
22
+ );
23
+ --> statement-breakpoint
24
+ CREATE UNIQUE INDEX "hf_approval_run_key_uq" ON "hf_approval" USING btree ("run_id","key");--> statement-breakpoint
25
+ CREATE INDEX "hf_approval_status_idx" ON "hf_approval" USING btree ("status","expires_at");
@@ -0,0 +1,13 @@
1
+ CREATE TABLE "hf_invitation" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "organization_id" text NOT NULL,
4
+ "email" text NOT NULL,
5
+ "role" text,
6
+ "status" text DEFAULT 'pending' NOT NULL,
7
+ "expires_at" timestamp with time zone NOT NULL,
8
+ "inviter_id" text NOT NULL,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "hf_invitation" ADD CONSTRAINT "hf_invitation_organization_id_hf_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hf_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
13
+ ALTER TABLE "hf_invitation" ADD CONSTRAINT "hf_invitation_inviter_id_hf_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."hf_user"("id") ON DELETE cascade ON UPDATE no action;
@@ -0,0 +1,105 @@
1
+ CREATE TABLE "hf_activity" (
2
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_activity_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
3
+ "record_type" text NOT NULL,
4
+ "record_id" text NOT NULL,
5
+ "kind" text NOT NULL,
6
+ "actor_id" text,
7
+ "body" text,
8
+ "meta" jsonb,
9
+ "run_id" text,
10
+ "at" timestamp with time zone DEFAULT now() NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "hf_label" (
14
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_label_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
15
+ "record_type" text NOT NULL,
16
+ "record_id" text NOT NULL,
17
+ "target" text NOT NULL,
18
+ "target_id" text,
19
+ "value" text NOT NULL,
20
+ "correction" jsonb,
21
+ "user_id" text,
22
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
23
+ );
24
+ --> statement-breakpoint
25
+ CREATE TABLE "hf_outcome" (
26
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_outcome_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
27
+ "record_type" text NOT NULL,
28
+ "record_id" text NOT NULL,
29
+ "outcome" text NOT NULL,
30
+ "at" timestamp with time zone DEFAULT now() NOT NULL,
31
+ "notes" text
32
+ );
33
+ --> statement-breakpoint
34
+ CREATE TABLE "hf_record_link" (
35
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_record_link_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
36
+ "source_record_id" bigint NOT NULL,
37
+ "record_type" text NOT NULL,
38
+ "record_id" text NOT NULL,
39
+ "confidence" double precision,
40
+ "method" text NOT NULL,
41
+ "decided_by" text,
42
+ "decided_at" timestamp with time zone
43
+ );
44
+ --> statement-breakpoint
45
+ CREATE TABLE "hf_score" (
46
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_score_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
47
+ "record_type" text NOT NULL,
48
+ "record_id" text NOT NULL,
49
+ "spec_version" integer NOT NULL,
50
+ "score" double precision NOT NULL,
51
+ "explanation" text,
52
+ "llm_call_id" bigint,
53
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
54
+ );
55
+ --> statement-breakpoint
56
+ CREATE TABLE "hf_source_record" (
57
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_source_record_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
58
+ "source" text NOT NULL,
59
+ "external_id" text NOT NULL,
60
+ "payload" jsonb NOT NULL,
61
+ "payload_hash" text NOT NULL,
62
+ "status" text DEFAULT 'new' NOT NULL,
63
+ "attempts" integer DEFAULT 0 NOT NULL,
64
+ "error" text,
65
+ "run_id" bigint,
66
+ "first_seen" timestamp with time zone DEFAULT now() NOT NULL,
67
+ "last_seen" timestamp with time zone DEFAULT now() NOT NULL
68
+ );
69
+ --> statement-breakpoint
70
+ CREATE TABLE "hf_source_run" (
71
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_source_run_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
72
+ "source" text NOT NULL,
73
+ "started_at" timestamp with time zone DEFAULT now() NOT NULL,
74
+ "finished_at" timestamp with time zone,
75
+ "status" text NOT NULL,
76
+ "rows_in" integer DEFAULT 0 NOT NULL,
77
+ "rows_new" integer DEFAULT 0 NOT NULL,
78
+ "rows_changed" integer DEFAULT 0 NOT NULL,
79
+ "error" text
80
+ );
81
+ --> statement-breakpoint
82
+ CREATE TABLE "hf_task" (
83
+ "id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "hf_task_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
84
+ "record_type" text NOT NULL,
85
+ "record_id" text NOT NULL,
86
+ "title" text NOT NULL,
87
+ "due_at" timestamp with time zone,
88
+ "owner_id" text,
89
+ "done_at" timestamp with time zone,
90
+ "cancelled_at" timestamp with time zone,
91
+ "origin" text NOT NULL,
92
+ "origin_ref" text,
93
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
94
+ );
95
+ --> statement-breakpoint
96
+ CREATE INDEX "hf_activity_record_idx" ON "hf_activity" USING btree ("record_type","record_id");--> statement-breakpoint
97
+ CREATE INDEX "hf_label_record_idx" ON "hf_label" USING btree ("record_type","record_id");--> statement-breakpoint
98
+ CREATE INDEX "hf_outcome_record_idx" ON "hf_outcome" USING btree ("record_type","record_id");--> statement-breakpoint
99
+ CREATE UNIQUE INDEX "hf_record_link_source_record_uq" ON "hf_record_link" USING btree ("source_record_id");--> statement-breakpoint
100
+ CREATE INDEX "hf_record_link_record_idx" ON "hf_record_link" USING btree ("record_type","record_id");--> statement-breakpoint
101
+ CREATE INDEX "hf_score_record_idx" ON "hf_score" USING btree ("record_type","record_id");--> statement-breakpoint
102
+ CREATE UNIQUE INDEX "hf_source_record_source_external_uq" ON "hf_source_record" USING btree ("source","external_id");--> statement-breakpoint
103
+ CREATE INDEX "hf_source_record_status_idx" ON "hf_source_record" USING btree ("status");--> statement-breakpoint
104
+ CREATE INDEX "hf_task_record_idx" ON "hf_task" USING btree ("record_type","record_id");--> statement-breakpoint
105
+ CREATE UNIQUE INDEX "hf_task_origin_ref_uq" ON "hf_task" USING btree ("origin","origin_ref") WHERE "hf_task"."origin_ref" IS NOT NULL;
@@ -0,0 +1,4 @@
1
+ ALTER TABLE "hf_activity" ALTER COLUMN "record_type" DROP NOT NULL;--> statement-breakpoint
2
+ ALTER TABLE "hf_activity" ALTER COLUMN "record_id" DROP NOT NULL;--> statement-breakpoint
3
+ ALTER TABLE "hf_task" ALTER COLUMN "record_type" DROP NOT NULL;--> statement-breakpoint
4
+ ALTER TABLE "hf_task" ALTER COLUMN "record_id" DROP NOT NULL;
@@ -0,0 +1,5 @@
1
+ ALTER TABLE "hf_activity" ADD COLUMN "key" text;--> statement-breakpoint
2
+ ALTER TABLE "hf_score" ADD COLUMN "run_id" text;--> statement-breakpoint
3
+ ALTER TABLE "hf_score" ADD COLUMN "key" text;--> statement-breakpoint
4
+ CREATE UNIQUE INDEX "hf_activity_run_key_uq" ON "hf_activity" USING btree ("run_id","key") WHERE "hf_activity"."key" IS NOT NULL;--> statement-breakpoint
5
+ CREATE UNIQUE INDEX "hf_score_run_key_uq" ON "hf_score" USING btree ("run_id","key") WHERE "hf_score"."key" IS NOT NULL;
@@ -0,0 +1,3 @@
1
+ DROP INDEX "hf_score_run_key_uq";--> statement-breakpoint
2
+ ALTER TABLE "hf_score" ADD COLUMN "spec_name" text;--> statement-breakpoint
3
+ CREATE UNIQUE INDEX "hf_score_run_key_spec_uq" ON "hf_score" USING btree ("run_id","key","spec_name") WHERE "hf_score"."key" IS NOT NULL;