spine-framework 0.3.127 → 0.3.128
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.
- package/.framework/migrations/001_core_schema.sql +11 -0
- package/.framework/migrations/002_core_rls_and_functions.sql +111 -0
- package/.framework/migrations/003_core_system_data.sql +54 -0
- package/.framework/migrations/004_core_rpc_and_broker.sql +1 -1
- package/.framework/migrations/007_kb_article_list.sql +1 -1
- package/package.json +1 -1
|
@@ -159,6 +159,17 @@ CREATE TABLE IF NOT EXISTS public.triggers (
|
|
|
159
159
|
created_at timestamptz DEFAULT now(), updated_at timestamptz DEFAULT now(),
|
|
160
160
|
UNIQUE(app_id, slug)
|
|
161
161
|
);
|
|
162
|
+
CREATE TABLE IF NOT EXISTS public.trigger_executions (
|
|
163
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
164
|
+
trigger_id uuid NOT NULL, account_id uuid,
|
|
165
|
+
status text DEFAULT 'pending', started_at timestamptz,
|
|
166
|
+
completed_at timestamptz, error_message text,
|
|
167
|
+
input_data jsonb DEFAULT '{}', output_data jsonb DEFAULT '{}',
|
|
168
|
+
metadata jsonb DEFAULT '{}', created_by uuid,
|
|
169
|
+
created_at timestamptz DEFAULT now(),
|
|
170
|
+
CONSTRAINT fk_trigger_executions_trigger
|
|
171
|
+
FOREIGN KEY (trigger_id) REFERENCES public.triggers(id) ON DELETE CASCADE
|
|
172
|
+
);
|
|
162
173
|
CREATE TABLE IF NOT EXISTS public.timers (
|
|
163
174
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
164
175
|
app_id uuid, account_id uuid, type_id uuid,
|
|
@@ -87,226 +87,337 @@ BEGIN
|
|
|
87
87
|
RETURN NEW;
|
|
88
88
|
END;
|
|
89
89
|
$$ LANGUAGE plpgsql;
|
|
90
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS fk_accounts_parent;
|
|
90
91
|
ALTER TABLE public.accounts ADD CONSTRAINT fk_accounts_parent
|
|
91
92
|
FOREIGN KEY (parent_id) REFERENCES public.accounts(id) ON DELETE SET NULL;
|
|
93
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS fk_accounts_type;
|
|
92
94
|
ALTER TABLE public.accounts ADD CONSTRAINT fk_accounts_type
|
|
93
95
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
96
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS fk_accounts_app;
|
|
94
97
|
ALTER TABLE public.accounts ADD CONSTRAINT fk_accounts_app
|
|
95
98
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
99
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS fk_accounts_created_by;
|
|
96
100
|
ALTER TABLE public.accounts ADD CONSTRAINT fk_accounts_created_by
|
|
97
101
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
102
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS fk_accounts_updated_by;
|
|
98
103
|
ALTER TABLE public.accounts ADD CONSTRAINT fk_accounts_updated_by
|
|
99
104
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
105
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_account_id_fkey;
|
|
100
106
|
ALTER TABLE public.people ADD CONSTRAINT people_account_id_fkey
|
|
101
107
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
108
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_app_id_fkey;
|
|
102
109
|
ALTER TABLE public.people ADD CONSTRAINT people_app_id_fkey
|
|
103
110
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
111
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_role_id_fkey;
|
|
104
112
|
ALTER TABLE public.people ADD CONSTRAINT people_role_id_fkey
|
|
105
113
|
FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE SET NULL;
|
|
114
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_type_id_fkey;
|
|
106
115
|
ALTER TABLE public.people ADD CONSTRAINT people_type_id_fkey
|
|
107
116
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
117
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_created_by_fkey;
|
|
108
118
|
ALTER TABLE public.people ADD CONSTRAINT people_created_by_fkey
|
|
109
119
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
120
|
+
ALTER TABLE public.types DROP CONSTRAINT IF EXISTS fk_types_app;
|
|
110
121
|
ALTER TABLE public.types ADD CONSTRAINT fk_types_app
|
|
111
122
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
123
|
+
ALTER TABLE public.apps DROP CONSTRAINT IF EXISTS fk_apps_account;
|
|
112
124
|
ALTER TABLE public.apps ADD CONSTRAINT fk_apps_account
|
|
113
125
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE SET NULL;
|
|
126
|
+
ALTER TABLE public.apps DROP CONSTRAINT IF EXISTS fk_apps_owner_account;
|
|
114
127
|
ALTER TABLE public.apps ADD CONSTRAINT fk_apps_owner_account
|
|
115
128
|
FOREIGN KEY (owner_account_id) REFERENCES public.accounts(id) ON DELETE SET NULL;
|
|
129
|
+
ALTER TABLE public.roles DROP CONSTRAINT IF EXISTS fk_roles_app;
|
|
116
130
|
ALTER TABLE public.roles ADD CONSTRAINT fk_roles_app
|
|
117
131
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE CASCADE;
|
|
132
|
+
ALTER TABLE public.roles DROP CONSTRAINT IF EXISTS fk_roles_account;
|
|
118
133
|
ALTER TABLE public.roles ADD CONSTRAINT fk_roles_account
|
|
119
134
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
135
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS fk_items_type;
|
|
120
136
|
ALTER TABLE public.items ADD CONSTRAINT fk_items_type
|
|
121
137
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
138
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS fk_items_account;
|
|
122
139
|
ALTER TABLE public.items ADD CONSTRAINT fk_items_account
|
|
123
140
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
141
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS fk_items_app;
|
|
124
142
|
ALTER TABLE public.items ADD CONSTRAINT fk_items_app
|
|
125
143
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
144
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS fk_items_created_by;
|
|
126
145
|
ALTER TABLE public.items ADD CONSTRAINT fk_items_created_by
|
|
127
146
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
147
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS fk_items_updated_by;
|
|
128
148
|
ALTER TABLE public.items ADD CONSTRAINT fk_items_updated_by
|
|
129
149
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
150
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS fk_threads_type;
|
|
130
151
|
ALTER TABLE public.threads ADD CONSTRAINT fk_threads_type
|
|
131
152
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
153
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS fk_threads_account;
|
|
132
154
|
ALTER TABLE public.threads ADD CONSTRAINT fk_threads_account
|
|
133
155
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
156
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS fk_threads_created_by;
|
|
134
157
|
ALTER TABLE public.threads ADD CONSTRAINT fk_threads_created_by
|
|
135
158
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
159
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS fk_threads_updated_by;
|
|
136
160
|
ALTER TABLE public.threads ADD CONSTRAINT fk_threads_updated_by
|
|
137
161
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
162
|
+
ALTER TABLE public.messages DROP CONSTRAINT IF EXISTS fk_messages_type;
|
|
138
163
|
ALTER TABLE public.messages ADD CONSTRAINT fk_messages_type
|
|
139
164
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
165
|
+
ALTER TABLE public.messages DROP CONSTRAINT IF EXISTS fk_messages_account;
|
|
140
166
|
ALTER TABLE public.messages ADD CONSTRAINT fk_messages_account
|
|
141
167
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
168
|
+
ALTER TABLE public.messages DROP CONSTRAINT IF EXISTS fk_messages_thread;
|
|
142
169
|
ALTER TABLE public.messages ADD CONSTRAINT fk_messages_thread
|
|
143
170
|
FOREIGN KEY (thread_id) REFERENCES public.threads(id) ON DELETE CASCADE;
|
|
171
|
+
ALTER TABLE public.messages DROP CONSTRAINT IF EXISTS fk_messages_created_by;
|
|
144
172
|
ALTER TABLE public.messages ADD CONSTRAINT fk_messages_created_by
|
|
145
173
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
174
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS fk_prompt_configs_type;
|
|
146
175
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT fk_prompt_configs_type
|
|
147
176
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
177
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS fk_prompt_configs_account;
|
|
148
178
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT fk_prompt_configs_account
|
|
149
179
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
180
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS fk_prompt_configs_app;
|
|
150
181
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT fk_prompt_configs_app
|
|
151
182
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
183
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS fk_prompt_configs_created_by;
|
|
152
184
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT fk_prompt_configs_created_by
|
|
153
185
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
186
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS fk_prompt_configs_updated_by;
|
|
154
187
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT fk_prompt_configs_updated_by
|
|
155
188
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
189
|
+
ALTER TABLE public.pipeline_executions DROP CONSTRAINT IF EXISTS fk_pipeline_executions_pipeline;
|
|
156
190
|
ALTER TABLE public.pipeline_executions ADD CONSTRAINT fk_pipeline_executions_pipeline
|
|
157
191
|
FOREIGN KEY (pipeline_id) REFERENCES public.pipelines(id) ON DELETE CASCADE;
|
|
192
|
+
ALTER TABLE public.pipeline_executions DROP CONSTRAINT IF EXISTS fk_pipeline_executions_account;
|
|
158
193
|
ALTER TABLE public.pipeline_executions ADD CONSTRAINT fk_pipeline_executions_account
|
|
159
194
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
195
|
+
ALTER TABLE public.pipeline_executions DROP CONSTRAINT IF EXISTS fk_pipeline_executions_app;
|
|
160
196
|
ALTER TABLE public.pipeline_executions ADD CONSTRAINT fk_pipeline_executions_app
|
|
161
197
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
198
|
+
ALTER TABLE public.pipeline_executions DROP CONSTRAINT IF EXISTS fk_pipeline_executions_created_by;
|
|
162
199
|
ALTER TABLE public.pipeline_executions ADD CONSTRAINT fk_pipeline_executions_created_by
|
|
163
200
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
201
|
+
ALTER TABLE public.test_runs DROP CONSTRAINT IF EXISTS fk_test_runs_pipeline_execution;
|
|
164
202
|
ALTER TABLE public.test_runs ADD CONSTRAINT fk_test_runs_pipeline_execution
|
|
165
203
|
FOREIGN KEY (pipeline_execution_id) REFERENCES public.pipeline_executions(id) ON DELETE CASCADE;
|
|
204
|
+
ALTER TABLE public.test_runs DROP CONSTRAINT IF EXISTS fk_test_runs_account;
|
|
166
205
|
ALTER TABLE public.test_runs ADD CONSTRAINT fk_test_runs_account
|
|
167
206
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
207
|
+
ALTER TABLE public.test_runs DROP CONSTRAINT IF EXISTS fk_test_runs_app;
|
|
168
208
|
ALTER TABLE public.test_runs ADD CONSTRAINT fk_test_runs_app
|
|
169
209
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
210
|
+
ALTER TABLE public.test_runs DROP CONSTRAINT IF EXISTS fk_test_runs_created_by;
|
|
170
211
|
ALTER TABLE public.test_runs ADD CONSTRAINT fk_test_runs_created_by
|
|
171
212
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
213
|
+
ALTER TABLE public.invites DROP CONSTRAINT IF EXISTS fk_invites_type;
|
|
172
214
|
ALTER TABLE public.invites ADD CONSTRAINT fk_invites_type
|
|
173
215
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
216
|
+
ALTER TABLE public.invites DROP CONSTRAINT IF EXISTS fk_invites_account;
|
|
174
217
|
ALTER TABLE public.invites ADD CONSTRAINT fk_invites_account
|
|
175
218
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
219
|
+
ALTER TABLE public.invites DROP CONSTRAINT IF EXISTS fk_invites_app;
|
|
176
220
|
ALTER TABLE public.invites ADD CONSTRAINT fk_invites_app
|
|
177
221
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
222
|
+
ALTER TABLE public.invites DROP CONSTRAINT IF EXISTS fk_invites_created_by;
|
|
178
223
|
ALTER TABLE public.invites ADD CONSTRAINT fk_invites_created_by
|
|
179
224
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
225
|
+
ALTER TABLE public.api_keys DROP CONSTRAINT IF EXISTS fk_api_keys_type;
|
|
180
226
|
ALTER TABLE public.api_keys ADD CONSTRAINT fk_api_keys_type
|
|
181
227
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
228
|
+
ALTER TABLE public.api_keys DROP CONSTRAINT IF EXISTS fk_api_keys_account;
|
|
182
229
|
ALTER TABLE public.api_keys ADD CONSTRAINT fk_api_keys_account
|
|
183
230
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
231
|
+
ALTER TABLE public.api_keys DROP CONSTRAINT IF EXISTS fk_api_keys_app;
|
|
184
232
|
ALTER TABLE public.api_keys ADD CONSTRAINT fk_api_keys_app
|
|
185
233
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
234
|
+
ALTER TABLE public.api_keys DROP CONSTRAINT IF EXISTS fk_api_keys_created_by;
|
|
186
235
|
ALTER TABLE public.api_keys ADD CONSTRAINT fk_api_keys_created_by
|
|
187
236
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
237
|
+
ALTER TABLE public.integrations DROP CONSTRAINT IF EXISTS fk_integrations_type;
|
|
188
238
|
ALTER TABLE public.integrations ADD CONSTRAINT fk_integrations_type
|
|
189
239
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
240
|
+
ALTER TABLE public.integrations DROP CONSTRAINT IF EXISTS fk_integrations_account;
|
|
190
241
|
ALTER TABLE public.integrations ADD CONSTRAINT fk_integrations_account
|
|
191
242
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
243
|
+
ALTER TABLE public.integrations DROP CONSTRAINT IF EXISTS fk_integrations_app;
|
|
192
244
|
ALTER TABLE public.integrations ADD CONSTRAINT fk_integrations_app
|
|
193
245
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
246
|
+
ALTER TABLE public.integrations DROP CONSTRAINT IF EXISTS fk_integrations_created_by;
|
|
194
247
|
ALTER TABLE public.integrations ADD CONSTRAINT fk_integrations_created_by
|
|
195
248
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
249
|
+
ALTER TABLE public.ai_agents DROP CONSTRAINT IF EXISTS fk_ai_agents_type;
|
|
196
250
|
ALTER TABLE public.ai_agents ADD CONSTRAINT fk_ai_agents_type
|
|
197
251
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
252
|
+
ALTER TABLE public.ai_agents DROP CONSTRAINT IF EXISTS fk_ai_agents_account;
|
|
198
253
|
ALTER TABLE public.ai_agents ADD CONSTRAINT fk_ai_agents_account
|
|
199
254
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
255
|
+
ALTER TABLE public.ai_agents DROP CONSTRAINT IF EXISTS fk_ai_agents_app;
|
|
200
256
|
ALTER TABLE public.ai_agents ADD CONSTRAINT fk_ai_agents_app
|
|
201
257
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
258
|
+
ALTER TABLE public.ai_agents DROP CONSTRAINT IF EXISTS fk_ai_agents_created_by;
|
|
202
259
|
ALTER TABLE public.ai_agents ADD CONSTRAINT fk_ai_agents_created_by
|
|
203
260
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
261
|
+
ALTER TABLE public.item_progress DROP CONSTRAINT IF EXISTS fk_item_progress_item;
|
|
204
262
|
ALTER TABLE public.item_progress ADD CONSTRAINT fk_item_progress_item
|
|
205
263
|
FOREIGN KEY (item_id) REFERENCES public.items(id) ON DELETE CASCADE;
|
|
264
|
+
ALTER TABLE public.item_progress DROP CONSTRAINT IF EXISTS fk_item_progress_account;
|
|
206
265
|
ALTER TABLE public.item_progress ADD CONSTRAINT fk_item_progress_account
|
|
207
266
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
267
|
+
ALTER TABLE public.item_progress DROP CONSTRAINT IF EXISTS fk_item_progress_app;
|
|
208
268
|
ALTER TABLE public.item_progress ADD CONSTRAINT fk_item_progress_app
|
|
209
269
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
270
|
+
ALTER TABLE public.item_progress DROP CONSTRAINT IF EXISTS fk_item_progress_created_by;
|
|
210
271
|
ALTER TABLE public.item_progress ADD CONSTRAINT fk_item_progress_created_by
|
|
211
272
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
273
|
+
ALTER TABLE public.logs DROP CONSTRAINT IF EXISTS fk_logs_type;
|
|
212
274
|
ALTER TABLE public.logs ADD CONSTRAINT fk_logs_type
|
|
213
275
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
276
|
+
ALTER TABLE public.logs DROP CONSTRAINT IF EXISTS fk_logs_account;
|
|
214
277
|
ALTER TABLE public.logs ADD CONSTRAINT fk_logs_account
|
|
215
278
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
279
|
+
ALTER TABLE public.logs DROP CONSTRAINT IF EXISTS fk_logs_app;
|
|
216
280
|
ALTER TABLE public.logs ADD CONSTRAINT fk_logs_app
|
|
217
281
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
282
|
+
ALTER TABLE public.logs DROP CONSTRAINT IF EXISTS fk_logs_created_by;
|
|
218
283
|
ALTER TABLE public.logs ADD CONSTRAINT fk_logs_created_by
|
|
219
284
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
285
|
+
ALTER TABLE public.observability DROP CONSTRAINT IF EXISTS fk_observability_type;
|
|
220
286
|
ALTER TABLE public.observability ADD CONSTRAINT fk_observability_type
|
|
221
287
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
288
|
+
ALTER TABLE public.observability DROP CONSTRAINT IF EXISTS fk_observability_account;
|
|
222
289
|
ALTER TABLE public.observability ADD CONSTRAINT fk_observability_account
|
|
223
290
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
291
|
+
ALTER TABLE public.observability DROP CONSTRAINT IF EXISTS fk_observability_app;
|
|
224
292
|
ALTER TABLE public.observability ADD CONSTRAINT fk_observability_app
|
|
225
293
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
294
|
+
ALTER TABLE public.observability DROP CONSTRAINT IF EXISTS fk_observability_created_by;
|
|
226
295
|
ALTER TABLE public.observability ADD CONSTRAINT fk_observability_created_by
|
|
227
296
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
297
|
+
ALTER TABLE public.timers DROP CONSTRAINT IF EXISTS fk_timers_type;
|
|
228
298
|
ALTER TABLE public.timers ADD CONSTRAINT fk_timers_type
|
|
229
299
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
300
|
+
ALTER TABLE public.timers DROP CONSTRAINT IF EXISTS fk_timers_account;
|
|
230
301
|
ALTER TABLE public.timers ADD CONSTRAINT fk_timers_account
|
|
231
302
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
303
|
+
ALTER TABLE public.timers DROP CONSTRAINT IF EXISTS fk_timers_app;
|
|
232
304
|
ALTER TABLE public.timers ADD CONSTRAINT fk_timers_app
|
|
233
305
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
306
|
+
ALTER TABLE public.timers DROP CONSTRAINT IF EXISTS fk_timers_created_by;
|
|
234
307
|
ALTER TABLE public.timers ADD CONSTRAINT fk_timers_created_by
|
|
235
308
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
309
|
+
ALTER TABLE public.triggers DROP CONSTRAINT IF EXISTS fk_triggers_type;
|
|
236
310
|
ALTER TABLE public.triggers ADD CONSTRAINT fk_triggers_type
|
|
237
311
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
312
|
+
ALTER TABLE public.triggers DROP CONSTRAINT IF EXISTS fk_triggers_account;
|
|
238
313
|
ALTER TABLE public.triggers ADD CONSTRAINT fk_triggers_account
|
|
239
314
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
315
|
+
ALTER TABLE public.triggers DROP CONSTRAINT IF EXISTS fk_triggers_app;
|
|
240
316
|
ALTER TABLE public.triggers ADD CONSTRAINT fk_triggers_app
|
|
241
317
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
318
|
+
ALTER TABLE public.triggers DROP CONSTRAINT IF EXISTS fk_triggers_created_by;
|
|
242
319
|
ALTER TABLE public.triggers ADD CONSTRAINT fk_triggers_created_by
|
|
243
320
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
321
|
+
ALTER TABLE public.roles DROP CONSTRAINT IF EXISTS fk_roles_type;
|
|
244
322
|
ALTER TABLE public.roles ADD CONSTRAINT fk_roles_type
|
|
245
323
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
324
|
+
ALTER TABLE public.roles DROP CONSTRAINT IF EXISTS fk_roles_created_by;
|
|
246
325
|
ALTER TABLE public.roles ADD CONSTRAINT fk_roles_created_by
|
|
247
326
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
327
|
+
ALTER TABLE public.pipelines DROP CONSTRAINT IF EXISTS fk_pipelines_type;
|
|
248
328
|
ALTER TABLE public.pipelines ADD CONSTRAINT fk_pipelines_type
|
|
249
329
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE RESTRICT;
|
|
330
|
+
ALTER TABLE public.pipelines DROP CONSTRAINT IF EXISTS fk_pipelines_account;
|
|
250
331
|
ALTER TABLE public.pipelines ADD CONSTRAINT fk_pipelines_account
|
|
251
332
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE CASCADE;
|
|
333
|
+
ALTER TABLE public.pipelines DROP CONSTRAINT IF EXISTS fk_pipelines_app;
|
|
252
334
|
ALTER TABLE public.pipelines ADD CONSTRAINT fk_pipelines_app
|
|
253
335
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
336
|
+
ALTER TABLE public.pipelines DROP CONSTRAINT IF EXISTS fk_pipelines_created_by;
|
|
254
337
|
ALTER TABLE public.pipelines ADD CONSTRAINT fk_pipelines_created_by
|
|
255
338
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
339
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_role_id_fkey;
|
|
256
340
|
ALTER TABLE public.people ADD CONSTRAINT people_role_id_fkey
|
|
257
341
|
FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE SET NULL;
|
|
342
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS accounts_app_id_fkey;
|
|
258
343
|
ALTER TABLE public.accounts ADD CONSTRAINT accounts_app_id_fkey
|
|
259
344
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
345
|
+
ALTER TABLE public.accounts DROP CONSTRAINT IF EXISTS accounts_type_id_fkey;
|
|
260
346
|
ALTER TABLE public.accounts ADD CONSTRAINT accounts_type_id_fkey
|
|
261
347
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE SET NULL;
|
|
348
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_app_id_fkey;
|
|
262
349
|
ALTER TABLE public.people ADD CONSTRAINT people_app_id_fkey
|
|
263
350
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
351
|
+
ALTER TABLE public.people DROP CONSTRAINT IF EXISTS people_type_id_fkey;
|
|
264
352
|
ALTER TABLE public.people ADD CONSTRAINT people_type_id_fkey
|
|
265
353
|
FOREIGN KEY (type_id) REFERENCES public.types(id) ON DELETE SET NULL;
|
|
354
|
+
ALTER TABLE public.types DROP CONSTRAINT IF EXISTS types_app_id_fkey;
|
|
266
355
|
ALTER TABLE public.types ADD CONSTRAINT types_app_id_fkey
|
|
267
356
|
FOREIGN KEY (app_id) REFERENCES public.apps(id) ON DELETE SET NULL;
|
|
357
|
+
ALTER TABLE public.apps DROP CONSTRAINT IF EXISTS apps_account_id_fkey;
|
|
268
358
|
ALTER TABLE public.apps ADD CONSTRAINT apps_account_id_fkey
|
|
269
359
|
FOREIGN KEY (account_id) REFERENCES public.accounts(id) ON DELETE SET NULL;
|
|
360
|
+
ALTER TABLE public.apps DROP CONSTRAINT IF EXISTS apps_owner_account_id_fkey;
|
|
270
361
|
ALTER TABLE public.apps ADD CONSTRAINT apps_owner_account_id_fkey
|
|
271
362
|
FOREIGN KEY (owner_account_id) REFERENCES public.accounts(id) ON DELETE SET NULL;
|
|
363
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS items_created_by_fkey;
|
|
272
364
|
ALTER TABLE public.items ADD CONSTRAINT items_created_by_fkey
|
|
273
365
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
366
|
+
ALTER TABLE public.items DROP CONSTRAINT IF EXISTS items_updated_by_fkey;
|
|
274
367
|
ALTER TABLE public.items ADD CONSTRAINT items_updated_by_fkey
|
|
275
368
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
369
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS threads_created_by_fkey;
|
|
276
370
|
ALTER TABLE public.threads ADD CONSTRAINT threads_created_by_fkey
|
|
277
371
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
372
|
+
ALTER TABLE public.threads DROP CONSTRAINT IF EXISTS threads_updated_by_fkey;
|
|
278
373
|
ALTER TABLE public.threads ADD CONSTRAINT threads_updated_by_fkey
|
|
279
374
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
375
|
+
ALTER TABLE public.messages DROP CONSTRAINT IF EXISTS messages_created_by_fkey;
|
|
280
376
|
ALTER TABLE public.messages ADD CONSTRAINT messages_created_by_fkey
|
|
281
377
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
378
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS prompt_configs_created_by_fkey;
|
|
282
379
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT prompt_configs_created_by_fkey
|
|
283
380
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
381
|
+
ALTER TABLE public.prompt_configs DROP CONSTRAINT IF EXISTS prompt_configs_updated_by_fkey;
|
|
284
382
|
ALTER TABLE public.prompt_configs ADD CONSTRAINT prompt_configs_updated_by_fkey
|
|
285
383
|
FOREIGN KEY (updated_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
384
|
+
ALTER TABLE public.pipeline_executions DROP CONSTRAINT IF EXISTS pipeline_executions_created_by_fkey;
|
|
286
385
|
ALTER TABLE public.pipeline_executions ADD CONSTRAINT pipeline_executions_created_by_fkey
|
|
287
386
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
387
|
+
ALTER TABLE public.test_runs DROP CONSTRAINT IF EXISTS test_runs_created_by_fkey;
|
|
288
388
|
ALTER TABLE public.test_runs ADD CONSTRAINT test_runs_created_by_fkey
|
|
289
389
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
390
|
+
ALTER TABLE public.invites DROP CONSTRAINT IF EXISTS invites_created_by_fkey;
|
|
290
391
|
ALTER TABLE public.invites ADD CONSTRAINT invites_created_by_fkey
|
|
291
392
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
393
|
+
ALTER TABLE public.api_keys DROP CONSTRAINT IF EXISTS api_keys_created_by_fkey;
|
|
292
394
|
ALTER TABLE public.api_keys ADD CONSTRAINT api_keys_created_by_fkey
|
|
293
395
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
396
|
+
ALTER TABLE public.integrations DROP CONSTRAINT IF EXISTS integrations_created_by_fkey;
|
|
294
397
|
ALTER TABLE public.integrations ADD CONSTRAINT integrations_created_by_fkey
|
|
295
398
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
399
|
+
ALTER TABLE public.ai_agents DROP CONSTRAINT IF EXISTS ai_agents_created_by_fkey;
|
|
296
400
|
ALTER TABLE public.ai_agents ADD CONSTRAINT ai_agents_created_by_fkey
|
|
297
401
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
402
|
+
ALTER TABLE public.item_progress DROP CONSTRAINT IF EXISTS item_progress_created_by_fkey;
|
|
298
403
|
ALTER TABLE public.item_progress ADD CONSTRAINT item_progress_created_by_fkey
|
|
299
404
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
405
|
+
ALTER TABLE public.logs DROP CONSTRAINT IF EXISTS logs_created_by_fkey;
|
|
300
406
|
ALTER TABLE public.logs ADD CONSTRAINT logs_created_by_fkey
|
|
301
407
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
408
|
+
ALTER TABLE public.observability DROP CONSTRAINT IF EXISTS observability_created_by_fkey;
|
|
302
409
|
ALTER TABLE public.observability ADD CONSTRAINT observability_created_by_fkey
|
|
303
410
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
411
|
+
ALTER TABLE public.timers DROP CONSTRAINT IF EXISTS timers_created_by_fkey;
|
|
304
412
|
ALTER TABLE public.timers ADD CONSTRAINT timers_created_by_fkey
|
|
305
413
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
414
|
+
ALTER TABLE public.triggers DROP CONSTRAINT IF EXISTS triggers_created_by_fkey;
|
|
306
415
|
ALTER TABLE public.triggers ADD CONSTRAINT triggers_created_by_fkey
|
|
307
416
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
417
|
+
ALTER TABLE public.roles DROP CONSTRAINT IF EXISTS roles_created_by_fkey;
|
|
308
418
|
ALTER TABLE public.roles ADD CONSTRAINT roles_created_by_fkey
|
|
309
419
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
420
|
+
ALTER TABLE public.pipelines DROP CONSTRAINT IF EXISTS pipelines_created_by_fkey;
|
|
310
421
|
ALTER TABLE public.pipelines ADD CONSTRAINT pipelines_created_by_fkey
|
|
311
422
|
FOREIGN KEY (created_by) REFERENCES public.people(id) ON DELETE SET NULL;
|
|
312
423
|
DROP TRIGGER IF EXISTS set_updated_at_accounts ON public.accounts;
|
|
@@ -32,6 +32,58 @@ VALUES
|
|
|
32
32
|
(gen_random_uuid(), 'support_admin', 'Support Admin', 'Support administrator — can invite and manage support staff', '["*"]'::jsonb, true, true, false, NULL, NULL)
|
|
33
33
|
ON CONFLICT (slug) DO NOTHING;
|
|
34
34
|
|
|
35
|
+
INSERT INTO public.apps (id, slug, name, description, version, app_type, source, is_active, is_system, renderer, route_prefix)
|
|
36
|
+
VALUES (
|
|
37
|
+
gen_random_uuid(),
|
|
38
|
+
'spine-core',
|
|
39
|
+
'Spine Core',
|
|
40
|
+
'Core Spine runtime - provides accounts, people, items, threads, messages, links, attachments, watchers',
|
|
41
|
+
'1.0.0',
|
|
42
|
+
'system',
|
|
43
|
+
'builtin',
|
|
44
|
+
true,
|
|
45
|
+
true,
|
|
46
|
+
'none',
|
|
47
|
+
NULL
|
|
48
|
+
)
|
|
49
|
+
ON CONFLICT (slug) DO NOTHING;
|
|
50
|
+
|
|
51
|
+
INSERT INTO public.apps (
|
|
52
|
+
id, slug, name, description, icon, color, version,
|
|
53
|
+
app_type, source, config, nav_items, min_role,
|
|
54
|
+
is_active, is_system, route_prefix, renderer
|
|
55
|
+
)
|
|
56
|
+
VALUES (
|
|
57
|
+
gen_random_uuid(),
|
|
58
|
+
'admin',
|
|
59
|
+
'Admin',
|
|
60
|
+
'Spine system administration interface',
|
|
61
|
+
'settings',
|
|
62
|
+
'slate',
|
|
63
|
+
'1.0.0',
|
|
64
|
+
'system',
|
|
65
|
+
'builtin',
|
|
66
|
+
'{}'::jsonb,
|
|
67
|
+
'[]'::jsonb,
|
|
68
|
+
'system_admin',
|
|
69
|
+
true,
|
|
70
|
+
true,
|
|
71
|
+
'/admin',
|
|
72
|
+
'custom'
|
|
73
|
+
)
|
|
74
|
+
ON CONFLICT (slug) DO UPDATE SET
|
|
75
|
+
route_prefix = EXCLUDED.route_prefix,
|
|
76
|
+
renderer = EXCLUDED.renderer,
|
|
77
|
+
min_role = EXCLUDED.min_role,
|
|
78
|
+
is_system = EXCLUDED.is_system,
|
|
79
|
+
app_type = EXCLUDED.app_type;
|
|
80
|
+
|
|
81
|
+
DO $$
|
|
82
|
+
DECLARE
|
|
83
|
+
v_spine_core_app_id uuid;
|
|
84
|
+
BEGIN
|
|
85
|
+
SELECT id INTO v_spine_core_app_id FROM public.apps WHERE slug = 'spine-core' LIMIT 1;
|
|
86
|
+
|
|
35
87
|
INSERT INTO public.types (id, app_id, kind, slug, name, description, design_schema, validation_schema, ownership, is_active)
|
|
36
88
|
VALUES (
|
|
37
89
|
gen_random_uuid(),
|
|
@@ -362,6 +414,8 @@ ON CONFLICT (slug) DO NOTHING;
|
|
|
362
414
|
|
|
363
415
|
END $$;
|
|
364
416
|
|
|
417
|
+
END $$;
|
|
418
|
+
|
|
365
419
|
CREATE OR REPLACE FUNCTION public.get_account_apps(
|
|
366
420
|
account_id uuid,
|
|
367
421
|
include_system boolean DEFAULT true,
|
|
@@ -403,7 +403,7 @@ INSERT INTO public.webhook_handlers (
|
|
|
403
403
|
VALUES (
|
|
404
404
|
NULL, NULL, 'portal-signals', 'custom/apps/portal/functions/custom_portal-signals',
|
|
405
405
|
'Portal funnel signal adapter that transforms portal engagement payloads into funnel_signal records.',
|
|
406
|
-
'
|
|
406
|
+
'["funnel.signal"]', true
|
|
407
407
|
)
|
|
408
408
|
ON CONFLICT (app_id, account_id, name) DO NOTHING;
|
|
409
409
|
|