peri-fuse 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.
@@ -0,0 +1,1128 @@
1
+ CREATE TABLE `Account` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `user_id` text NOT NULL,
4
+ `type` text NOT NULL,
5
+ `provider` text NOT NULL,
6
+ `providerAccountId` text NOT NULL,
7
+ `refresh_token` text,
8
+ `access_token` text,
9
+ `expires_at` integer,
10
+ `expires_in` integer,
11
+ `ext_expires_in` integer,
12
+ `token_type` text,
13
+ `scope` text,
14
+ `id_token` text,
15
+ `session_state` text,
16
+ `refresh_token_expires_in` integer,
17
+ `created_at` integer,
18
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
19
+ );
20
+ --> statement-breakpoint
21
+ CREATE UNIQUE INDEX `Account_provider_providerAccountId_key` ON `Account` (`provider`,`providerAccountId`);--> statement-breakpoint
22
+ CREATE INDEX `Account_user_id_idx` ON `Account` (`user_id`);--> statement-breakpoint
23
+ CREATE TABLE `actions` (
24
+ `id` text PRIMARY KEY NOT NULL,
25
+ `created_at` integer NOT NULL,
26
+ `updated_at` integer NOT NULL,
27
+ `project_id` text NOT NULL,
28
+ `type` text NOT NULL,
29
+ `config` text NOT NULL,
30
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
31
+ );
32
+ --> statement-breakpoint
33
+ CREATE INDEX `actions_project_id_idx` ON `actions` (`project_id`);--> statement-breakpoint
34
+ CREATE TABLE `annotation_queue_assignments` (
35
+ `id` text PRIMARY KEY NOT NULL,
36
+ `project_id` text NOT NULL,
37
+ `user_id` text NOT NULL,
38
+ `queue_id` text NOT NULL,
39
+ `created_at` integer NOT NULL,
40
+ `updated_at` integer NOT NULL,
41
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
42
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade,
43
+ FOREIGN KEY (`queue_id`) REFERENCES `annotation_queues`(`id`) ON UPDATE cascade ON DELETE cascade
44
+ );
45
+ --> statement-breakpoint
46
+ CREATE UNIQUE INDEX `annotation_queue_assignments_project_id_queue_id_user_id_key` ON `annotation_queue_assignments` (`project_id`,`queue_id`,`user_id`);--> statement-breakpoint
47
+ CREATE TABLE `annotation_queue_items` (
48
+ `id` text PRIMARY KEY NOT NULL,
49
+ `queue_id` text NOT NULL,
50
+ `object_id` text NOT NULL,
51
+ `object_type` text NOT NULL,
52
+ `status` text DEFAULT 'PENDING' NOT NULL,
53
+ `locked_at` integer,
54
+ `locked_by_user_id` text,
55
+ `annotator_user_id` text,
56
+ `completed_at` integer,
57
+ `project_id` text NOT NULL,
58
+ `created_at` integer NOT NULL,
59
+ `updated_at` integer NOT NULL,
60
+ FOREIGN KEY (`queue_id`) REFERENCES `annotation_queues`(`id`) ON UPDATE cascade ON DELETE cascade,
61
+ FOREIGN KEY (`locked_by_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
62
+ FOREIGN KEY (`annotator_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
63
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
64
+ );
65
+ --> statement-breakpoint
66
+ CREATE INDEX `annotation_queue_items_created_at_idx` ON `annotation_queue_items` (`created_at`);--> statement-breakpoint
67
+ CREATE INDEX `annotation_queue_items_annotator_user_id_idx` ON `annotation_queue_items` (`annotator_user_id`);--> statement-breakpoint
68
+ CREATE INDEX `annotation_queue_items_object_id_object_type_project_id_queue_id_idx` ON `annotation_queue_items` (`object_id`,`object_type`,`project_id`,`queue_id`);--> statement-breakpoint
69
+ CREATE INDEX `annotation_queue_items_project_id_queue_id_status_idx` ON `annotation_queue_items` (`project_id`,`queue_id`,`status`);--> statement-breakpoint
70
+ CREATE INDEX `annotation_queue_items_id_project_id_idx` ON `annotation_queue_items` (`id`,`project_id`);--> statement-breakpoint
71
+ CREATE TABLE `annotation_queues` (
72
+ `id` text PRIMARY KEY NOT NULL,
73
+ `name` text NOT NULL,
74
+ `description` text,
75
+ `score_config_ids` text DEFAULT '[]' NOT NULL,
76
+ `project_id` text NOT NULL,
77
+ `created_at` integer NOT NULL,
78
+ `updated_at` integer NOT NULL,
79
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
80
+ );
81
+ --> statement-breakpoint
82
+ CREATE UNIQUE INDEX `annotation_queues_project_id_name_key` ON `annotation_queues` (`project_id`,`name`);--> statement-breakpoint
83
+ CREATE INDEX `annotation_queues_project_id_created_at_idx` ON `annotation_queues` (`project_id`,`created_at`);--> statement-breakpoint
84
+ CREATE INDEX `annotation_queues_id_project_id_idx` ON `annotation_queues` (`id`,`project_id`);--> statement-breakpoint
85
+ CREATE TABLE `api_keys` (
86
+ `id` text PRIMARY KEY NOT NULL,
87
+ `created_at` integer NOT NULL,
88
+ `note` text,
89
+ `public_key` text NOT NULL,
90
+ `hashed_secret_key` text NOT NULL,
91
+ `fast_hashed_secret_key` text,
92
+ `display_secret_key` text NOT NULL,
93
+ `last_used_at` integer,
94
+ `expires_at` integer,
95
+ `is_in_app_agent_key` integer DEFAULT false NOT NULL,
96
+ `project_id` text,
97
+ `organization_id` text,
98
+ `scope` text DEFAULT 'PROJECT' NOT NULL,
99
+ `created_by_user_id` text,
100
+ `created_by_api_key_id` text,
101
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
102
+ FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade,
103
+ FOREIGN KEY (`created_by_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
104
+ FOREIGN KEY (`created_by_api_key_id`) REFERENCES `api_keys`(`id`) ON UPDATE cascade ON DELETE set null
105
+ );
106
+ --> statement-breakpoint
107
+ CREATE INDEX `api_keys_fast_hashed_secret_key_idx` ON `api_keys` (`fast_hashed_secret_key`);--> statement-breakpoint
108
+ CREATE INDEX `api_keys_hashed_secret_key_idx` ON `api_keys` (`hashed_secret_key`);--> statement-breakpoint
109
+ CREATE INDEX `api_keys_public_key_idx` ON `api_keys` (`public_key`);--> statement-breakpoint
110
+ CREATE INDEX `api_keys_created_by_api_key_id_idx` ON `api_keys` (`created_by_api_key_id`);--> statement-breakpoint
111
+ CREATE INDEX `api_keys_project_id_idx` ON `api_keys` (`project_id`);--> statement-breakpoint
112
+ CREATE INDEX `api_keys_organization_id_idx` ON `api_keys` (`organization_id`);--> statement-breakpoint
113
+ CREATE UNIQUE INDEX `api_keys_fast_hashed_secret_key_key` ON `api_keys` (`fast_hashed_secret_key`);--> statement-breakpoint
114
+ CREATE UNIQUE INDEX `api_keys_hashed_secret_key_key` ON `api_keys` (`hashed_secret_key`);--> statement-breakpoint
115
+ CREATE UNIQUE INDEX `api_keys_public_key_key` ON `api_keys` (`public_key`);--> statement-breakpoint
116
+ CREATE UNIQUE INDEX `api_keys_id_key` ON `api_keys` (`id`);--> statement-breakpoint
117
+ CREATE TABLE `audit_logs` (
118
+ `id` text PRIMARY KEY NOT NULL,
119
+ `created_at` integer NOT NULL,
120
+ `updated_at` integer NOT NULL,
121
+ `type` text DEFAULT 'USER' NOT NULL,
122
+ `api_key_id` text,
123
+ `user_id` text,
124
+ `org_id` text NOT NULL,
125
+ `user_org_role` text,
126
+ `project_id` text,
127
+ `user_project_role` text,
128
+ `resource_type` text NOT NULL,
129
+ `resource_id` text NOT NULL,
130
+ `action` text NOT NULL,
131
+ `before` text,
132
+ `after` text
133
+ );
134
+ --> statement-breakpoint
135
+ CREATE INDEX `audit_logs_updated_at_idx` ON `audit_logs` (`updated_at`);--> statement-breakpoint
136
+ CREATE INDEX `audit_logs_created_at_idx` ON `audit_logs` (`created_at`);--> statement-breakpoint
137
+ CREATE INDEX `audit_logs_org_id_idx` ON `audit_logs` (`org_id`);--> statement-breakpoint
138
+ CREATE INDEX `audit_logs_user_id_idx` ON `audit_logs` (`user_id`);--> statement-breakpoint
139
+ CREATE INDEX `audit_logs_api_key_id_idx` ON `audit_logs` (`api_key_id`);--> statement-breakpoint
140
+ CREATE INDEX `audit_logs_project_id_idx` ON `audit_logs` (`project_id`);--> statement-breakpoint
141
+ CREATE TABLE `automation_executions` (
142
+ `id` text PRIMARY KEY NOT NULL,
143
+ `created_at` integer NOT NULL,
144
+ `updated_at` integer NOT NULL,
145
+ `source_id` text NOT NULL,
146
+ `automation_id` text NOT NULL,
147
+ `trigger_id` text NOT NULL,
148
+ `action_id` text NOT NULL,
149
+ `project_id` text NOT NULL,
150
+ `status` text DEFAULT 'PENDING' NOT NULL,
151
+ `input` text NOT NULL,
152
+ `output` text,
153
+ `started_at` integer,
154
+ `finished_at` integer,
155
+ `error` text,
156
+ FOREIGN KEY (`automation_id`) REFERENCES `automations`(`id`) ON UPDATE cascade ON DELETE cascade,
157
+ FOREIGN KEY (`trigger_id`) REFERENCES `triggers`(`id`) ON UPDATE cascade ON DELETE cascade,
158
+ FOREIGN KEY (`action_id`) REFERENCES `actions`(`id`) ON UPDATE cascade ON DELETE cascade,
159
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
160
+ );
161
+ --> statement-breakpoint
162
+ CREATE INDEX `automation_executions_project_id_idx` ON `automation_executions` (`project_id`);--> statement-breakpoint
163
+ CREATE INDEX `automation_executions_action_id_idx` ON `automation_executions` (`action_id`);--> statement-breakpoint
164
+ CREATE INDEX `automation_executions_trigger_id_idx` ON `automation_executions` (`trigger_id`);--> statement-breakpoint
165
+ CREATE TABLE `automations` (
166
+ `id` text PRIMARY KEY NOT NULL,
167
+ `name` text NOT NULL,
168
+ `trigger_id` text NOT NULL,
169
+ `action_id` text NOT NULL,
170
+ `created_at` integer NOT NULL,
171
+ `project_id` text NOT NULL,
172
+ FOREIGN KEY (`trigger_id`) REFERENCES `triggers`(`id`) ON UPDATE cascade ON DELETE cascade,
173
+ FOREIGN KEY (`action_id`) REFERENCES `actions`(`id`) ON UPDATE cascade ON DELETE cascade,
174
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
175
+ );
176
+ --> statement-breakpoint
177
+ CREATE INDEX `automations_project_id_name_idx` ON `automations` (`project_id`,`name`);--> statement-breakpoint
178
+ CREATE INDEX `automations_project_id_action_id_trigger_id_idx` ON `automations` (`project_id`,`action_id`,`trigger_id`);--> statement-breakpoint
179
+ CREATE TABLE `background_migrations` (
180
+ `id` text PRIMARY KEY NOT NULL,
181
+ `name` text NOT NULL,
182
+ `script` text NOT NULL,
183
+ `args` text NOT NULL,
184
+ `state` text DEFAULT '{}' NOT NULL,
185
+ `finished_at` integer,
186
+ `failed_at` integer,
187
+ `failed_reason` text,
188
+ `worker_id` text,
189
+ `locked_at` integer
190
+ );
191
+ --> statement-breakpoint
192
+ CREATE UNIQUE INDEX `background_migrations_name_key` ON `background_migrations` (`name`);--> statement-breakpoint
193
+ CREATE TABLE `batch_actions` (
194
+ `id` text PRIMARY KEY NOT NULL,
195
+ `created_at` integer NOT NULL,
196
+ `updated_at` integer NOT NULL,
197
+ `project_id` text NOT NULL,
198
+ `user_id` text NOT NULL,
199
+ `action_type` text NOT NULL,
200
+ `table_name` text NOT NULL,
201
+ `status` text NOT NULL,
202
+ `finished_at` integer,
203
+ `query` text NOT NULL,
204
+ `config` text,
205
+ `total_count` integer,
206
+ `processed_count` integer,
207
+ `failed_count` integer,
208
+ `log` text,
209
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
210
+ );
211
+ --> statement-breakpoint
212
+ CREATE INDEX `batch_actions_project_id_action_type_idx` ON `batch_actions` (`project_id`,`action_type`);--> statement-breakpoint
213
+ CREATE INDEX `batch_actions_status_idx` ON `batch_actions` (`status`);--> statement-breakpoint
214
+ CREATE INDEX `batch_actions_project_id_user_id_idx` ON `batch_actions` (`project_id`,`user_id`);--> statement-breakpoint
215
+ CREATE TABLE `batch_exports` (
216
+ `id` text PRIMARY KEY NOT NULL,
217
+ `created_at` integer NOT NULL,
218
+ `updated_at` integer NOT NULL,
219
+ `project_id` text NOT NULL,
220
+ `user_id` text NOT NULL,
221
+ `finished_at` integer,
222
+ `expires_at` integer,
223
+ `name` text NOT NULL,
224
+ `status` text NOT NULL,
225
+ `query` text NOT NULL,
226
+ `format` text NOT NULL,
227
+ `url` text,
228
+ `log` text,
229
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
230
+ );
231
+ --> statement-breakpoint
232
+ CREATE INDEX `batch_exports_status_idx` ON `batch_exports` (`status`);--> statement-breakpoint
233
+ CREATE INDEX `batch_exports_project_id_user_id_idx` ON `batch_exports` (`project_id`,`user_id`);--> statement-breakpoint
234
+ CREATE TABLE `billing_meter_backups` (
235
+ `stripe_customer_id` text NOT NULL,
236
+ `meter_id` text NOT NULL,
237
+ `start_time` integer NOT NULL,
238
+ `end_time` integer NOT NULL,
239
+ `aggregated_value` integer NOT NULL,
240
+ `event_name` text NOT NULL,
241
+ `org_id` text NOT NULL,
242
+ `created_at` integer NOT NULL,
243
+ `updated_at` integer NOT NULL
244
+ );
245
+ --> statement-breakpoint
246
+ CREATE UNIQUE INDEX `billing_meter_backups_stripe_customer_id_meter_id_start_time_end_time_key` ON `billing_meter_backups` (`stripe_customer_id`,`meter_id`,`start_time`,`end_time`);--> statement-breakpoint
247
+ CREATE INDEX `billing_meter_backups_stripe_customer_id_meter_id_start_time_end_time_idx` ON `billing_meter_backups` (`stripe_customer_id`,`meter_id`,`start_time`,`end_time`);--> statement-breakpoint
248
+ CREATE TABLE `blob_storage_integrations` (
249
+ `project_id` text PRIMARY KEY NOT NULL,
250
+ `type` text NOT NULL,
251
+ `bucket_name` text NOT NULL,
252
+ `prefix` text NOT NULL,
253
+ `access_key_id` text,
254
+ `secret_access_key` text,
255
+ `region` text NOT NULL,
256
+ `endpoint` text,
257
+ `force_path_style` integer NOT NULL,
258
+ `next_sync_at` integer,
259
+ `last_sync_at` integer,
260
+ `enabled` integer NOT NULL,
261
+ `export_frequency` text NOT NULL,
262
+ `file_type` text DEFAULT 'CSV' NOT NULL,
263
+ `export_mode` text DEFAULT 'FULL_HISTORY' NOT NULL,
264
+ `export_start_date` integer,
265
+ `export_source` text DEFAULT 'TRACES_OBSERVATIONS' NOT NULL,
266
+ `export_field_groups` text DEFAULT '[]' NOT NULL,
267
+ `compressed` integer DEFAULT true NOT NULL,
268
+ `export_tuning` text,
269
+ `run_started_at` integer,
270
+ `last_error` text,
271
+ `last_error_at` integer,
272
+ `last_failure_notification_sent_at` integer,
273
+ `created_at` integer NOT NULL,
274
+ `updated_at` integer NOT NULL,
275
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
276
+ );
277
+ --> statement-breakpoint
278
+ CREATE TABLE `cloud_spend_alerts` (
279
+ `id` text PRIMARY KEY NOT NULL,
280
+ `org_id` text NOT NULL,
281
+ `title` text NOT NULL,
282
+ `threshold` real NOT NULL,
283
+ `triggered_at` integer,
284
+ `created_at` integer NOT NULL,
285
+ `updated_at` integer NOT NULL,
286
+ FOREIGN KEY (`org_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade
287
+ );
288
+ --> statement-breakpoint
289
+ CREATE INDEX `cloud_spend_alerts_org_id_idx` ON `cloud_spend_alerts` (`org_id`);--> statement-breakpoint
290
+ CREATE TABLE `comment_reactions` (
291
+ `id` text PRIMARY KEY NOT NULL,
292
+ `project_id` text NOT NULL,
293
+ `comment_id` text NOT NULL,
294
+ `user_id` text NOT NULL,
295
+ `emoji` text NOT NULL,
296
+ `created_at` integer NOT NULL,
297
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
298
+ FOREIGN KEY (`comment_id`) REFERENCES `comments`(`id`) ON UPDATE cascade ON DELETE cascade,
299
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
300
+ );
301
+ --> statement-breakpoint
302
+ CREATE UNIQUE INDEX `comment_reactions_comment_id_user_id_emoji_key` ON `comment_reactions` (`comment_id`,`user_id`,`emoji`);--> statement-breakpoint
303
+ CREATE TABLE `comments` (
304
+ `id` text PRIMARY KEY NOT NULL,
305
+ `project_id` text NOT NULL,
306
+ `object_type` text NOT NULL,
307
+ `object_id` text NOT NULL,
308
+ `created_at` integer NOT NULL,
309
+ `updated_at` integer NOT NULL,
310
+ `content` text NOT NULL,
311
+ `author_user_id` text,
312
+ `data_field` text,
313
+ `path` text DEFAULT '[]' NOT NULL,
314
+ `range_start` text DEFAULT '[]' NOT NULL,
315
+ `range_end` text DEFAULT '[]' NOT NULL,
316
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
317
+ );
318
+ --> statement-breakpoint
319
+ CREATE INDEX `comments_project_id_object_type_object_id_idx` ON `comments` (`project_id`,`object_type`,`object_id`);--> statement-breakpoint
320
+ CREATE TABLE `cron_jobs` (
321
+ `name` text PRIMARY KEY NOT NULL,
322
+ `last_run` integer,
323
+ `job_started_at` integer,
324
+ `state` text
325
+ );
326
+ --> statement-breakpoint
327
+ CREATE TABLE `dashboard_widgets` (
328
+ `id` text PRIMARY KEY NOT NULL,
329
+ `created_at` integer NOT NULL,
330
+ `updated_at` integer NOT NULL,
331
+ `created_by` text,
332
+ `updated_by` text,
333
+ `project_id` text,
334
+ `name` text NOT NULL,
335
+ `description` text NOT NULL,
336
+ `view` text NOT NULL,
337
+ `dimensions` text NOT NULL,
338
+ `metrics` text NOT NULL,
339
+ `filters` text NOT NULL,
340
+ `chart_type` text NOT NULL,
341
+ `chart_config` text NOT NULL,
342
+ `min_version` integer DEFAULT 1 NOT NULL,
343
+ FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
344
+ FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
345
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
346
+ );
347
+ --> statement-breakpoint
348
+ CREATE TABLE `dashboards` (
349
+ `id` text PRIMARY KEY NOT NULL,
350
+ `created_at` integer NOT NULL,
351
+ `updated_at` integer NOT NULL,
352
+ `created_by` text,
353
+ `updated_by` text,
354
+ `project_id` text,
355
+ `name` text NOT NULL,
356
+ `description` text NOT NULL,
357
+ `definition` text NOT NULL,
358
+ `filters` text DEFAULT '[]' NOT NULL,
359
+ FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
360
+ FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
361
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
362
+ );
363
+ --> statement-breakpoint
364
+ CREATE TABLE `dataset_item_media` (
365
+ `id` text PRIMARY KEY NOT NULL,
366
+ `project_id` text NOT NULL,
367
+ `created_at` integer NOT NULL,
368
+ `updated_at` integer NOT NULL,
369
+ `media_id` text NOT NULL,
370
+ `dataset_id` text NOT NULL,
371
+ `dataset_item_id` text NOT NULL,
372
+ `dataset_item_valid_from` integer,
373
+ `field` text NOT NULL,
374
+ `json_path` text,
375
+ `reference_string` text
376
+ );
377
+ --> statement-breakpoint
378
+ CREATE UNIQUE INDEX `dataset_item_media_item_version_field_path_key` ON `dataset_item_media` (`project_id`,`dataset_item_id`,`dataset_item_valid_from`,`field`,`json_path`);--> statement-breakpoint
379
+ CREATE INDEX `dataset_item_media_project_id_dataset_id_idx` ON `dataset_item_media` (`project_id`,`dataset_id`);--> statement-breakpoint
380
+ CREATE INDEX `dataset_item_media_project_id_media_id_idx` ON `dataset_item_media` (`project_id`,`media_id`);--> statement-breakpoint
381
+ CREATE TABLE `dataset_items` (
382
+ `id` text NOT NULL,
383
+ `project_id` text NOT NULL,
384
+ `status` text DEFAULT 'ACTIVE',
385
+ `input` text,
386
+ `expected_output` text,
387
+ `metadata` text,
388
+ `source_trace_id` text,
389
+ `source_observation_id` text,
390
+ `dataset_id` text NOT NULL,
391
+ `created_at` integer NOT NULL,
392
+ `updated_at` integer NOT NULL,
393
+ `valid_from` integer NOT NULL,
394
+ `valid_to` integer,
395
+ `is_deleted` integer DEFAULT false NOT NULL,
396
+ PRIMARY KEY(`id`, `project_id`, `valid_from`),
397
+ FOREIGN KEY (`dataset_id`,`project_id`) REFERENCES `datasets`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade
398
+ );
399
+ --> statement-breakpoint
400
+ CREATE INDEX `dataset_items_updated_at_idx` ON `dataset_items` (`updated_at`);--> statement-breakpoint
401
+ CREATE INDEX `dataset_items_created_at_idx` ON `dataset_items` (`created_at`);--> statement-breakpoint
402
+ CREATE INDEX `dataset_items_dataset_id_idx` ON `dataset_items` (`dataset_id`);--> statement-breakpoint
403
+ CREATE INDEX `dataset_items_source_observation_id_idx` ON `dataset_items` (`source_observation_id`);--> statement-breakpoint
404
+ CREATE INDEX `dataset_items_source_trace_id_idx` ON `dataset_items` (`source_trace_id`);--> statement-breakpoint
405
+ CREATE INDEX `dataset_items_project_id_id_valid_from_idx` ON `dataset_items` (`project_id`,`id`,`valid_from`);--> statement-breakpoint
406
+ CREATE INDEX `dataset_items_project_id_valid_to_idx` ON `dataset_items` (`project_id`,`valid_to`);--> statement-breakpoint
407
+ CREATE TABLE `dataset_runs` (
408
+ `id` text NOT NULL,
409
+ `project_id` text NOT NULL,
410
+ `name` text NOT NULL,
411
+ `description` text,
412
+ `metadata` text,
413
+ `dataset_id` text NOT NULL,
414
+ `created_at` integer NOT NULL,
415
+ `updated_at` integer NOT NULL,
416
+ PRIMARY KEY(`id`, `project_id`),
417
+ FOREIGN KEY (`dataset_id`,`project_id`) REFERENCES `datasets`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade
418
+ );
419
+ --> statement-breakpoint
420
+ CREATE UNIQUE INDEX `dataset_runs_dataset_id_project_id_name_key` ON `dataset_runs` (`dataset_id`,`project_id`,`name`);--> statement-breakpoint
421
+ CREATE INDEX `dataset_runs_updated_at_idx` ON `dataset_runs` (`updated_at`);--> statement-breakpoint
422
+ CREATE INDEX `dataset_runs_created_at_idx` ON `dataset_runs` (`created_at`);--> statement-breakpoint
423
+ CREATE INDEX `dataset_runs_dataset_id_idx` ON `dataset_runs` (`dataset_id`);--> statement-breakpoint
424
+ CREATE TABLE `datasets` (
425
+ `id` text NOT NULL,
426
+ `project_id` text NOT NULL,
427
+ `name` text NOT NULL,
428
+ `description` text,
429
+ `metadata` text,
430
+ `remote_experiment_url` text,
431
+ `remote_experiment_payload` text,
432
+ `remote_experiment_enabled` integer DEFAULT true NOT NULL,
433
+ `input_schema` text,
434
+ `expected_output_schema` text,
435
+ `created_at` integer NOT NULL,
436
+ `updated_at` integer NOT NULL,
437
+ PRIMARY KEY(`id`, `project_id`),
438
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
439
+ );
440
+ --> statement-breakpoint
441
+ CREATE UNIQUE INDEX `datasets_project_id_name_key` ON `datasets` (`project_id`,`name`);--> statement-breakpoint
442
+ CREATE INDEX `datasets_updated_at_idx` ON `datasets` (`updated_at`);--> statement-breakpoint
443
+ CREATE INDEX `datasets_created_at_idx` ON `datasets` (`created_at`);--> statement-breakpoint
444
+ CREATE TABLE `default_llm_models` (
445
+ `id` text PRIMARY KEY NOT NULL,
446
+ `created_at` integer NOT NULL,
447
+ `updated_at` integer NOT NULL,
448
+ `project_id` text NOT NULL,
449
+ `llm_api_key_id` text NOT NULL,
450
+ `provider` text NOT NULL,
451
+ `adapter` text NOT NULL,
452
+ `model` text NOT NULL,
453
+ `model_params` text,
454
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
455
+ FOREIGN KEY (`llm_api_key_id`) REFERENCES `llm_api_keys`(`id`) ON UPDATE cascade ON DELETE cascade
456
+ );
457
+ --> statement-breakpoint
458
+ CREATE UNIQUE INDEX `default_llm_models_project_id_key` ON `default_llm_models` (`project_id`);--> statement-breakpoint
459
+ CREATE TABLE `default_views` (
460
+ `id` text PRIMARY KEY NOT NULL,
461
+ `created_at` integer NOT NULL,
462
+ `updated_at` integer NOT NULL,
463
+ `project_id` text NOT NULL,
464
+ `user_id` text,
465
+ `view_name` text NOT NULL,
466
+ `view_id` text NOT NULL,
467
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
468
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
469
+ );
470
+ --> statement-breakpoint
471
+ CREATE INDEX `default_views_project_id_view_name_idx` ON `default_views` (`project_id`,`view_name`);--> statement-breakpoint
472
+ CREATE TABLE `eval_templates` (
473
+ `id` text PRIMARY KEY NOT NULL,
474
+ `created_at` integer NOT NULL,
475
+ `updated_at` integer NOT NULL,
476
+ `project_id` text,
477
+ `name` text NOT NULL,
478
+ `version` integer NOT NULL,
479
+ `prompt` text,
480
+ `type` text DEFAULT 'LLM_AS_JUDGE' NOT NULL,
481
+ `partner` text,
482
+ `model` text,
483
+ `provider` text,
484
+ `model_params` text,
485
+ `vars` text DEFAULT '[]' NOT NULL,
486
+ `output_schema` text,
487
+ `source_code` text,
488
+ `source_code_language` text,
489
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
490
+ );
491
+ --> statement-breakpoint
492
+ CREATE UNIQUE INDEX `eval_templates_project_id_name_version_key` ON `eval_templates` (`project_id`,`name`,`version`);--> statement-breakpoint
493
+ CREATE INDEX `eval_templates_project_id_id_idx` ON `eval_templates` (`project_id`,`id`);--> statement-breakpoint
494
+ CREATE TABLE `in_app_agent_conversations` (
495
+ `id` text NOT NULL,
496
+ `project_id` text NOT NULL,
497
+ `created_by_user_id` text,
498
+ `title` text,
499
+ `renamed_by_user_at` integer,
500
+ `visibility_scope` text DEFAULT 'PERSONAL' NOT NULL,
501
+ `provider_session_id` text,
502
+ `deleted_at` integer,
503
+ `created_at` integer NOT NULL,
504
+ `updated_at` integer NOT NULL,
505
+ PRIMARY KEY(`id`, `project_id`),
506
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
507
+ FOREIGN KEY (`created_by_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null
508
+ );
509
+ --> statement-breakpoint
510
+ CREATE INDEX `in_app_agent_conversations_project_user_list_idx` ON `in_app_agent_conversations` (`project_id`,`created_by_user_id`,`deleted_at`,`updated_at`,`id`);--> statement-breakpoint
511
+ CREATE TABLE `in_app_agent_events` (
512
+ `project_id` text NOT NULL,
513
+ `conversation_id` text NOT NULL,
514
+ `run_id` text NOT NULL,
515
+ `sequence_number` integer NOT NULL,
516
+ `type` text NOT NULL,
517
+ `event` text NOT NULL,
518
+ `created_at` integer NOT NULL,
519
+ PRIMARY KEY(`project_id`, `conversation_id`, `sequence_number`),
520
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
521
+ FOREIGN KEY (`run_id`,`project_id`) REFERENCES `in_app_agent_runs`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade,
522
+ FOREIGN KEY (`conversation_id`,`project_id`) REFERENCES `in_app_agent_conversations`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade
523
+ );
524
+ --> statement-breakpoint
525
+ CREATE INDEX `in_app_agent_events_project_run_idx` ON `in_app_agent_events` (`project_id`,`run_id`);--> statement-breakpoint
526
+ CREATE TABLE `in_app_agent_pending_tool_approvals` (
527
+ `project_id` text NOT NULL,
528
+ `conversation_id` text NOT NULL,
529
+ `tool_call_id` text NOT NULL,
530
+ `approval_fingerprint` text NOT NULL,
531
+ `expires_at` integer NOT NULL,
532
+ `created_at` integer NOT NULL,
533
+ `updated_at` integer NOT NULL,
534
+ PRIMARY KEY(`project_id`, `conversation_id`, `tool_call_id`),
535
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
536
+ FOREIGN KEY (`conversation_id`,`project_id`) REFERENCES `in_app_agent_conversations`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade
537
+ );
538
+ --> statement-breakpoint
539
+ CREATE INDEX `in_app_agent_pending_tool_approvals_expires_at_idx` ON `in_app_agent_pending_tool_approvals` (`expires_at`);--> statement-breakpoint
540
+ CREATE TABLE `in_app_agent_runs` (
541
+ `id` text NOT NULL,
542
+ `project_id` text NOT NULL,
543
+ `conversation_id` text NOT NULL,
544
+ `triggered_by_user_id` text,
545
+ `model` text,
546
+ `mcp_api_key_id` text,
547
+ `error_code` text,
548
+ `error_message` text,
549
+ `finished_at` integer,
550
+ `status` text,
551
+ `request` text,
552
+ `claimed_at` integer,
553
+ `heartbeat_at` integer,
554
+ `cancel_requested_at` integer,
555
+ `created_at` integer NOT NULL,
556
+ `updated_at` integer NOT NULL,
557
+ PRIMARY KEY(`id`, `project_id`),
558
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
559
+ FOREIGN KEY (`triggered_by_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
560
+ FOREIGN KEY (`conversation_id`,`project_id`) REFERENCES `in_app_agent_conversations`(`id`,`project_id`) ON UPDATE cascade ON DELETE cascade
561
+ );
562
+ --> statement-breakpoint
563
+ CREATE INDEX `in_app_agent_runs_project_conversation_created_idx` ON `in_app_agent_runs` (`project_id`,`conversation_id`,`created_at`);--> statement-breakpoint
564
+ CREATE TABLE `job_configurations` (
565
+ `id` text PRIMARY KEY NOT NULL,
566
+ `created_at` integer NOT NULL,
567
+ `updated_at` integer NOT NULL,
568
+ `project_id` text NOT NULL,
569
+ `job_type` text NOT NULL,
570
+ `status` text DEFAULT 'ACTIVE' NOT NULL,
571
+ `blocked_at` integer,
572
+ `block_reason` text,
573
+ `block_message` text,
574
+ `eval_template_id` text,
575
+ `score_name` text NOT NULL,
576
+ `filter` text NOT NULL,
577
+ `target_object` text NOT NULL,
578
+ `variable_mapping` text NOT NULL,
579
+ `sampling` real NOT NULL,
580
+ `delay` integer NOT NULL,
581
+ `time_scope` text DEFAULT '[]' NOT NULL,
582
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
583
+ FOREIGN KEY (`eval_template_id`) REFERENCES `eval_templates`(`id`) ON UPDATE cascade ON DELETE set null
584
+ );
585
+ --> statement-breakpoint
586
+ CREATE INDEX `job_configurations_project_id_id_idx` ON `job_configurations` (`project_id`,`id`);--> statement-breakpoint
587
+ CREATE TABLE `job_executions` (
588
+ `id` text PRIMARY KEY NOT NULL,
589
+ `created_at` integer NOT NULL,
590
+ `updated_at` integer NOT NULL,
591
+ `project_id` text NOT NULL,
592
+ `job_configuration_id` text NOT NULL,
593
+ `job_template_id` text,
594
+ `status` text NOT NULL,
595
+ `start_time` integer,
596
+ `end_time` integer,
597
+ `error` text,
598
+ `job_input_trace_id` text,
599
+ `job_input_trace_timestamp` integer,
600
+ `job_input_observation_id` text,
601
+ `job_input_dataset_item_id` text,
602
+ `job_input_dataset_item_valid_from` integer,
603
+ `job_output_score_id` text,
604
+ `execution_trace_id` text,
605
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
606
+ FOREIGN KEY (`job_configuration_id`) REFERENCES `job_configurations`(`id`) ON UPDATE cascade ON DELETE cascade
607
+ );
608
+ --> statement-breakpoint
609
+ CREATE INDEX `job_executions_job_configuration_id_idx` ON `job_executions` (`job_configuration_id`);--> statement-breakpoint
610
+ CREATE INDEX `job_executions_project_id_job_output_score_id_idx` ON `job_executions` (`project_id`,`job_output_score_id`);--> statement-breakpoint
611
+ CREATE INDEX `job_executions_project_id_job_configuration_id_job_input_trace_id_idx` ON `job_executions` (`project_id`,`job_configuration_id`,`job_input_trace_id`);--> statement-breakpoint
612
+ CREATE TABLE `llm_api_keys` (
613
+ `id` text PRIMARY KEY NOT NULL,
614
+ `created_at` integer NOT NULL,
615
+ `updated_at` integer NOT NULL,
616
+ `provider` text NOT NULL,
617
+ `adapter` text NOT NULL,
618
+ `display_secret_key` text NOT NULL,
619
+ `secret_key` text NOT NULL,
620
+ `base_url` text,
621
+ `custom_models` text DEFAULT '[]' NOT NULL,
622
+ `with_default_models` integer DEFAULT true NOT NULL,
623
+ `extra_headers` text,
624
+ `extra_header_keys` text DEFAULT '[]' NOT NULL,
625
+ `config` text,
626
+ `project_id` text NOT NULL,
627
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
628
+ );
629
+ --> statement-breakpoint
630
+ CREATE UNIQUE INDEX `llm_api_keys_project_id_provider_key` ON `llm_api_keys` (`project_id`,`provider`);--> statement-breakpoint
631
+ CREATE UNIQUE INDEX `llm_api_keys_id_key` ON `llm_api_keys` (`id`);--> statement-breakpoint
632
+ CREATE TABLE `llm_schemas` (
633
+ `id` text PRIMARY KEY NOT NULL,
634
+ `created_at` integer NOT NULL,
635
+ `updated_at` integer NOT NULL,
636
+ `project_id` text NOT NULL,
637
+ `name` text NOT NULL,
638
+ `description` text NOT NULL,
639
+ `schema` text NOT NULL,
640
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
641
+ );
642
+ --> statement-breakpoint
643
+ CREATE UNIQUE INDEX `llm_schemas_project_id_name_key` ON `llm_schemas` (`project_id`,`name`);--> statement-breakpoint
644
+ CREATE TABLE `llm_tools` (
645
+ `id` text PRIMARY KEY NOT NULL,
646
+ `created_at` integer NOT NULL,
647
+ `updated_at` integer NOT NULL,
648
+ `project_id` text NOT NULL,
649
+ `name` text NOT NULL,
650
+ `description` text NOT NULL,
651
+ `parameters` text NOT NULL,
652
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
653
+ );
654
+ --> statement-breakpoint
655
+ CREATE UNIQUE INDEX `llm_tools_project_id_name_key` ON `llm_tools` (`project_id`,`name`);--> statement-breakpoint
656
+ CREATE TABLE `media` (
657
+ `id` text NOT NULL,
658
+ `sha_256_hash` text NOT NULL,
659
+ `project_id` text NOT NULL,
660
+ `created_at` integer NOT NULL,
661
+ `updated_at` integer NOT NULL,
662
+ `uploaded_at` integer,
663
+ `upload_http_status` integer,
664
+ `upload_http_error` text,
665
+ `bucket_path` text NOT NULL,
666
+ `bucket_name` text NOT NULL,
667
+ `content_type` text NOT NULL,
668
+ `content_length` integer NOT NULL,
669
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
670
+ );
671
+ --> statement-breakpoint
672
+ CREATE UNIQUE INDEX `media_project_id_sha_256_hash_key` ON `media` (`project_id`,`sha_256_hash`);--> statement-breakpoint
673
+ CREATE UNIQUE INDEX `media_project_id_id_key` ON `media` (`project_id`,`id`);--> statement-breakpoint
674
+ CREATE INDEX `media_project_id_created_at_idx` ON `media` (`project_id`,`created_at`);--> statement-breakpoint
675
+ CREATE TABLE `membership_invitations` (
676
+ `id` text PRIMARY KEY NOT NULL,
677
+ `email` text NOT NULL,
678
+ `org_id` text NOT NULL,
679
+ `org_role` text NOT NULL,
680
+ `project_id` text,
681
+ `project_role` text,
682
+ `invited_by_user_id` text,
683
+ `created_at` integer NOT NULL,
684
+ `updated_at` integer NOT NULL,
685
+ FOREIGN KEY (`org_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade,
686
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE set null,
687
+ FOREIGN KEY (`invited_by_user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null
688
+ );
689
+ --> statement-breakpoint
690
+ CREATE UNIQUE INDEX `membership_invitations_email_org_id_key` ON `membership_invitations` (`email`,`org_id`);--> statement-breakpoint
691
+ CREATE INDEX `membership_invitations_email_idx` ON `membership_invitations` (`email`);--> statement-breakpoint
692
+ CREATE INDEX `membership_invitations_org_id_idx` ON `membership_invitations` (`org_id`);--> statement-breakpoint
693
+ CREATE INDEX `membership_invitations_project_id_idx` ON `membership_invitations` (`project_id`);--> statement-breakpoint
694
+ CREATE UNIQUE INDEX `membership_invitations_id_key` ON `membership_invitations` (`id`);--> statement-breakpoint
695
+ CREATE TABLE `mixpanel_integrations` (
696
+ `project_id` text PRIMARY KEY NOT NULL,
697
+ `encrypted_mixpanel_project_token` text NOT NULL,
698
+ `mixpanel_region` text NOT NULL,
699
+ `last_sync_at` integer,
700
+ `enabled` integer NOT NULL,
701
+ `created_at` integer NOT NULL,
702
+ `export_source` text DEFAULT 'TRACES_OBSERVATIONS' NOT NULL,
703
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
704
+ );
705
+ --> statement-breakpoint
706
+ CREATE TABLE `models` (
707
+ `id` text PRIMARY KEY NOT NULL,
708
+ `created_at` integer NOT NULL,
709
+ `updated_at` integer NOT NULL,
710
+ `project_id` text,
711
+ `model_name` text NOT NULL,
712
+ `match_pattern` text NOT NULL,
713
+ `start_date` integer,
714
+ `input_price` real,
715
+ `output_price` real,
716
+ `total_price` real,
717
+ `unit` text,
718
+ `tokenizer_id` text,
719
+ `tokenizer_config` text,
720
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
721
+ );
722
+ --> statement-breakpoint
723
+ CREATE UNIQUE INDEX `models_project_id_model_name_start_date_unit_key` ON `models` (`project_id`,`model_name`,`start_date`,`unit`);--> statement-breakpoint
724
+ CREATE INDEX `models_model_name_idx` ON `models` (`model_name`);--> statement-breakpoint
725
+ CREATE TABLE `monitors` (
726
+ `id` text PRIMARY KEY NOT NULL,
727
+ `created_at` integer NOT NULL,
728
+ `updated_at` integer NOT NULL,
729
+ `created_by` text,
730
+ `updated_by` text,
731
+ `project_id` text NOT NULL,
732
+ `view` text NOT NULL,
733
+ `filters` text NOT NULL,
734
+ `metric` text NOT NULL,
735
+ `window_ms` integer NOT NULL,
736
+ `cadence_ms` integer NOT NULL,
737
+ `threshold_operator` text NOT NULL,
738
+ `alert_threshold` real NOT NULL,
739
+ `warning_threshold` real,
740
+ `severity` text DEFAULT 'UNKNOWN' NOT NULL,
741
+ `severity_changed_at` integer,
742
+ `no_data` text NOT NULL,
743
+ `renotify` text NOT NULL,
744
+ `status` text DEFAULT 'ACTIVE' NOT NULL,
745
+ `scheduler_batch_id` integer NOT NULL,
746
+ `next_run_at` integer,
747
+ `last_published_at` integer,
748
+ `last_claimed_at` integer,
749
+ `last_completed_at` integer,
750
+ `name` text NOT NULL,
751
+ `tags` text DEFAULT '[]' NOT NULL,
752
+ `trigger_ids` text DEFAULT '[]' NOT NULL,
753
+ `alerted_at` integer,
754
+ FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
755
+ FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
756
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
757
+ );
758
+ --> statement-breakpoint
759
+ CREATE INDEX `monitors_scheduler_tick_idx` ON `monitors` (`next_run_at`,`scheduler_batch_id`);--> statement-breakpoint
760
+ CREATE INDEX `monitors_scheduler_batch_id_idx` ON `monitors` (`scheduler_batch_id`);--> statement-breakpoint
761
+ CREATE INDEX `monitors_project_id_idx` ON `monitors` (`project_id`);--> statement-breakpoint
762
+ CREATE TABLE `notification_preferences` (
763
+ `id` text PRIMARY KEY NOT NULL,
764
+ `user_id` text NOT NULL,
765
+ `project_id` text NOT NULL,
766
+ `channel` text NOT NULL,
767
+ `type` text NOT NULL,
768
+ `enabled` integer DEFAULT true NOT NULL,
769
+ `created_at` integer NOT NULL,
770
+ `updated_at` integer NOT NULL,
771
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade,
772
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
773
+ );
774
+ --> statement-breakpoint
775
+ CREATE UNIQUE INDEX `notification_preferences_user_id_project_id_channel_type_key` ON `notification_preferences` (`user_id`,`project_id`,`channel`,`type`);--> statement-breakpoint
776
+ CREATE TABLE `observation_media` (
777
+ `id` text PRIMARY KEY NOT NULL,
778
+ `project_id` text NOT NULL,
779
+ `created_at` integer NOT NULL,
780
+ `updated_at` integer NOT NULL,
781
+ `media_id` text NOT NULL,
782
+ `trace_id` text NOT NULL,
783
+ `observation_id` text NOT NULL,
784
+ `field` text NOT NULL
785
+ );
786
+ --> statement-breakpoint
787
+ CREATE UNIQUE INDEX `observation_media_project_id_trace_id_observation_id_media_id_field_key` ON `observation_media` (`project_id`,`trace_id`,`observation_id`,`media_id`,`field`);--> statement-breakpoint
788
+ CREATE INDEX `observation_media_project_id_media_id_idx` ON `observation_media` (`project_id`,`media_id`);--> statement-breakpoint
789
+ CREATE TABLE `organization_memberships` (
790
+ `id` text PRIMARY KEY NOT NULL,
791
+ `org_id` text NOT NULL,
792
+ `user_id` text NOT NULL,
793
+ `role` text NOT NULL,
794
+ `created_at` integer NOT NULL,
795
+ `updated_at` integer NOT NULL,
796
+ FOREIGN KEY (`org_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade,
797
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
798
+ );
799
+ --> statement-breakpoint
800
+ CREATE UNIQUE INDEX `organization_memberships_org_id_user_id_key` ON `organization_memberships` (`org_id`,`user_id`);--> statement-breakpoint
801
+ CREATE INDEX `organization_memberships_user_id_idx` ON `organization_memberships` (`user_id`);--> statement-breakpoint
802
+ CREATE TABLE `organizations` (
803
+ `id` text PRIMARY KEY NOT NULL,
804
+ `name` text NOT NULL,
805
+ `created_at` integer NOT NULL,
806
+ `updated_at` integer NOT NULL,
807
+ `cloud_config` text,
808
+ `metadata` text,
809
+ `cloud_billing_cycle_anchor` integer,
810
+ `cloud_billing_cycle_updated_at` integer,
811
+ `cloud_current_cycle_usage` integer,
812
+ `cloud_free_tier_usage_threshold_state` text,
813
+ `ai_features_enabled` integer DEFAULT false NOT NULL,
814
+ `ai_telemetry_enabled` integer DEFAULT true NOT NULL,
815
+ `sfdc_org_id` text
816
+ );
817
+ --> statement-breakpoint
818
+ CREATE TABLE `pending_deletions` (
819
+ `id` text PRIMARY KEY NOT NULL,
820
+ `project_id` text NOT NULL,
821
+ `object` text NOT NULL,
822
+ `object_id` text NOT NULL,
823
+ `is_deleted` integer DEFAULT false NOT NULL,
824
+ `created_at` integer NOT NULL,
825
+ `updated_at` integer NOT NULL,
826
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
827
+ );
828
+ --> statement-breakpoint
829
+ CREATE INDEX `pending_deletions_object_id_object_idx` ON `pending_deletions` (`object_id`,`object`);--> statement-breakpoint
830
+ CREATE INDEX `pending_deletions_project_id_object_is_deleted_object_id_id_idx` ON `pending_deletions` (`project_id`,`object`,`is_deleted`,`object_id`,`id`);--> statement-breakpoint
831
+ CREATE TABLE `posthog_integrations` (
832
+ `project_id` text PRIMARY KEY NOT NULL,
833
+ `encrypted_posthog_api_key` text NOT NULL,
834
+ `posthog_host_name` text NOT NULL,
835
+ `last_sync_at` integer,
836
+ `enabled` integer NOT NULL,
837
+ `created_at` integer NOT NULL,
838
+ `export_source` text DEFAULT 'TRACES_OBSERVATIONS' NOT NULL,
839
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
840
+ );
841
+ --> statement-breakpoint
842
+ CREATE TABLE `prices` (
843
+ `id` text PRIMARY KEY NOT NULL,
844
+ `created_at` integer NOT NULL,
845
+ `updated_at` integer NOT NULL,
846
+ `model_id` text NOT NULL,
847
+ `project_id` text,
848
+ `pricing_tier_id` text NOT NULL,
849
+ `usage_type` text NOT NULL,
850
+ `price` real NOT NULL,
851
+ FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE cascade ON DELETE cascade,
852
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
853
+ FOREIGN KEY (`pricing_tier_id`) REFERENCES `pricing_tiers`(`id`) ON UPDATE cascade ON DELETE cascade
854
+ );
855
+ --> statement-breakpoint
856
+ CREATE UNIQUE INDEX `prices_model_id_usage_type_pricing_tier_id_key` ON `prices` (`model_id`,`usage_type`,`pricing_tier_id`);--> statement-breakpoint
857
+ CREATE INDEX `prices_pricing_tier_id_idx` ON `prices` (`pricing_tier_id`);--> statement-breakpoint
858
+ CREATE TABLE `pricing_tiers` (
859
+ `id` text PRIMARY KEY NOT NULL,
860
+ `created_at` integer NOT NULL,
861
+ `updated_at` integer NOT NULL,
862
+ `model_id` text NOT NULL,
863
+ `name` text NOT NULL,
864
+ `is_default` integer DEFAULT false NOT NULL,
865
+ `priority` integer NOT NULL,
866
+ `conditions` text NOT NULL,
867
+ FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE cascade ON DELETE cascade
868
+ );
869
+ --> statement-breakpoint
870
+ CREATE UNIQUE INDEX `pricing_tiers_model_id_name_key` ON `pricing_tiers` (`model_id`,`name`);--> statement-breakpoint
871
+ CREATE UNIQUE INDEX `pricing_tiers_model_id_priority_key` ON `pricing_tiers` (`model_id`,`priority`);--> statement-breakpoint
872
+ CREATE TABLE `project_memberships` (
873
+ `org_membership_id` text NOT NULL,
874
+ `project_id` text NOT NULL,
875
+ `user_id` text NOT NULL,
876
+ `role` text NOT NULL,
877
+ `created_at` integer NOT NULL,
878
+ `updated_at` integer NOT NULL,
879
+ PRIMARY KEY(`project_id`, `user_id`),
880
+ FOREIGN KEY (`org_membership_id`) REFERENCES `organization_memberships`(`id`) ON UPDATE cascade ON DELETE cascade,
881
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
882
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
883
+ );
884
+ --> statement-breakpoint
885
+ CREATE INDEX `project_memberships_org_membership_id_idx` ON `project_memberships` (`org_membership_id`);--> statement-breakpoint
886
+ CREATE INDEX `project_memberships_project_id_idx` ON `project_memberships` (`project_id`);--> statement-breakpoint
887
+ CREATE INDEX `project_memberships_user_id_idx` ON `project_memberships` (`user_id`);--> statement-breakpoint
888
+ CREATE TABLE `projects` (
889
+ `id` text PRIMARY KEY NOT NULL,
890
+ `org_id` text NOT NULL,
891
+ `created_at` integer NOT NULL,
892
+ `updated_at` integer NOT NULL,
893
+ `deleted_at` integer,
894
+ `name` text NOT NULL,
895
+ `retention_days` integer,
896
+ `has_traces` integer DEFAULT false NOT NULL,
897
+ `metadata` text,
898
+ `home_dashboard_id` text,
899
+ FOREIGN KEY (`org_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade,
900
+ FOREIGN KEY (`home_dashboard_id`) REFERENCES `dashboards`(`id`) ON UPDATE cascade ON DELETE set null
901
+ );
902
+ --> statement-breakpoint
903
+ CREATE INDEX `projects_org_id_idx` ON `projects` (`org_id`);--> statement-breakpoint
904
+ CREATE TABLE `prompt_dependencies` (
905
+ `id` text PRIMARY KEY NOT NULL,
906
+ `created_at` integer NOT NULL,
907
+ `updated_at` integer NOT NULL,
908
+ `project_id` text NOT NULL,
909
+ `parent_id` text NOT NULL,
910
+ `child_name` text NOT NULL,
911
+ `child_label` text,
912
+ `child_version` integer,
913
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
914
+ FOREIGN KEY (`parent_id`) REFERENCES `prompts`(`id`) ON UPDATE cascade ON DELETE cascade
915
+ );
916
+ --> statement-breakpoint
917
+ CREATE INDEX `prompt_dependencies_project_id_child_name` ON `prompt_dependencies` (`project_id`,`child_name`);--> statement-breakpoint
918
+ CREATE INDEX `prompt_dependencies_project_id_parent_id` ON `prompt_dependencies` (`project_id`,`parent_id`);--> statement-breakpoint
919
+ CREATE TABLE `prompt_protected_labels` (
920
+ `id` text PRIMARY KEY NOT NULL,
921
+ `created_at` integer NOT NULL,
922
+ `updated_at` integer NOT NULL,
923
+ `project_id` text NOT NULL,
924
+ `label` text NOT NULL,
925
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
926
+ );
927
+ --> statement-breakpoint
928
+ CREATE UNIQUE INDEX `prompt_protected_labels_project_id_label_key` ON `prompt_protected_labels` (`project_id`,`label`);--> statement-breakpoint
929
+ CREATE TABLE `prompts` (
930
+ `id` text PRIMARY KEY NOT NULL,
931
+ `created_at` integer NOT NULL,
932
+ `updated_at` integer NOT NULL,
933
+ `project_id` text NOT NULL,
934
+ `created_by` text NOT NULL,
935
+ `prompt` text NOT NULL,
936
+ `name` text NOT NULL,
937
+ `version` integer NOT NULL,
938
+ `type` text DEFAULT 'text' NOT NULL,
939
+ `is_active` integer,
940
+ `config` text DEFAULT '{}' NOT NULL,
941
+ `tags` text DEFAULT '[]' NOT NULL,
942
+ `labels` text DEFAULT '[]' NOT NULL,
943
+ `commit_message` text,
944
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
945
+ );
946
+ --> statement-breakpoint
947
+ CREATE UNIQUE INDEX `prompts_project_id_name_version_key` ON `prompts` (`project_id`,`name`,`version`);--> statement-breakpoint
948
+ CREATE INDEX `prompts_tags_idx` ON `prompts` (`tags`);--> statement-breakpoint
949
+ CREATE INDEX `prompts_updated_at_idx` ON `prompts` (`updated_at`);--> statement-breakpoint
950
+ CREATE INDEX `prompts_created_at_idx` ON `prompts` (`created_at`);--> statement-breakpoint
951
+ CREATE INDEX `prompts_project_id_id_idx` ON `prompts` (`project_id`,`id`);--> statement-breakpoint
952
+ CREATE TABLE `score_configs` (
953
+ `id` text PRIMARY KEY NOT NULL,
954
+ `created_at` integer NOT NULL,
955
+ `updated_at` integer NOT NULL,
956
+ `project_id` text NOT NULL,
957
+ `name` text NOT NULL,
958
+ `data_type` text NOT NULL,
959
+ `is_archived` integer DEFAULT false NOT NULL,
960
+ `min_value` real,
961
+ `max_value` real,
962
+ `categories` text,
963
+ `description` text,
964
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
965
+ );
966
+ --> statement-breakpoint
967
+ CREATE UNIQUE INDEX `score_configs_id_project_id_key` ON `score_configs` (`id`,`project_id`);--> statement-breakpoint
968
+ CREATE INDEX `score_configs_updated_at_idx` ON `score_configs` (`updated_at`);--> statement-breakpoint
969
+ CREATE INDEX `score_configs_created_at_idx` ON `score_configs` (`created_at`);--> statement-breakpoint
970
+ CREATE INDEX `score_configs_categories_idx` ON `score_configs` (`categories`);--> statement-breakpoint
971
+ CREATE INDEX `score_configs_project_id_idx` ON `score_configs` (`project_id`);--> statement-breakpoint
972
+ CREATE INDEX `score_configs_is_archived_idx` ON `score_configs` (`is_archived`);--> statement-breakpoint
973
+ CREATE INDEX `score_configs_data_type_idx` ON `score_configs` (`data_type`);--> statement-breakpoint
974
+ CREATE TABLE `Session` (
975
+ `id` text PRIMARY KEY NOT NULL,
976
+ `session_token` text NOT NULL,
977
+ `user_id` text NOT NULL,
978
+ `expires` integer NOT NULL,
979
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
980
+ );
981
+ --> statement-breakpoint
982
+ CREATE UNIQUE INDEX `Session_session_token_key` ON `Session` (`session_token`);--> statement-breakpoint
983
+ CREATE TABLE `slack_integrations` (
984
+ `id` text PRIMARY KEY NOT NULL,
985
+ `project_id` text NOT NULL,
986
+ `team_id` text NOT NULL,
987
+ `team_name` text NOT NULL,
988
+ `bot_token` text NOT NULL,
989
+ `bot_user_id` text NOT NULL,
990
+ `created_at` integer NOT NULL,
991
+ `updated_at` integer NOT NULL,
992
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
993
+ );
994
+ --> statement-breakpoint
995
+ CREATE INDEX `slack_integrations_team_id_idx` ON `slack_integrations` (`team_id`);--> statement-breakpoint
996
+ CREATE UNIQUE INDEX `slack_integrations_project_id_key` ON `slack_integrations` (`project_id`);--> statement-breakpoint
997
+ CREATE TABLE `sso_configs` (
998
+ `domain` text PRIMARY KEY NOT NULL,
999
+ `created_at` integer NOT NULL,
1000
+ `updated_at` integer NOT NULL,
1001
+ `auth_provider` text NOT NULL,
1002
+ `auth_config` text
1003
+ );
1004
+ --> statement-breakpoint
1005
+ CREATE TABLE `surveys` (
1006
+ `id` text PRIMARY KEY NOT NULL,
1007
+ `created_at` integer NOT NULL,
1008
+ `survey_name` text NOT NULL,
1009
+ `response` text NOT NULL,
1010
+ `user_id` text,
1011
+ `user_email` text,
1012
+ `org_id` text,
1013
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade,
1014
+ FOREIGN KEY (`org_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade
1015
+ );
1016
+ --> statement-breakpoint
1017
+ CREATE TABLE `table_view_presets` (
1018
+ `id` text PRIMARY KEY NOT NULL,
1019
+ `created_at` integer NOT NULL,
1020
+ `updated_at` integer NOT NULL,
1021
+ `project_id` text NOT NULL,
1022
+ `name` text NOT NULL,
1023
+ `table_name` text NOT NULL,
1024
+ `created_by` text,
1025
+ `updated_by` text,
1026
+ `filters` text NOT NULL,
1027
+ `column_order` text NOT NULL,
1028
+ `column_visibility` text NOT NULL,
1029
+ `search_query` text,
1030
+ `order_by` text,
1031
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade,
1032
+ FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
1033
+ FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null
1034
+ );
1035
+ --> statement-breakpoint
1036
+ CREATE UNIQUE INDEX `table_view_presets_project_id_table_name_name_key` ON `table_view_presets` (`project_id`,`table_name`,`name`);--> statement-breakpoint
1037
+ CREATE TABLE `trace_media` (
1038
+ `id` text PRIMARY KEY NOT NULL,
1039
+ `project_id` text NOT NULL,
1040
+ `created_at` integer NOT NULL,
1041
+ `updated_at` integer NOT NULL,
1042
+ `media_id` text NOT NULL,
1043
+ `trace_id` text NOT NULL,
1044
+ `field` text NOT NULL
1045
+ );
1046
+ --> statement-breakpoint
1047
+ CREATE UNIQUE INDEX `trace_media_project_id_trace_id_media_id_field_key` ON `trace_media` (`project_id`,`trace_id`,`media_id`,`field`);--> statement-breakpoint
1048
+ CREATE INDEX `trace_media_project_id_media_id_idx` ON `trace_media` (`project_id`,`media_id`);--> statement-breakpoint
1049
+ CREATE TABLE `trace_sessions` (
1050
+ `id` text NOT NULL,
1051
+ `created_at` integer NOT NULL,
1052
+ `updated_at` integer NOT NULL,
1053
+ `project_id` text NOT NULL,
1054
+ `bookmarked` integer DEFAULT false NOT NULL,
1055
+ `public` integer DEFAULT false NOT NULL,
1056
+ `environment` text DEFAULT 'default' NOT NULL,
1057
+ PRIMARY KEY(`id`, `project_id`),
1058
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
1059
+ );
1060
+ --> statement-breakpoint
1061
+ CREATE INDEX `trace_sessions_project_id_created_at_idx` ON `trace_sessions` (`project_id`,`created_at`);--> statement-breakpoint
1062
+ CREATE TABLE `triggers` (
1063
+ `id` text PRIMARY KEY NOT NULL,
1064
+ `created_at` integer NOT NULL,
1065
+ `updated_at` integer NOT NULL,
1066
+ `project_id` text NOT NULL,
1067
+ `eventSource` text NOT NULL,
1068
+ `eventActions` text NOT NULL,
1069
+ `filter` text,
1070
+ `status` text DEFAULT 'ACTIVE' NOT NULL,
1071
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
1072
+ );
1073
+ --> statement-breakpoint
1074
+ CREATE INDEX `triggers_project_id_idx` ON `triggers` (`project_id`);--> statement-breakpoint
1075
+ CREATE TABLE `users` (
1076
+ `id` text PRIMARY KEY NOT NULL,
1077
+ `name` text,
1078
+ `email` text,
1079
+ `email_verified` integer,
1080
+ `password` text,
1081
+ `image` text,
1082
+ `admin` integer DEFAULT false NOT NULL,
1083
+ `v4_beta_enabled` integer DEFAULT false NOT NULL,
1084
+ `created_at` integer NOT NULL,
1085
+ `updated_at` integer NOT NULL,
1086
+ `feature_flags` text DEFAULT '[]' NOT NULL
1087
+ );
1088
+ --> statement-breakpoint
1089
+ CREATE UNIQUE INDEX `users_email_key` ON `users` (`email`);--> statement-breakpoint
1090
+ CREATE TABLE `verification_tokens` (
1091
+ `identifier` text NOT NULL,
1092
+ `token` text NOT NULL,
1093
+ `expires` integer NOT NULL
1094
+ );
1095
+ --> statement-breakpoint
1096
+ CREATE UNIQUE INDEX `verification_tokens_identifier_token_key` ON `verification_tokens` (`identifier`,`token`);--> statement-breakpoint
1097
+ CREATE UNIQUE INDEX `verification_tokens_token_key` ON `verification_tokens` (`token`);--> statement-breakpoint
1098
+ CREATE TABLE `verified_domains` (
1099
+ `id` text PRIMARY KEY NOT NULL,
1100
+ `organization_id` text NOT NULL,
1101
+ `domain` text NOT NULL,
1102
+ `verification_token` text NOT NULL,
1103
+ `verified_at` integer,
1104
+ `created_by_user_id` text,
1105
+ `created_at` integer NOT NULL,
1106
+ `updated_at` integer NOT NULL,
1107
+ FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade
1108
+ );
1109
+ --> statement-breakpoint
1110
+ CREATE UNIQUE INDEX `verified_domains_organization_id_domain_key` ON `verified_domains` (`organization_id`,`domain`);--> statement-breakpoint
1111
+ CREATE INDEX `verified_domains_organization_id_idx` ON `verified_domains` (`organization_id`);--> statement-breakpoint
1112
+ CREATE UNIQUE INDEX `verified_domains_verification_token_key` ON `verified_domains` (`verification_token`);--> statement-breakpoint
1113
+ CREATE TABLE `web_callout_endpoints` (
1114
+ `id` text PRIMARY KEY NOT NULL,
1115
+ `created_at` integer NOT NULL,
1116
+ `updated_at` integer NOT NULL,
1117
+ `project_id` text NOT NULL,
1118
+ `name` text DEFAULT 'Default' NOT NULL,
1119
+ `url` text NOT NULL,
1120
+ `enabled` integer DEFAULT true NOT NULL,
1121
+ `toast_message` text DEFAULT 'Callout sent' NOT NULL,
1122
+ `request_headers` text,
1123
+ `request_header_keys` text DEFAULT '[]' NOT NULL,
1124
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE cascade ON DELETE cascade
1125
+ );
1126
+ --> statement-breakpoint
1127
+ CREATE INDEX `web_callout_endpoints_project_id_enabled_idx` ON `web_callout_endpoints` (`project_id`,`enabled`);--> statement-breakpoint
1128
+ CREATE INDEX `web_callout_endpoints_project_id_idx` ON `web_callout_endpoints` (`project_id`);