@onequery/cli 0.0.0-bootstrap.0-darwin-arm64 → 0.0.0-bootstrap.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 (125) hide show
  1. package/bin/onequery.js +156 -0
  2. package/bin/package-constants.js +95 -0
  3. package/package.json +20 -15
  4. package/runtime/migrations/20260327065242_curious_nightmare.sql +403 -0
  5. package/runtime/migrations/meta/20260327065242_snapshot.json +2817 -0
  6. package/runtime/migrations/meta/_journal.json +13 -0
  7. package/runtime/web/assets/CompositeItem-BV7KhPQk.js +1 -0
  8. package/runtime/web/assets/CompositeList-CX7HHxYw.js +1 -0
  9. package/runtime/web/assets/DialogTitle-z5f0waCI.js +1 -0
  10. package/runtime/web/assets/IconArrowRight-DsOD7mDl.js +1 -0
  11. package/runtime/web/assets/IconCheck-Gc24xPT2.js +1 -0
  12. package/runtime/web/assets/IconChevronDown-B-39MA7-.js +1 -0
  13. package/runtime/web/assets/IconCoins-C7Nn0L6R.js +1 -0
  14. package/runtime/web/assets/IconHistory-BqAd-xl2.js +1 -0
  15. package/runtime/web/assets/IconLoader2-B3B6M8nQ.js +1 -0
  16. package/runtime/web/assets/IconPlus-C3-kRhGX.js +1 -0
  17. package/runtime/web/assets/IconX-BQkA009b.js +1 -0
  18. package/runtime/web/assets/Separator-vw4jPN_6.js +1 -0
  19. package/runtime/web/assets/_authenticated-C5CjK6Mu.js +1 -0
  20. package/runtime/web/assets/_org_slug-D94kykq2.js +1 -0
  21. package/runtime/web/assets/api-base-url-DIb6qukm.js +1 -0
  22. package/runtime/web/assets/api-client-w1GRwBWy.js +1 -0
  23. package/runtime/web/assets/api-error-KjK7uFAE.js +1 -0
  24. package/runtime/web/assets/api-paths-ClEWWGwS.js +1 -0
  25. package/runtime/web/assets/app-routes-DdRvA1bK.js +1 -0
  26. package/runtime/web/assets/audit-TXhp0u8O.js +1 -0
  27. package/runtime/web/assets/auth-bootstrap-query-BhAn1APx.js +1 -0
  28. package/runtime/web/assets/auth-client-BlMeXgb4.js +3 -0
  29. package/runtime/web/assets/avatar-DzUYMSvr.js +1 -0
  30. package/runtime/web/assets/badge-DHOXVqXh.js +1 -0
  31. package/runtime/web/assets/budget-BaZbMGkP.js +1 -0
  32. package/runtime/web/assets/callback-8KQafZFQ.js +1 -0
  33. package/runtime/web/assets/card-Bsy6azfK.js +1 -0
  34. package/runtime/web/assets/checkbox-L6MjK5Df.js +1 -0
  35. package/runtime/web/assets/compiler-runtime-DCc3R3Xn.js +1 -0
  36. package/runtime/web/assets/connect-database-DhHeQ0pY.js +1 -0
  37. package/runtime/web/assets/create-org-C60JHlxs.js +1 -0
  38. package/runtime/web/assets/createReactComponent-_L2mp4Ui.js +1 -0
  39. package/runtime/web/assets/data-source-connection-form-Dbf1vMmU.js +173 -0
  40. package/runtime/web/assets/device-BKmB0Ojy.js +1 -0
  41. package/runtime/web/assets/dropdown-menu-CEyg7UUK.js +1 -0
  42. package/runtime/web/assets/empty-COnWCwda.js +1 -0
  43. package/runtime/web/assets/getDisabledMountTransitionStyles-BYKRz4ha.js +1 -0
  44. package/runtime/web/assets/getPseudoElementBounds-InhM-dWf.js +12 -0
  45. package/runtime/web/assets/home-BN45-W_R.js +1 -0
  46. package/runtime/web/assets/index-Dh_88m70.js +10 -0
  47. package/runtime/web/assets/index-FAyK3-UK.css +2 -0
  48. package/runtime/web/assets/input-DZ9QHu2b.js +1 -0
  49. package/runtime/web/assets/integrations-BSVo3EhL.js +1 -0
  50. package/runtime/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  51. package/runtime/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  52. package/runtime/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  53. package/runtime/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  54. package/runtime/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  55. package/runtime/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  56. package/runtime/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  57. package/runtime/web/assets/invite._invitationId-BFlHHn20.js +1 -0
  58. package/runtime/web/assets/jsx-runtime-DG_AJzB_.js +1 -0
  59. package/runtime/web/assets/label-CWOhoN_L.js +1 -0
  60. package/runtime/web/assets/link-Cgvqhh5w.js +1 -0
  61. package/runtime/web/assets/matchContext-CDajBC0L.js +1 -0
  62. package/runtime/web/assets/organization-permissions-BQQ5PJbI.js +1 -0
  63. package/runtime/web/assets/organization-query-keys-uOvv8Ob1.js +1 -0
  64. package/runtime/web/assets/query-timing-LGzitMXx.js +1 -0
  65. package/runtime/web/assets/queryOptions-BHw87wTZ.js +1 -0
  66. package/runtime/web/assets/removable-BfDesq3B.js +1 -0
  67. package/runtime/web/assets/routes-6XMkyZd6.js +1 -0
  68. package/runtime/web/assets/schemas-BdEYnr23.js +39 -0
  69. package/runtime/web/assets/select-CxmfKkmB.js +1 -0
  70. package/runtime/web/assets/separator-BQc-hryc.js +1 -0
  71. package/runtime/web/assets/settings-5_Ep5M2N.js +1 -0
  72. package/runtime/web/assets/signin-BtRJc1yx.js +1 -0
  73. package/runtime/web/assets/src-DCIPwIx0.js +1 -0
  74. package/runtime/web/assets/table-DCvfJyLS.js +1 -0
  75. package/runtime/web/assets/team-DrtYsBm8.js +1 -0
  76. package/runtime/web/assets/textarea-DiU04l_U.js +1 -0
  77. package/runtime/web/assets/theme-toggle-b9r_T-hF.js +1 -0
  78. package/runtime/web/assets/use-optimistic-mutation-BlewMk5s.js +1 -0
  79. package/runtime/web/assets/useBaseQuery-BATLGzdG.js +1 -0
  80. package/runtime/web/assets/useBaseUiId-BLFGpnYJ.js +1 -0
  81. package/runtime/web/assets/useCompositeItem-DkdkBgiU.js +1 -0
  82. package/runtime/web/assets/useControlled-C1S7R-1A.js +1 -0
  83. package/runtime/web/assets/useQuery-FSZF3_9j.js +1 -0
  84. package/runtime/web/assets/useRender-DFMo54_d.js +1 -0
  85. package/runtime/web/assets/useRouterState-DpT8luFk.js +1 -0
  86. package/runtime/web/assets/useSuspenseQuery-BGsqElb3.js +1 -0
  87. package/runtime/web/assets/useValueChanged-CqxkrqWn.js +1 -0
  88. package/runtime/web/assets/utils-C8DGLIgm.js +1 -0
  89. package/runtime/web/assets/xstate-react.esm-BlF76DuP.js +1 -0
  90. package/runtime/web/assets/zod-D2loGbpH.js +1 -0
  91. package/runtime/web/images/amplitude/step1_settings_sidebar.png +0 -0
  92. package/runtime/web/images/amplitude/step2_projects.png +0 -0
  93. package/runtime/web/images/amplitude/step3_project_keys.png +0 -0
  94. package/runtime/web/images/amplitude/step4_api_keys.png +0 -0
  95. package/runtime/web/images/bigquery/step1_service_accounts.png +0 -0
  96. package/runtime/web/images/bigquery/step2_bigquery_roles.png +0 -0
  97. package/runtime/web/images/bigquery/step3_add_key_menu.png +0 -0
  98. package/runtime/web/images/bigquery/step4_create_json_key.png +0 -0
  99. package/runtime/web/images/ga4/step1_service_accounts.png +0 -0
  100. package/runtime/web/images/ga4/step2_create_json_key.png +0 -0
  101. package/runtime/web/images/ga4/step3_add_user_viewer.png +0 -0
  102. package/runtime/web/images/ga4/step4_property_details.png +0 -0
  103. package/runtime/web/images/github-token-guide/step1_signin.png +0 -0
  104. package/runtime/web/images/github-token-guide/step2_new_fine_grained_token_sanitized.png +0 -0
  105. package/runtime/web/images/github-token-guide/step3_permissions_configured_sanitized.png +0 -0
  106. package/runtime/web/images/github-token-guide/step4_token_created_sanitized.png +0 -0
  107. package/runtime/web/images/mixpanel/step1_service_accounts.png +0 -0
  108. package/runtime/web/images/mixpanel/step2_create_service_account.png +0 -0
  109. package/runtime/web/images/mixpanel/step3_credentials.png +0 -0
  110. package/runtime/web/images/mixpanel/step4_project_settings.png +0 -0
  111. package/runtime/web/images/postgresql/step1_create_user.png +0 -0
  112. package/runtime/web/images/postgresql/step2_connection.png +0 -0
  113. package/runtime/web/images/rds/step1_connect.png +0 -0
  114. package/runtime/web/images/rds/step2_create_user.png +0 -0
  115. package/runtime/web/images/rds/step3_grant.png +0 -0
  116. package/runtime/web/images/rds/step4_info.png +0 -0
  117. package/runtime/web/images/sentry/step1_personal_tokens.png +0 -0
  118. package/runtime/web/images/sentry/step2_create_token_permissions.png +0 -0
  119. package/runtime/web/images/sentry/step3_organization_slug.png +0 -0
  120. package/runtime/web/images/sentry/step4_project_slug.png +0 -0
  121. package/runtime/web/index.html +47 -0
  122. package/runtime/web/linear.svg +1 -0
  123. package/runtime/web/onequery.svg +14 -0
  124. package/vendor/aarch64-apple-darwin/onequery/onequery +0 -0
  125. package/vendor/aarch64-apple-darwin/server/onequery-server +0 -0
@@ -0,0 +1,403 @@
1
+ CREATE TABLE "account" (
2
+ "access_token" text,
3
+ "access_token_expires_at" timestamp,
4
+ "account_id" text NOT NULL,
5
+ "created_at" timestamp DEFAULT now() NOT NULL,
6
+ "id" text PRIMARY KEY NOT NULL,
7
+ "id_token" text,
8
+ "password" text,
9
+ "provider_id" text NOT NULL,
10
+ "refresh_token" text,
11
+ "refresh_token_expires_at" timestamp,
12
+ "scope" text,
13
+ "updated_at" timestamp DEFAULT now() NOT NULL,
14
+ "user_id" text NOT NULL
15
+ );
16
+ --> statement-breakpoint
17
+ ALTER TABLE "account" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
18
+ CREATE TABLE "device_code" (
19
+ "client_id" text,
20
+ "device_code" text NOT NULL,
21
+ "expires_at" timestamp NOT NULL,
22
+ "id" text PRIMARY KEY NOT NULL,
23
+ "last_polled_at" timestamp,
24
+ "polling_interval" integer,
25
+ "scope" text,
26
+ "status" text NOT NULL,
27
+ "user_code" text NOT NULL,
28
+ "user_id" text
29
+ );
30
+ --> statement-breakpoint
31
+ ALTER TABLE "device_code" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
32
+ CREATE TABLE "invitation" (
33
+ "created_at" timestamp DEFAULT now() NOT NULL,
34
+ "email" text NOT NULL,
35
+ "expires_at" timestamp NOT NULL,
36
+ "id" text PRIMARY KEY NOT NULL,
37
+ "inviter_id" text NOT NULL,
38
+ "organization_id" text NOT NULL,
39
+ "role" text,
40
+ "status" text NOT NULL
41
+ );
42
+ --> statement-breakpoint
43
+ ALTER TABLE "invitation" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
44
+ CREATE TABLE "member" (
45
+ "created_at" timestamp DEFAULT now() NOT NULL,
46
+ "id" text PRIMARY KEY NOT NULL,
47
+ "organization_id" text NOT NULL,
48
+ "role" text NOT NULL,
49
+ "user_id" text NOT NULL
50
+ );
51
+ --> statement-breakpoint
52
+ ALTER TABLE "member" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
53
+ CREATE TABLE "organization" (
54
+ "created_at" timestamp DEFAULT now() NOT NULL,
55
+ "id" text PRIMARY KEY NOT NULL,
56
+ "logo" text,
57
+ "metadata" text,
58
+ "name" text NOT NULL,
59
+ "slug" text,
60
+ CONSTRAINT "organization_slug_unique" UNIQUE("slug")
61
+ );
62
+ --> statement-breakpoint
63
+ ALTER TABLE "organization" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
64
+ CREATE TABLE "session" (
65
+ "active_organization_id" text,
66
+ "created_at" timestamp DEFAULT now() NOT NULL,
67
+ "expires_at" timestamp NOT NULL,
68
+ "id" text PRIMARY KEY NOT NULL,
69
+ "ip_address" text,
70
+ "token" text NOT NULL,
71
+ "updated_at" timestamp DEFAULT now() NOT NULL,
72
+ "user_agent" text,
73
+ "user_id" text NOT NULL,
74
+ CONSTRAINT "session_token_unique" UNIQUE("token")
75
+ );
76
+ --> statement-breakpoint
77
+ ALTER TABLE "session" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
78
+ CREATE TABLE "user" (
79
+ "created_at" timestamp DEFAULT now() NOT NULL,
80
+ "email" text NOT NULL,
81
+ "email_verified" boolean DEFAULT false NOT NULL,
82
+ "id" text PRIMARY KEY NOT NULL,
83
+ "image" text,
84
+ "name" text NOT NULL,
85
+ "updated_at" timestamp DEFAULT now() NOT NULL,
86
+ CONSTRAINT "user_email_unique" UNIQUE("email")
87
+ );
88
+ --> statement-breakpoint
89
+ ALTER TABLE "user" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
90
+ CREATE TABLE "verification" (
91
+ "created_at" timestamp DEFAULT now() NOT NULL,
92
+ "expires_at" timestamp NOT NULL,
93
+ "id" text PRIMARY KEY NOT NULL,
94
+ "identifier" text NOT NULL,
95
+ "updated_at" timestamp DEFAULT now() NOT NULL,
96
+ "value" text NOT NULL
97
+ );
98
+ --> statement-breakpoint
99
+ ALTER TABLE "verification" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
100
+ CREATE TABLE "bigquery_query_costs" (
101
+ "actual_bytes_billed" bigint,
102
+ "actual_bytes_processed" bigint,
103
+ "actual_cost_usd" double precision,
104
+ "cache_hit" boolean,
105
+ "connection_name" text NOT NULL,
106
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
107
+ "currency" text DEFAULT 'USD' NOT NULL,
108
+ "estimated_bytes_processed" bigint,
109
+ "estimated_cost_usd" double precision,
110
+ "executed_at" timestamp with time zone NOT NULL,
111
+ "id" text PRIMARY KEY NOT NULL,
112
+ "job_id" text,
113
+ "location" text,
114
+ "organization_id" text NOT NULL,
115
+ "pricing_model" text DEFAULT 'unknown' NOT NULL,
116
+ "query_id" text NOT NULL,
117
+ "tool_call_id" text NOT NULL
118
+ );
119
+ --> statement-breakpoint
120
+ ALTER TABLE "bigquery_query_costs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
121
+ CREATE TABLE "cli_query_actions" (
122
+ "id" text PRIMARY KEY NOT NULL,
123
+ "organization_id" text NOT NULL,
124
+ "actor_user_id" text NOT NULL,
125
+ "actor_email" text NOT NULL,
126
+ "actor_auth_mode" text NOT NULL,
127
+ "actor_membership_roles" jsonb NOT NULL,
128
+ "request_id" text NOT NULL,
129
+ "action_type" text NOT NULL,
130
+ "stage" text DEFAULT 'received' NOT NULL,
131
+ "status" text DEFAULT 'pending' NOT NULL,
132
+ "usage_persistence_status" text DEFAULT 'not_started' NOT NULL,
133
+ "source_key" text NOT NULL,
134
+ "source_id" text,
135
+ "provider" text,
136
+ "source_status" text,
137
+ "sql" text NOT NULL,
138
+ "normalized_sql" text,
139
+ "max_rows" integer,
140
+ "max_bytes" integer,
141
+ "cell_max_chars" integer,
142
+ "timeout_ms" integer,
143
+ "normalized_sql_changed" boolean DEFAULT false NOT NULL,
144
+ "row_count" integer,
145
+ "elapsed_ms" integer,
146
+ "error_detail" text,
147
+ "error_hint" text,
148
+ "retryable" boolean,
149
+ "last_event_id" text,
150
+ "last_event_at" timestamp with time zone DEFAULT now() NOT NULL,
151
+ "completed_at" timestamp with time zone,
152
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
153
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
154
+ "version" integer DEFAULT 1 NOT NULL,
155
+ CONSTRAINT "cli_query_actions_identity_unique" UNIQUE("id","organization_id","request_id","action_type","source_key"),
156
+ CONSTRAINT "cli_query_actions_action_type_check" CHECK ("cli_query_actions"."action_type" in ('validate', 'execute')),
157
+ CONSTRAINT "cli_query_actions_actor_auth_mode_check" CHECK ("cli_query_actions"."actor_auth_mode" in ('browser_session', 'bearer_token')),
158
+ CONSTRAINT "cli_query_actions_stage_check" CHECK ("cli_query_actions"."stage" in ('received', 'load_source', 'validate_query', 'load_credentials', 'execute_query', 'persist_usage', 'completed')),
159
+ CONSTRAINT "cli_query_actions_status_check" CHECK ("cli_query_actions"."status" in ('pending', 'succeeded', 'source_not_found', 'source_not_queryable', 'query_rejected', 'query_preparation_failed', 'query_unavailable', 'query_timed_out', 'query_execution_failed')),
160
+ CONSTRAINT "cli_query_actions_usage_persistence_status_check" CHECK ("cli_query_actions"."usage_persistence_status" in ('not_started', 'succeeded', 'failed')),
161
+ CONSTRAINT "cli_query_actions_completed_stage_check" CHECK (( (stage = 'completed' and completed_at is not null) or (stage <> 'completed' and completed_at is null) )),
162
+ CONSTRAINT "cli_query_actions_stage_status_alignment_check" CHECK (( (stage = 'completed' and status <> 'pending') or (stage <> 'completed' and status = 'pending') )),
163
+ CONSTRAINT "cli_query_actions_pre_completion_usage_check" CHECK (( stage = 'completed' or usage_persistence_status = 'not_started' ))
164
+ );
165
+ --> statement-breakpoint
166
+ ALTER TABLE "cli_query_actions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
167
+ CREATE TABLE "cli_query_action_events" (
168
+ "id" text PRIMARY KEY NOT NULL,
169
+ "query_action_id" text NOT NULL,
170
+ "organization_id" text NOT NULL,
171
+ "actor_user_id" text NOT NULL,
172
+ "actor_email" text NOT NULL,
173
+ "actor_auth_mode" text NOT NULL,
174
+ "actor_membership_roles" jsonb NOT NULL,
175
+ "request_id" text NOT NULL,
176
+ "action_type" text NOT NULL,
177
+ "event_type" text NOT NULL,
178
+ "stage" text NOT NULL,
179
+ "status" text NOT NULL,
180
+ "usage_persistence_status" text NOT NULL,
181
+ "source_key" text NOT NULL,
182
+ "source_id" text,
183
+ "provider" text,
184
+ "source_status" text,
185
+ "sql" text,
186
+ "normalized_sql" text,
187
+ "max_rows" integer,
188
+ "max_bytes" integer,
189
+ "cell_max_chars" integer,
190
+ "timeout_ms" integer,
191
+ "normalized_sql_changed" boolean DEFAULT false NOT NULL,
192
+ "row_count" integer,
193
+ "elapsed_ms" integer,
194
+ "error_detail" text,
195
+ "error_hint" text,
196
+ "retryable" boolean,
197
+ "occurred_at" timestamp with time zone NOT NULL,
198
+ "causation_event_id" text,
199
+ "org_slug" text,
200
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
201
+ CONSTRAINT "cli_query_action_events_action_id_unique" UNIQUE("query_action_id","id"),
202
+ CONSTRAINT "cli_query_action_events_sql_payload_check" CHECK (( (event_type = 'action_received' and sql is not null) or (event_type <> 'action_received' and sql is null) )),
203
+ CONSTRAINT "cli_query_action_events_causation_chain_check" CHECK (( (event_type = 'action_received' and causation_event_id is null) or (event_type <> 'action_received' and causation_event_id is not null) )),
204
+ CONSTRAINT "cli_query_action_events_validated_normalized_sql_check" CHECK ((event_type <> 'query_validated' or normalized_sql is not null)),
205
+ CONSTRAINT "cli_query_action_events_lifecycle_check" CHECK (( (event_type = 'action_received' and stage = 'received' and status = 'pending' and usage_persistence_status = 'not_started') or (event_type = 'source_loaded' and stage = 'validate_query' and status = 'pending' and usage_persistence_status = 'not_started') or (event_type = 'source_not_found' and stage = 'completed' and status = 'source_not_found' and usage_persistence_status = 'not_started') or (event_type = 'source_not_queryable' and stage = 'completed' and status = 'source_not_queryable' and usage_persistence_status = 'not_started') or ( event_type = 'query_validated' and ( (action_type = 'validate' and stage = 'completed' and status = 'succeeded' and usage_persistence_status = 'not_started') or (action_type = 'execute' and stage = 'load_credentials' and status = 'pending' and usage_persistence_status = 'not_started') ) ) or (event_type = 'query_rejected' and stage = 'completed' and status = 'query_rejected' and usage_persistence_status = 'not_started') or (event_type = 'credentials_loaded' and stage = 'execute_query' and status = 'pending' and usage_persistence_status = 'not_started') or (event_type = 'query_preparation_failed' and stage = 'completed' and status = 'query_preparation_failed' and usage_persistence_status = 'not_started') or (event_type = 'query_executed' and stage = 'persist_usage' and status = 'pending' and usage_persistence_status = 'not_started') or (event_type = 'query_unavailable' and stage = 'completed' and status = 'query_unavailable' and usage_persistence_status = 'not_started') or (event_type = 'query_timed_out' and stage = 'completed' and status = 'query_timed_out' and usage_persistence_status = 'not_started') or (event_type = 'query_execution_failed' and stage = 'completed' and status = 'query_execution_failed' and usage_persistence_status = 'not_started') or (event_type = 'usage_persisted' and stage = 'completed' and status = 'succeeded' and usage_persistence_status = 'succeeded') or (event_type = 'usage_persist_failed' and stage = 'completed' and status = 'succeeded' and usage_persistence_status = 'failed') )),
206
+ CONSTRAINT "cli_query_action_events_action_type_check" CHECK ("cli_query_action_events"."action_type" in ('validate', 'execute')),
207
+ CONSTRAINT "cli_query_action_events_actor_auth_mode_check" CHECK ("cli_query_action_events"."actor_auth_mode" in ('browser_session', 'bearer_token')),
208
+ CONSTRAINT "cli_query_action_events_event_type_check" CHECK ("cli_query_action_events"."event_type" in ('action_received', 'source_loaded', 'source_not_found', 'source_not_queryable', 'query_validated', 'query_rejected', 'credentials_loaded', 'query_preparation_failed', 'query_executed', 'query_unavailable', 'query_timed_out', 'query_execution_failed', 'usage_persisted', 'usage_persist_failed')),
209
+ CONSTRAINT "cli_query_action_events_stage_check" CHECK ("cli_query_action_events"."stage" in ('received', 'load_source', 'validate_query', 'load_credentials', 'execute_query', 'persist_usage', 'completed')),
210
+ CONSTRAINT "cli_query_action_events_status_check" CHECK ("cli_query_action_events"."status" in ('pending', 'succeeded', 'source_not_found', 'source_not_queryable', 'query_rejected', 'query_preparation_failed', 'query_unavailable', 'query_timed_out', 'query_execution_failed')),
211
+ CONSTRAINT "cli_query_action_events_usage_persistence_status_check" CHECK ("cli_query_action_events"."usage_persistence_status" in ('not_started', 'succeeded', 'failed')),
212
+ CONSTRAINT "cli_query_action_events_causation_not_self_check" CHECK ("cli_query_action_events"."causation_event_id" is null or "cli_query_action_events"."causation_event_id" <> "cli_query_action_events"."id")
213
+ );
214
+ --> statement-breakpoint
215
+ ALTER TABLE "cli_query_action_events" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
216
+ CREATE TABLE "connector_jobs" (
217
+ "completed_at" timestamp with time zone,
218
+ "connector_id" text NOT NULL,
219
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
220
+ "database" text NOT NULL,
221
+ "job_id" text PRIMARY KEY NOT NULL,
222
+ "leased_at" timestamp with time zone,
223
+ "max_rows" integer,
224
+ "outcome" jsonb,
225
+ "sql" text NOT NULL,
226
+ "status" text NOT NULL,
227
+ "timeout_ms" integer,
228
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
229
+ "workgroup" text
230
+ );
231
+ --> statement-breakpoint
232
+ ALTER TABLE "connector_jobs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
233
+ CREATE TABLE "connectors" (
234
+ "auth_token_hash" text NOT NULL,
235
+ "connector_id" text PRIMARY KEY NOT NULL,
236
+ "connector_name" text NOT NULL,
237
+ "health_status" text,
238
+ "last_heartbeat_at" timestamp with time zone,
239
+ "last_seen_at" timestamp with time zone,
240
+ "metadata" jsonb,
241
+ "organization_id" text NOT NULL,
242
+ "registered_at" timestamp with time zone DEFAULT now() NOT NULL,
243
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
244
+ );
245
+ --> statement-breakpoint
246
+ ALTER TABLE "connectors" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
247
+ CREATE TABLE "data_source_query_costs" (
248
+ "actual_cost_usd" double precision,
249
+ "actual_processed_bytes" bigint,
250
+ "billable_bytes" bigint,
251
+ "cache_hit" boolean,
252
+ "connection_name" text NOT NULL,
253
+ "connector_id" text,
254
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
255
+ "currency" text DEFAULT 'USD' NOT NULL,
256
+ "database" text,
257
+ "estimated_cost_usd" double precision,
258
+ "estimated_processed_bytes" bigint,
259
+ "executed_at" timestamp with time zone NOT NULL,
260
+ "execution_time_ms" integer,
261
+ "id" text PRIMARY KEY NOT NULL,
262
+ "job_id" text,
263
+ "location" text,
264
+ "organization_id" text NOT NULL,
265
+ "pricing_model" text DEFAULT 'unknown' NOT NULL,
266
+ "provider" text NOT NULL,
267
+ "query_execution_id" text,
268
+ "query_id" text NOT NULL,
269
+ "row_count" integer,
270
+ "tool_call_id" text NOT NULL,
271
+ "workgroup" text
272
+ );
273
+ --> statement-breakpoint
274
+ ALTER TABLE "data_source_query_costs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
275
+ CREATE TABLE "data_sources" (
276
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
277
+ "credentials_encrypted" text NOT NULL,
278
+ "credentials_iv" text NOT NULL,
279
+ "error_message" text,
280
+ "id" text PRIMARY KEY NOT NULL,
281
+ "last_used_at" timestamp with time zone,
282
+ "name" text NOT NULL,
283
+ "organization_id" text NOT NULL,
284
+ "provider" text NOT NULL,
285
+ "provider_account_id" text,
286
+ "scope" text,
287
+ "status" text DEFAULT 'active' NOT NULL,
288
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
289
+ "use_as_data_source" boolean DEFAULT true NOT NULL,
290
+ CONSTRAINT "data_sources_organization_name_unique" UNIQUE("organization_id","name")
291
+ );
292
+ --> statement-breakpoint
293
+ ALTER TABLE "data_sources" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
294
+ CREATE TABLE "data_source_table_usage" (
295
+ "column_memos" jsonb DEFAULT '{}'::jsonb NOT NULL,
296
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
297
+ "data_source_id" text NOT NULL,
298
+ "formatted" text NOT NULL,
299
+ "generated_at" timestamp with time zone NOT NULL,
300
+ "id" text PRIMARY KEY NOT NULL,
301
+ "memo_updated_at" timestamp with time zone,
302
+ "memo_updated_by" text,
303
+ "organization_id" text NOT NULL,
304
+ "provider" text NOT NULL,
305
+ "schema_hash" text,
306
+ "table_lineage" jsonb DEFAULT '{}'::jsonb NOT NULL,
307
+ "table_memos" jsonb DEFAULT '{}'::jsonb NOT NULL,
308
+ "tables" jsonb NOT NULL,
309
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
310
+ );
311
+ --> statement-breakpoint
312
+ ALTER TABLE "data_source_table_usage" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
313
+ CREATE TABLE "organization_profiles" (
314
+ "id" text PRIMARY KEY NOT NULL,
315
+ "organization_id" text NOT NULL,
316
+ "north_star_metric" text,
317
+ "kpis" jsonb DEFAULT '[]'::jsonb NOT NULL,
318
+ "website_url" text,
319
+ "monthly_budget_usd" double precision,
320
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
321
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
322
+ );
323
+ --> statement-breakpoint
324
+ ALTER TABLE "organization_profiles" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
325
+ CREATE TABLE "user_profiles" (
326
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
327
+ "id" text PRIMARY KEY NOT NULL,
328
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
329
+ "user_id" text NOT NULL
330
+ );
331
+ --> statement-breakpoint
332
+ ALTER TABLE "user_profiles" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
333
+ ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
334
+ ALTER TABLE "device_code" ADD CONSTRAINT "device_code_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
335
+ ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
336
+ ALTER TABLE "invitation" ADD CONSTRAINT "invitation_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
337
+ ALTER TABLE "member" ADD CONSTRAINT "member_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
338
+ ALTER TABLE "member" ADD CONSTRAINT "member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
339
+ ALTER TABLE "session" ADD CONSTRAINT "session_active_organization_id_organization_id_fk" FOREIGN KEY ("active_organization_id") REFERENCES "public"."organization"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
340
+ ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
341
+ ALTER TABLE "bigquery_query_costs" ADD CONSTRAINT "bigquery_query_costs_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
342
+ ALTER TABLE "cli_query_actions" ADD CONSTRAINT "cli_query_actions_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
343
+ ALTER TABLE "cli_query_actions" ADD CONSTRAINT "cli_query_actions_source_id_data_sources_id_fk" FOREIGN KEY ("source_id") REFERENCES "public"."data_sources"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
344
+ ALTER TABLE "cli_query_actions" ADD CONSTRAINT "cli_query_actions_same_action_last_event_fk" FOREIGN KEY ("id","last_event_id") REFERENCES "public"."cli_query_action_events"("query_action_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
345
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_query_action_id_cli_query_actions_id_fk" FOREIGN KEY ("query_action_id") REFERENCES "public"."cli_query_actions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
346
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
347
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_source_id_data_sources_id_fk" FOREIGN KEY ("source_id") REFERENCES "public"."data_sources"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
348
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_action_identity_fk" FOREIGN KEY ("query_action_id","organization_id","request_id","action_type","source_key") REFERENCES "public"."cli_query_actions"("id","organization_id","request_id","action_type","source_key") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
349
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_same_action_causation_fk" FOREIGN KEY ("query_action_id","causation_event_id") REFERENCES "public"."cli_query_action_events"("query_action_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
350
+ ALTER TABLE "cli_query_action_events" ADD CONSTRAINT "cli_query_action_events_causation_event_id_cli_query_action_events_id_fk" FOREIGN KEY ("causation_event_id") REFERENCES "public"."cli_query_action_events"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
351
+ ALTER TABLE "connector_jobs" ADD CONSTRAINT "connector_jobs_connector_id_connectors_connector_id_fk" FOREIGN KEY ("connector_id") REFERENCES "public"."connectors"("connector_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
352
+ ALTER TABLE "connectors" ADD CONSTRAINT "connectors_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
353
+ ALTER TABLE "data_source_query_costs" ADD CONSTRAINT "data_source_query_costs_connector_id_connectors_connector_id_fk" FOREIGN KEY ("connector_id") REFERENCES "public"."connectors"("connector_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
354
+ ALTER TABLE "data_source_query_costs" ADD CONSTRAINT "data_source_query_costs_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
355
+ ALTER TABLE "data_sources" ADD CONSTRAINT "data_sources_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
356
+ ALTER TABLE "data_source_table_usage" ADD CONSTRAINT "data_source_table_usage_data_source_id_data_sources_id_fk" FOREIGN KEY ("data_source_id") REFERENCES "public"."data_sources"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
357
+ ALTER TABLE "data_source_table_usage" ADD CONSTRAINT "data_source_table_usage_memo_updated_by_user_id_fk" FOREIGN KEY ("memo_updated_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
358
+ ALTER TABLE "data_source_table_usage" ADD CONSTRAINT "data_source_table_usage_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
359
+ ALTER TABLE "organization_profiles" ADD CONSTRAINT "organization_profiles_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
360
+ ALTER TABLE "user_profiles" ADD CONSTRAINT "user_profiles_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
361
+ CREATE INDEX "account_userId_idx" ON "account" USING btree ("user_id");--> statement-breakpoint
362
+ CREATE UNIQUE INDEX "device_code_device_code_key" ON "device_code" USING btree ("device_code");--> statement-breakpoint
363
+ CREATE UNIQUE INDEX "device_code_user_code_key" ON "device_code" USING btree ("user_code");--> statement-breakpoint
364
+ CREATE INDEX "device_code_user_id_idx" ON "device_code" USING btree ("user_id");--> statement-breakpoint
365
+ CREATE INDEX "device_code_expires_at_idx" ON "device_code" USING btree ("expires_at");--> statement-breakpoint
366
+ CREATE INDEX "invitation_organizationId_idx" ON "invitation" USING btree ("organization_id");--> statement-breakpoint
367
+ CREATE INDEX "invitation_email_idx" ON "invitation" USING btree ("email");--> statement-breakpoint
368
+ CREATE INDEX "member_organizationId_idx" ON "member" USING btree ("organization_id");--> statement-breakpoint
369
+ CREATE INDEX "member_userId_idx" ON "member" USING btree ("user_id");--> statement-breakpoint
370
+ CREATE INDEX "session_userId_idx" ON "session" USING btree ("user_id");--> statement-breakpoint
371
+ CREATE INDEX "verification_identifier_idx" ON "verification" USING btree ("identifier");--> statement-breakpoint
372
+ CREATE INDEX "idx_bigquery_query_costs_org" ON "bigquery_query_costs" USING btree ("organization_id");--> statement-breakpoint
373
+ CREATE INDEX "idx_bigquery_query_costs_executed_at" ON "bigquery_query_costs" USING btree ("executed_at");--> statement-breakpoint
374
+ CREATE INDEX "idx_cli_query_actions_org_created" ON "cli_query_actions" USING btree ("organization_id","created_at");--> statement-breakpoint
375
+ CREATE INDEX "idx_cli_query_actions_actor_user_id" ON "cli_query_actions" USING btree ("actor_user_id");--> statement-breakpoint
376
+ CREATE INDEX "idx_cli_query_actions_request_id" ON "cli_query_actions" USING btree ("request_id");--> statement-breakpoint
377
+ CREATE INDEX "idx_cli_query_actions_source_id" ON "cli_query_actions" USING btree ("source_id");--> statement-breakpoint
378
+ CREATE INDEX "idx_cli_query_actions_status" ON "cli_query_actions" USING btree ("status");--> statement-breakpoint
379
+ CREATE INDEX "idx_cli_query_action_events_action_occurred" ON "cli_query_action_events" USING btree ("query_action_id","occurred_at","id");--> statement-breakpoint
380
+ CREATE INDEX "idx_cli_query_action_events_org_occurred" ON "cli_query_action_events" USING btree ("organization_id","occurred_at");--> statement-breakpoint
381
+ CREATE INDEX "idx_cli_query_action_events_actor_user_id" ON "cli_query_action_events" USING btree ("actor_user_id");--> statement-breakpoint
382
+ CREATE INDEX "idx_cli_query_action_events_request_id" ON "cli_query_action_events" USING btree ("request_id");--> statement-breakpoint
383
+ CREATE INDEX "idx_cli_query_action_events_causation" ON "cli_query_action_events" USING btree ("causation_event_id");--> statement-breakpoint
384
+ CREATE UNIQUE INDEX "idx_cli_query_action_events_action_event_type_unique" ON "cli_query_action_events" USING btree ("query_action_id","event_type");--> statement-breakpoint
385
+ CREATE INDEX "idx_connector_jobs_connector_created" ON "connector_jobs" USING btree ("connector_id","created_at");--> statement-breakpoint
386
+ CREATE INDEX "idx_connector_jobs_status_created" ON "connector_jobs" USING btree ("status","created_at");--> statement-breakpoint
387
+ CREATE INDEX "idx_connectors_organization" ON "connectors" USING btree ("organization_id");--> statement-breakpoint
388
+ CREATE INDEX "idx_connectors_last_seen" ON "connectors" USING btree ("last_seen_at");--> statement-breakpoint
389
+ CREATE UNIQUE INDEX "idx_connectors_auth_token_hash_unique" ON "connectors" USING btree ("auth_token_hash");--> statement-breakpoint
390
+ CREATE INDEX "idx_data_source_query_costs_org" ON "data_source_query_costs" USING btree ("organization_id");--> statement-breakpoint
391
+ CREATE INDEX "idx_data_source_query_costs_provider" ON "data_source_query_costs" USING btree ("provider");--> statement-breakpoint
392
+ CREATE INDEX "idx_data_source_query_costs_executed_at" ON "data_source_query_costs" USING btree ("executed_at");--> statement-breakpoint
393
+ CREATE INDEX "idx_data_sources_organization" ON "data_sources" USING btree ("organization_id");--> statement-breakpoint
394
+ CREATE INDEX "idx_data_sources_provider" ON "data_sources" USING btree ("provider");--> statement-breakpoint
395
+ CREATE INDEX "idx_data_sources_provider_account" ON "data_sources" USING btree ("provider","provider_account_id");--> statement-breakpoint
396
+ CREATE INDEX "idx_data_sources_status" ON "data_sources" USING btree ("status");--> statement-breakpoint
397
+ CREATE UNIQUE INDEX "idx_data_source_table_usage_source" ON "data_source_table_usage" USING btree ("data_source_id");--> statement-breakpoint
398
+ CREATE INDEX "idx_data_source_table_usage_org" ON "data_source_table_usage" USING btree ("organization_id");--> statement-breakpoint
399
+ CREATE INDEX "idx_data_source_table_usage_provider" ON "data_source_table_usage" USING btree ("provider");--> statement-breakpoint
400
+ CREATE INDEX "idx_data_source_table_usage_generated_at" ON "data_source_table_usage" USING btree ("generated_at");--> statement-breakpoint
401
+ CREATE UNIQUE INDEX "idx_org_profiles_org" ON "organization_profiles" USING btree ("organization_id");--> statement-breakpoint
402
+ CREATE INDEX "idx_org_profiles_created" ON "organization_profiles" USING btree ("created_at");--> statement-breakpoint
403
+ CREATE UNIQUE INDEX "idx_user_profiles_user" ON "user_profiles" USING btree ("user_id");