@de-otio/trellis 0.4.0 → 0.6.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 (41) hide show
  1. package/dist/lib/crypto/voting/hash-utils.d.ts +3 -49
  2. package/dist/lib/crypto/voting/hash-utils.d.ts.map +1 -1
  3. package/dist/lib/crypto/voting/hash-utils.js +12 -54
  4. package/dist/lib/crypto/voting/hash-utils.js.map +1 -1
  5. package/dist/lib/email-privacy.d.ts +6 -44
  6. package/dist/lib/email-privacy.d.ts.map +1 -1
  7. package/dist/lib/email-privacy.js +10 -50
  8. package/dist/lib/email-privacy.js.map +1 -1
  9. package/package.json +6 -6
  10. package/prisma/migrations/20260412075058_init_redesign_schema/migration.sql +1547 -0
  11. package/prisma/migrations/20260412080000_seed_role_metadata/migration.sql +15 -0
  12. package/prisma/migrations/migration_lock.toml +3 -0
  13. package/prisma/schema.prisma +1408 -0
  14. package/dist/lib/crypto/encryption-service.d.ts +0 -100
  15. package/dist/lib/crypto/encryption-service.d.ts.map +0 -1
  16. package/dist/lib/crypto/encryption-service.js +0 -293
  17. package/dist/lib/crypto/encryption-service.js.map +0 -1
  18. package/dist/lib/crypto/index.d.ts +0 -22
  19. package/dist/lib/crypto/index.d.ts.map +0 -1
  20. package/dist/lib/crypto/index.js +0 -28
  21. package/dist/lib/crypto/index.js.map +0 -1
  22. package/dist/lib/crypto/types.d.ts +0 -71
  23. package/dist/lib/crypto/types.d.ts.map +0 -1
  24. package/dist/lib/crypto/types.js +0 -3
  25. package/dist/lib/crypto/types.js.map +0 -1
  26. package/dist/lib/crypto/versioning.d.ts +0 -112
  27. package/dist/lib/crypto/versioning.d.ts.map +0 -1
  28. package/dist/lib/crypto/versioning.js +0 -148
  29. package/dist/lib/crypto/versioning.js.map +0 -1
  30. package/dist/lib/encryption-key-service.d.ts +0 -115
  31. package/dist/lib/encryption-key-service.d.ts.map +0 -1
  32. package/dist/lib/encryption-key-service.js +0 -272
  33. package/dist/lib/encryption-key-service.js.map +0 -1
  34. package/dist/lib/followers-handler.d.ts +0 -21
  35. package/dist/lib/followers-handler.d.ts.map +0 -1
  36. package/dist/lib/followers-handler.js +0 -35
  37. package/dist/lib/followers-handler.js.map +0 -1
  38. package/dist/lib/routes/followers.d.ts +0 -6
  39. package/dist/lib/routes/followers.d.ts.map +0 -1
  40. package/dist/lib/routes/followers.js +0 -405
  41. package/dist/lib/routes/followers.js.map +0 -1
@@ -0,0 +1,1547 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "EntityStatus" AS ENUM ('ACTIVE', 'MEMORIAL', 'TRANSFERRED');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "UserRole" AS ENUM ('END_USER', 'B2B_PARTNER', 'PARTNER_ADMIN', 'INTERNAL', 'CONTENT_CREATOR', 'SUPER_ADMIN');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "PostRadius" AS ENUM ('WHISPER', 'NORMAL', 'LOUD', 'SHOUT');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "Privacy" AS ENUM ('PUBLIC', 'FOLLOWERS', 'PRIVATE');
12
+
13
+ -- CreateEnum
14
+ CREATE TYPE "OwnershipRole" AS ENUM ('PRIMARY_OWNER', 'CO_OWNER', 'CARETAKER');
15
+
16
+ -- CreateEnum
17
+ CREATE TYPE "OwnershipStatus" AS ENUM ('ACTIVE', 'REMOVED', 'LEFT');
18
+
19
+ -- CreateEnum
20
+ CREATE TYPE "GroupPrivacy" AS ENUM ('PUBLIC', 'PRIVATE', 'FRIENDS_ONLY');
21
+
22
+ -- CreateEnum
23
+ CREATE TYPE "GroupRole" AS ENUM ('MEMBER', 'MODERATOR', 'ADMIN');
24
+
25
+ -- CreateEnum
26
+ CREATE TYPE "AgeTier" AS ENUM ('CHILD', 'TEEN', 'ADULT');
27
+
28
+ -- CreateEnum
29
+ CREATE TYPE "ProfileVisibility" AS ENUM ('PUBLIC', 'CONNECTIONS', 'PRIVATE');
30
+
31
+ -- CreateEnum
32
+ CREATE TYPE "DmAccess" AS ENUM ('ANYONE', 'CONNECTIONS', 'NOBODY');
33
+
34
+ -- CreateEnum
35
+ CREATE TYPE "ParentalLinkStatus" AS ENUM ('PENDING', 'ACTIVE', 'REVOKED');
36
+
37
+ -- CreateEnum
38
+ CREATE TYPE "NotificationType" AS ENUM ('DIRECT_MESSAGE', 'SAFETY_ALERT', 'PARENTAL_LINK', 'FOLLOW', 'SENTIMENT_DIGEST', 'SYSTEM', 'RELATIONSHIP_CREATED', 'RELATIONSHIP_RECIPROCATED', 'TIER_CHANGED', 'ENTITY_RELATIONSHIP_PROPOSED', 'ENTITY_RELATIONSHIP_CONFIRMED', 'CONNECTION_CODE_REDEEMED');
39
+
40
+ -- CreateTable
41
+ CREATE TABLE "entities" (
42
+ "id" TEXT NOT NULL,
43
+ "name" TEXT NOT NULL,
44
+ "entity_type" TEXT,
45
+ "metadata" JSONB,
46
+ "status" "EntityStatus" NOT NULL DEFAULT 'ACTIVE',
47
+ "deceased_at" TIMESTAMP(3),
48
+ "memorial_settings" JSONB,
49
+ "life_stage" TEXT,
50
+ "life_stage_manual_override" BOOLEAN NOT NULL DEFAULT false,
51
+ "life_stage_calculated_at" TIMESTAMP(3),
52
+ "actor_uri" TEXT,
53
+ "inbox_url" TEXT,
54
+ "outbox_url" TEXT,
55
+ "followers_url" TEXT,
56
+ "public_key" TEXT,
57
+ "private_key" TEXT,
58
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
59
+ "updated_at" TIMESTAMP(3) NOT NULL,
60
+
61
+ CONSTRAINT "entities_pkey" PRIMARY KEY ("id")
62
+ );
63
+
64
+ -- CreateTable
65
+ CREATE TABLE "post_geo_index" (
66
+ "post_uri" TEXT NOT NULL,
67
+ "entity_ref" TEXT,
68
+ "geohash" TEXT NOT NULL,
69
+ "lat" DOUBLE PRECISION NOT NULL,
70
+ "lng" DOUBLE PRECISION NOT NULL,
71
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
72
+ "place" TEXT,
73
+ "labels" JSONB DEFAULT '[]',
74
+ "sensitivity_level" TEXT NOT NULL DEFAULT 'benign',
75
+
76
+ CONSTRAINT "post_geo_index_pkey" PRIMARY KEY ("post_uri")
77
+ );
78
+
79
+ -- CreateTable
80
+ CREATE TABLE "ingest_state" (
81
+ "id" TEXT NOT NULL,
82
+ "cursor" TEXT,
83
+ "last_processed" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
84
+ "updated_at" TIMESTAMP(3) NOT NULL,
85
+
86
+ CONSTRAINT "ingest_state_pkey" PRIMARY KEY ("id")
87
+ );
88
+
89
+ -- CreateTable
90
+ CREATE TABLE "role_metadata" (
91
+ "role" "UserRole" NOT NULL,
92
+ "display_name" TEXT NOT NULL,
93
+ "description" TEXT,
94
+ "category" TEXT NOT NULL,
95
+ "permissions" JSONB,
96
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
97
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
98
+ "updated_at" TIMESTAMP(3) NOT NULL,
99
+
100
+ CONSTRAINT "role_metadata_pkey" PRIMARY KEY ("role")
101
+ );
102
+
103
+ -- CreateTable
104
+ CREATE TABLE "users" (
105
+ "id" TEXT NOT NULL,
106
+ "email" TEXT NOT NULL,
107
+ "role" "UserRole" NOT NULL DEFAULT 'END_USER',
108
+ "actor_uri" TEXT,
109
+ "handle" TEXT,
110
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
111
+ "cognito_sub" TEXT,
112
+ "suspended" BOOLEAN NOT NULL DEFAULT false,
113
+ "suspended_at" TIMESTAMP(3),
114
+ "suspended_reason" TEXT,
115
+ "partnerId" TEXT,
116
+ "deletion_requested_at" TIMESTAMP(3),
117
+ "deletion_scheduled_at" TIMESTAMP(3),
118
+ "deletion_confirmed_at" TIMESTAMP(3),
119
+ "username" TEXT,
120
+ "stealth_mode" BOOLEAN NOT NULL DEFAULT false,
121
+ "show_online_status" BOOLEAN NOT NULL DEFAULT true,
122
+ "show_typing_indicator" BOOLEAN NOT NULL DEFAULT true,
123
+ "show_last_seen" BOOLEAN NOT NULL DEFAULT true,
124
+ "location_tracking_enabled" BOOLEAN NOT NULL DEFAULT true,
125
+ "location_anonymization_level" INTEGER NOT NULL DEFAULT 0,
126
+ "analytics_opt_out" BOOLEAN NOT NULL DEFAULT false,
127
+ "email_verified" BOOLEAN NOT NULL DEFAULT false,
128
+ "email_verified_at" TIMESTAMP(3),
129
+ "show_verified_badge" BOOLEAN NOT NULL DEFAULT true,
130
+ "identity_verified" BOOLEAN NOT NULL DEFAULT false,
131
+ "identity_verified_at" TIMESTAMP(3),
132
+ "identity_verification_method" TEXT,
133
+ "identity_verification_provider" TEXT,
134
+ "show_identity_verified_badge" BOOLEAN NOT NULL DEFAULT true,
135
+ "region" TEXT NOT NULL DEFAULT 'EU',
136
+ "data_region" TEXT,
137
+ "inbox_url" TEXT,
138
+ "outbox_url" TEXT,
139
+ "followers_url" TEXT,
140
+ "following_url" TEXT,
141
+ "friends_url" TEXT,
142
+ "public_key" TEXT,
143
+ "private_key" TEXT,
144
+ "encryption_key_id" TEXT,
145
+ "default_context" TEXT NOT NULL DEFAULT 'primary',
146
+ "travel_mode_active" BOOLEAN NOT NULL DEFAULT false,
147
+ "travel_mode_activated_at" TIMESTAMP(3),
148
+ "panic_action_config" TEXT,
149
+ "email_hash" TEXT,
150
+ "anonymous_id" TEXT,
151
+ "message_retention_days" INTEGER,
152
+ "auto_delete_after_days" INTEGER,
153
+ "date_of_birth" TIMESTAMP(3),
154
+ "age_tier" "AgeTier" NOT NULL DEFAULT 'ADULT',
155
+ "quiet_hours_start" INTEGER,
156
+ "quiet_hours_end" INTEGER,
157
+ "quiet_hours_enabled" BOOLEAN NOT NULL DEFAULT false,
158
+ "profile_visibility" "ProfileVisibility" NOT NULL DEFAULT 'PUBLIC',
159
+ "dm_access" "DmAccess" NOT NULL DEFAULT 'CONNECTIONS',
160
+
161
+ CONSTRAINT "users_pkey" PRIMARY KEY ("id")
162
+ );
163
+
164
+ -- CreateTable
165
+ CREATE TABLE "mfa_enrollments" (
166
+ "id" TEXT NOT NULL,
167
+ "user_id" TEXT NOT NULL,
168
+ "encrypted_secret" TEXT NOT NULL,
169
+ "backup_codes" TEXT[],
170
+ "enrolled_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
171
+ "last_used_at" TIMESTAMP(3),
172
+
173
+ CONSTRAINT "mfa_enrollments_pkey" PRIMARY KEY ("id")
174
+ );
175
+
176
+ -- CreateTable
177
+ CREATE TABLE "user_encryption_keys" (
178
+ "id" TEXT NOT NULL,
179
+ "user_id" TEXT NOT NULL,
180
+ "context_id" TEXT NOT NULL,
181
+ "encrypted_key" TEXT NOT NULL,
182
+ "kdf_params" TEXT NOT NULL,
183
+ "algorithm" TEXT NOT NULL DEFAULT 'AES-256-GCM',
184
+ "keyPurpose" TEXT NOT NULL,
185
+ "key_type" TEXT NOT NULL DEFAULT 'border_safety',
186
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
187
+ "rotated_at" TIMESTAMP(3),
188
+
189
+ CONSTRAINT "user_encryption_keys_pkey" PRIMARY KEY ("id")
190
+ );
191
+
192
+ -- CreateTable
193
+ CREATE TABLE "cross_region_consent" (
194
+ "id" TEXT NOT NULL,
195
+ "user_id" TEXT NOT NULL,
196
+ "data_region" TEXT NOT NULL,
197
+ "access_region" TEXT NOT NULL,
198
+ "consented" BOOLEAN NOT NULL DEFAULT false,
199
+ "consented_at" TIMESTAMP(3),
200
+ "withdrawn_at" TIMESTAMP(3),
201
+ "ip_address" TEXT,
202
+ "user_agent" TEXT,
203
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
204
+ "updated_at" TIMESTAMP(3) NOT NULL,
205
+
206
+ CONSTRAINT "cross_region_consent_pkey" PRIMARY KEY ("id")
207
+ );
208
+
209
+ -- CreateTable
210
+ CREATE TABLE "posts" (
211
+ "id" TEXT NOT NULL,
212
+ "author_id" TEXT NOT NULL,
213
+ "text" TEXT NOT NULL,
214
+ "radius" "PostRadius" NOT NULL DEFAULT 'NORMAL',
215
+ "geo_data" JSONB,
216
+ "uri" TEXT,
217
+ "content_warnings" TEXT[],
218
+ "deleted_at" TIMESTAMP(3),
219
+ "hidden_by_author" BOOLEAN NOT NULL DEFAULT false,
220
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
221
+ "updated_at" TIMESTAMP(3) NOT NULL,
222
+ "edited_at" TIMESTAMP(3),
223
+ "group_id" TEXT,
224
+ "primary_entity_id" TEXT,
225
+ "data_region" TEXT,
226
+ "activity_id" TEXT,
227
+ "object_id" TEXT,
228
+ "to" JSONB,
229
+ "cc" JSONB,
230
+ "bto" JSONB,
231
+ "bcc" JSONB,
232
+ "published" TIMESTAMP(3),
233
+ "has_blocked_links" BOOLEAN NOT NULL DEFAULT false,
234
+ "sensitivity_level" TEXT NOT NULL DEFAULT 'benign',
235
+ "owner_context" TEXT NOT NULL DEFAULT 'primary',
236
+ "screening_risk_level" TEXT NOT NULL DEFAULT 'low',
237
+ "content_category" TEXT,
238
+
239
+ CONSTRAINT "posts_pkey" PRIMARY KEY ("id")
240
+ );
241
+
242
+ -- CreateTable
243
+ CREATE TABLE "media_files" (
244
+ "id" TEXT NOT NULL,
245
+ "content_hash" TEXT NOT NULL,
246
+ "cid" TEXT,
247
+ "mime_type" TEXT NOT NULL,
248
+ "size" INTEGER NOT NULL,
249
+ "original_key" TEXT NOT NULL,
250
+ "thumbnail_key" TEXT,
251
+ "optimized_key" TEXT,
252
+ "width" INTEGER,
253
+ "height" INTEGER,
254
+ "duration" INTEGER,
255
+ "exif_data" JSONB,
256
+ "iptc_data" JSONB,
257
+ "video_metadata" JSONB,
258
+ "date_taken" TIMESTAMP(3),
259
+ "gps_latitude" DOUBLE PRECISION,
260
+ "gps_longitude" DOUBLE PRECISION,
261
+ "keywords" TEXT[] DEFAULT ARRAY[]::TEXT[],
262
+ "metadata_visible" BOOLEAN NOT NULL DEFAULT true,
263
+ "location_visible" BOOLEAN NOT NULL DEFAULT false,
264
+ "hidden" BOOLEAN NOT NULL DEFAULT false,
265
+ "deleted_at" TIMESTAMP(3),
266
+ "hidden_at" TIMESTAMP(3),
267
+ "hidden_by" TEXT,
268
+ "upload_status" TEXT NOT NULL DEFAULT 'PENDING',
269
+ "uploaded_by" TEXT,
270
+ "upload_batch_id" TEXT,
271
+ "reconciled_at" TIMESTAMP(3),
272
+ "reconcile_attempts" INTEGER NOT NULL DEFAULT 0,
273
+ "created_via_reconciliation" BOOLEAN NOT NULL DEFAULT false,
274
+ "attached_to_post" BOOLEAN NOT NULL DEFAULT false,
275
+ "orphaned_at" TIMESTAMP(3),
276
+ "last_accessed_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
277
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
278
+ "updated_at" TIMESTAMP(3) NOT NULL,
279
+
280
+ CONSTRAINT "media_files_pkey" PRIMARY KEY ("id")
281
+ );
282
+
283
+ -- CreateTable
284
+ CREATE TABLE "upload_sessions" (
285
+ "id" TEXT NOT NULL,
286
+ "user_id" TEXT NOT NULL,
287
+ "media_ids" TEXT[],
288
+ "status" TEXT NOT NULL DEFAULT 'active',
289
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
290
+ "expires_at" TIMESTAMP(3) NOT NULL,
291
+
292
+ CONSTRAINT "upload_sessions_pkey" PRIMARY KEY ("id")
293
+ );
294
+
295
+ -- CreateTable
296
+ CREATE TABLE "post_media" (
297
+ "id" TEXT NOT NULL,
298
+ "post_id" TEXT NOT NULL,
299
+ "media_id" TEXT NOT NULL,
300
+ "alt" TEXT,
301
+ "order" INTEGER NOT NULL DEFAULT 0,
302
+
303
+ CONSTRAINT "post_media_pkey" PRIMARY KEY ("id")
304
+ );
305
+
306
+ -- CreateTable
307
+ CREATE TABLE "post_sentiments" (
308
+ "id" TEXT NOT NULL,
309
+ "post_id" TEXT NOT NULL,
310
+ "post_uri" TEXT,
311
+ "author_id" TEXT NOT NULL,
312
+ "sentiment" TEXT NOT NULL,
313
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
314
+
315
+ CONSTRAINT "post_sentiments_pkey" PRIMARY KEY ("id")
316
+ );
317
+
318
+ -- CreateTable
319
+ CREATE TABLE "post_comments" (
320
+ "id" TEXT NOT NULL,
321
+ "post_id" TEXT NOT NULL,
322
+ "post_uri" TEXT,
323
+ "author_id" TEXT NOT NULL,
324
+ "text" TEXT NOT NULL,
325
+ "root_uri" TEXT,
326
+ "reply_to_uri" TEXT,
327
+ "hidden_by_post_owner" BOOLEAN NOT NULL DEFAULT false,
328
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
329
+ "edited_at" TIMESTAMP(3),
330
+ "original_text" TEXT,
331
+ "deleted_at" TIMESTAMP(3),
332
+ "deleted_by" TEXT,
333
+ "has_blocked_links" BOOLEAN NOT NULL DEFAULT false,
334
+ "sensitivity_level" TEXT NOT NULL DEFAULT 'benign',
335
+ "owner_context" TEXT NOT NULL DEFAULT 'primary',
336
+ "screening_risk_level" TEXT NOT NULL DEFAULT 'low',
337
+ "content_category" TEXT,
338
+
339
+ CONSTRAINT "post_comments_pkey" PRIMARY KEY ("id")
340
+ );
341
+
342
+ -- CreateTable
343
+ CREATE TABLE "post_comment_media" (
344
+ "id" TEXT NOT NULL,
345
+ "comment_id" TEXT NOT NULL,
346
+ "media_id" TEXT NOT NULL,
347
+ "alt" TEXT,
348
+ "order" INTEGER NOT NULL DEFAULT 0,
349
+
350
+ CONSTRAINT "post_comment_media_pkey" PRIMARY KEY ("id")
351
+ );
352
+
353
+ -- CreateTable
354
+ CREATE TABLE "comment_sentiments" (
355
+ "id" TEXT NOT NULL,
356
+ "comment_id" TEXT NOT NULL,
357
+ "comment_uri" TEXT,
358
+ "author_id" TEXT NOT NULL,
359
+ "sentiment" TEXT NOT NULL,
360
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
361
+
362
+ CONSTRAINT "comment_sentiments_pkey" PRIMARY KEY ("id")
363
+ );
364
+
365
+ -- CreateTable
366
+ CREATE TABLE "post_subjects" (
367
+ "id" TEXT NOT NULL,
368
+ "post_id" TEXT NOT NULL,
369
+ "entity_id" TEXT NOT NULL,
370
+ "is_primary" BOOLEAN NOT NULL DEFAULT false,
371
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
372
+
373
+ CONSTRAINT "post_subjects_pkey" PRIMARY KEY ("id")
374
+ );
375
+
376
+ -- CreateTable
377
+ CREATE TABLE "security_events" (
378
+ "id" TEXT NOT NULL,
379
+ "type" TEXT NOT NULL,
380
+ "severity" TEXT NOT NULL,
381
+ "userId" TEXT,
382
+ "partnerId" TEXT,
383
+ "ip_address" TEXT,
384
+ "user_agent" TEXT,
385
+ "details" TEXT NOT NULL,
386
+ "timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
387
+ "retention_until" TIMESTAMP(3),
388
+
389
+ CONSTRAINT "security_events_pkey" PRIMARY KEY ("id")
390
+ );
391
+
392
+ -- CreateTable
393
+ CREATE TABLE "partners" (
394
+ "id" TEXT NOT NULL,
395
+ "name" TEXT NOT NULL,
396
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
397
+
398
+ CONSTRAINT "partners_pkey" PRIMARY KEY ("id")
399
+ );
400
+
401
+ -- CreateTable
402
+ CREATE TABLE "feature_toggles" (
403
+ "id" TEXT NOT NULL,
404
+ "key" TEXT NOT NULL,
405
+ "enabled" BOOLEAN NOT NULL DEFAULT false,
406
+ "description" TEXT,
407
+ "changed_by" TEXT,
408
+ "last_changed" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
409
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
410
+
411
+ CONSTRAINT "feature_toggles_pkey" PRIMARY KEY ("id")
412
+ );
413
+
414
+ -- CreateTable
415
+ CREATE TABLE "invitations" (
416
+ "id" TEXT NOT NULL,
417
+ "code" TEXT NOT NULL,
418
+ "created_by" TEXT NOT NULL,
419
+ "email" TEXT,
420
+ "used" BOOLEAN NOT NULL DEFAULT false,
421
+ "used_by" TEXT,
422
+ "used_at" TIMESTAMP(3),
423
+ "scanned_at" TIMESTAMP(3),
424
+ "scanned_by" TEXT,
425
+ "expires_at" TIMESTAMP(3),
426
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
427
+
428
+ CONSTRAINT "invitations_pkey" PRIMARY KEY ("id")
429
+ );
430
+
431
+ -- CreateTable
432
+ CREATE TABLE "taxonomy_dimensions" (
433
+ "id" TEXT NOT NULL,
434
+ "tenant_id" TEXT NOT NULL,
435
+ "code" TEXT NOT NULL,
436
+ "display_name" TEXT NOT NULL,
437
+ "description" TEXT,
438
+ "order" INTEGER NOT NULL DEFAULT 0,
439
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
440
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
441
+ "updated_at" TIMESTAMP(3) NOT NULL,
442
+
443
+ CONSTRAINT "taxonomy_dimensions_pkey" PRIMARY KEY ("id")
444
+ );
445
+
446
+ -- CreateTable
447
+ CREATE TABLE "taxonomy_categories" (
448
+ "id" TEXT NOT NULL,
449
+ "tenant_id" TEXT NOT NULL,
450
+ "dimension_id" TEXT NOT NULL,
451
+ "code" TEXT NOT NULL,
452
+ "display_name" TEXT NOT NULL,
453
+ "description" TEXT,
454
+ "order" INTEGER NOT NULL DEFAULT 0,
455
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
456
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
457
+ "updated_at" TIMESTAMP(3) NOT NULL,
458
+
459
+ CONSTRAINT "taxonomy_categories_pkey" PRIMARY KEY ("id")
460
+ );
461
+
462
+ -- CreateTable
463
+ CREATE TABLE "taxonomy_taxons" (
464
+ "id" TEXT NOT NULL,
465
+ "tenant_id" TEXT NOT NULL,
466
+ "category_id" TEXT NOT NULL,
467
+ "taxonId" TEXT NOT NULL,
468
+ "display_name" TEXT NOT NULL,
469
+ "description" TEXT,
470
+ "order" INTEGER NOT NULL DEFAULT 0,
471
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
472
+ "synonyms" JSONB,
473
+ "userTerms" JSONB,
474
+ "parent_taxon_id" TEXT,
475
+ "translations" JSONB,
476
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
477
+ "updated_at" TIMESTAMP(3) NOT NULL,
478
+
479
+ CONSTRAINT "taxonomy_taxons_pkey" PRIMARY KEY ("id")
480
+ );
481
+
482
+ -- CreateTable
483
+ CREATE TABLE "post_taxonomy_tags" (
484
+ "id" TEXT NOT NULL,
485
+ "post_id" TEXT NOT NULL,
486
+ "taxon_id" TEXT NOT NULL,
487
+ "added_by" TEXT NOT NULL,
488
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
489
+
490
+ CONSTRAINT "post_taxonomy_tags_pkey" PRIMARY KEY ("id")
491
+ );
492
+
493
+ -- CreateTable
494
+ CREATE TABLE "entity_taxonomy_tags" (
495
+ "id" TEXT NOT NULL,
496
+ "entity_id" TEXT NOT NULL,
497
+ "taxon_id" TEXT NOT NULL,
498
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
499
+
500
+ CONSTRAINT "entity_taxonomy_tags_pkey" PRIMARY KEY ("id")
501
+ );
502
+
503
+ -- CreateTable
504
+ CREATE TABLE "product_taxonomy_tags" (
505
+ "id" TEXT NOT NULL,
506
+ "product_id" TEXT NOT NULL,
507
+ "taxon_id" TEXT NOT NULL,
508
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
509
+
510
+ CONSTRAINT "product_taxonomy_tags_pkey" PRIMARY KEY ("id")
511
+ );
512
+
513
+ -- CreateTable
514
+ CREATE TABLE "entity_ownerships" (
515
+ "id" TEXT NOT NULL,
516
+ "entity_id" TEXT NOT NULL,
517
+ "user_id" TEXT NOT NULL,
518
+ "role" "OwnershipRole" NOT NULL DEFAULT 'CO_OWNER',
519
+ "added_by_user_id" TEXT NOT NULL,
520
+ "added_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
521
+ "status" "OwnershipStatus" NOT NULL DEFAULT 'ACTIVE',
522
+ "removed_at" TIMESTAMP(3),
523
+
524
+ CONSTRAINT "entity_ownerships_pkey" PRIMARY KEY ("id")
525
+ );
526
+
527
+ -- CreateTable
528
+ CREATE TABLE "circle_configs" (
529
+ "id" TEXT NOT NULL,
530
+ "user_id" TEXT NOT NULL,
531
+ "inner_threshold" DOUBLE PRECISION NOT NULL DEFAULT 0.8,
532
+ "close_friend_threshold" DOUBLE PRECISION NOT NULL DEFAULT 0.5,
533
+ "community_threshold" DOUBLE PRECISION NOT NULL DEFAULT 0.2,
534
+ "daily_deck_size" INTEGER,
535
+ "glance_limit" INTEGER NOT NULL DEFAULT 20,
536
+ "depth_window_days" INTEGER NOT NULL DEFAULT 7,
537
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
538
+ "updated_at" TIMESTAMP(3) NOT NULL,
539
+
540
+ CONSTRAINT "circle_configs_pkey" PRIMARY KEY ("id")
541
+ );
542
+
543
+ -- CreateTable
544
+ CREATE TABLE "circle_read_states" (
545
+ "id" TEXT NOT NULL,
546
+ "user_id" TEXT NOT NULL,
547
+ "tier" INTEGER NOT NULL,
548
+ "last_read_at" TIMESTAMP(3) NOT NULL,
549
+ "last_read_post_id" TEXT,
550
+ "caught_up" BOOLEAN NOT NULL DEFAULT true,
551
+ "updated_at" TIMESTAMP(3) NOT NULL,
552
+
553
+ CONSTRAINT "circle_read_states_pkey" PRIMARY KEY ("id")
554
+ );
555
+
556
+ -- CreateTable
557
+ CREATE TABLE "groups" (
558
+ "id" TEXT NOT NULL,
559
+ "name" TEXT NOT NULL,
560
+ "description" TEXT,
561
+ "actor_uri" TEXT NOT NULL,
562
+ "inbox_url" TEXT NOT NULL,
563
+ "outbox_url" TEXT NOT NULL,
564
+ "followers_url" TEXT NOT NULL,
565
+ "public_key" TEXT NOT NULL,
566
+ "private_key" TEXT NOT NULL,
567
+ "privacy" "GroupPrivacy" NOT NULL,
568
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
569
+ "updated_at" TIMESTAMP(3) NOT NULL,
570
+
571
+ CONSTRAINT "groups_pkey" PRIMARY KEY ("id")
572
+ );
573
+
574
+ -- CreateTable
575
+ CREATE TABLE "group_members" (
576
+ "id" TEXT NOT NULL,
577
+ "group_id" TEXT NOT NULL,
578
+ "actor_uri" TEXT NOT NULL,
579
+ "role" "GroupRole" NOT NULL,
580
+ "joined_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
581
+
582
+ CONSTRAINT "group_members_pkey" PRIMARY KEY ("id")
583
+ );
584
+
585
+ -- CreateTable
586
+ CREATE TABLE "activities" (
587
+ "id" TEXT NOT NULL,
588
+ "actor_uri" TEXT NOT NULL,
589
+ "type" TEXT NOT NULL,
590
+ "object_id" TEXT,
591
+ "target_id" TEXT,
592
+ "to" JSONB,
593
+ "cc" JSONB,
594
+ "bto" JSONB,
595
+ "bcc" JSONB,
596
+ "published" TIMESTAMP(3) NOT NULL,
597
+ "received_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
598
+ "inbox_actor_uri" TEXT,
599
+ "outbox_actor_uri" TEXT,
600
+
601
+ CONSTRAINT "activities_pkey" PRIMARY KEY ("id")
602
+ );
603
+
604
+ -- CreateTable
605
+ CREATE TABLE "direct_messages" (
606
+ "id" TEXT NOT NULL,
607
+ "sender_id" TEXT NOT NULL,
608
+ "recipient_id" TEXT NOT NULL,
609
+ "text" TEXT NOT NULL,
610
+ "encrypted_text" TEXT,
611
+ "encryption_key_id" TEXT,
612
+ "encryption_algorithm" TEXT DEFAULT 'AES-256-GCM',
613
+ "encryption_iv" TEXT,
614
+ "object_id" TEXT,
615
+ "activity_id" TEXT,
616
+ "read" BOOLEAN NOT NULL DEFAULT false,
617
+ "read_at" TIMESTAMP(3),
618
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
619
+
620
+ CONSTRAINT "direct_messages_pkey" PRIMARY KEY ("id")
621
+ );
622
+
623
+ -- CreateTable
624
+ CREATE TABLE "custom_audiences" (
625
+ "id" TEXT NOT NULL,
626
+ "name" TEXT NOT NULL,
627
+ "creator_id" TEXT NOT NULL,
628
+ "collection_id" TEXT NOT NULL,
629
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
630
+ "updated_at" TIMESTAMP(3) NOT NULL,
631
+
632
+ CONSTRAINT "custom_audiences_pkey" PRIMARY KEY ("id")
633
+ );
634
+
635
+ -- CreateTable
636
+ CREATE TABLE "custom_audience_members" (
637
+ "id" TEXT NOT NULL,
638
+ "audience_id" TEXT NOT NULL,
639
+ "member_id" TEXT NOT NULL,
640
+ "added_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
641
+
642
+ CONSTRAINT "custom_audience_members_pkey" PRIMARY KEY ("id")
643
+ );
644
+
645
+ -- CreateTable
646
+ CREATE TABLE "domain_reputations" (
647
+ "id" TEXT NOT NULL,
648
+ "domain" TEXT NOT NULL,
649
+ "reputation" INTEGER NOT NULL DEFAULT 0,
650
+ "status" TEXT NOT NULL DEFAULT 'unknown',
651
+ "last_checked" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
652
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
653
+ "updated_at" TIMESTAMP(3) NOT NULL,
654
+
655
+ CONSTRAINT "domain_reputations_pkey" PRIMARY KEY ("id")
656
+ );
657
+
658
+ -- CreateTable
659
+ CREATE TABLE "link_checks" (
660
+ "id" TEXT NOT NULL,
661
+ "post_id" TEXT,
662
+ "comment_id" TEXT,
663
+ "original_url" TEXT NOT NULL,
664
+ "normalized_url" TEXT NOT NULL,
665
+ "final_url" TEXT,
666
+ "domain" TEXT NOT NULL,
667
+ "status" TEXT NOT NULL,
668
+ "check_type" TEXT NOT NULL,
669
+ "threat_intel" JSONB,
670
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
671
+ "checked_at" TIMESTAMP(3),
672
+
673
+ CONSTRAINT "link_checks_pkey" PRIMARY KEY ("id")
674
+ );
675
+
676
+ -- CreateTable
677
+ CREATE TABLE "link_reports" (
678
+ "id" TEXT NOT NULL,
679
+ "user_id" TEXT NOT NULL,
680
+ "link_url" TEXT NOT NULL,
681
+ "domain" TEXT NOT NULL,
682
+ "reason" TEXT,
683
+ "status" TEXT NOT NULL DEFAULT 'pending',
684
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
685
+
686
+ CONSTRAINT "link_reports_pkey" PRIMARY KEY ("id")
687
+ );
688
+
689
+ -- CreateTable
690
+ CREATE TABLE "EmailSuppression" (
691
+ "id" TEXT NOT NULL,
692
+ "email" TEXT NOT NULL,
693
+ "reason" TEXT NOT NULL,
694
+ "bounceType" TEXT,
695
+ "suppressedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
696
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
697
+ "updatedAt" TIMESTAMP(3) NOT NULL,
698
+
699
+ CONSTRAINT "EmailSuppression_pkey" PRIMARY KEY ("id")
700
+ );
701
+
702
+ -- CreateTable
703
+ CREATE TABLE "deletion_audit_logs" (
704
+ "id" TEXT NOT NULL,
705
+ "user_id" TEXT NOT NULL,
706
+ "email" TEXT NOT NULL,
707
+ "requested_at" TIMESTAMP(3) NOT NULL,
708
+ "confirmed_at" TIMESTAMP(3),
709
+ "completed_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
710
+ "items_deleted" JSONB NOT NULL,
711
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
712
+
713
+ CONSTRAINT "deletion_audit_logs_pkey" PRIMARY KEY ("id")
714
+ );
715
+
716
+ -- CreateTable
717
+ CREATE TABLE "parental_links" (
718
+ "id" TEXT NOT NULL,
719
+ "child_id" TEXT NOT NULL,
720
+ "guardian_id" TEXT NOT NULL,
721
+ "status" "ParentalLinkStatus" NOT NULL DEFAULT 'PENDING',
722
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
723
+ "confirmed_at" TIMESTAMP(3),
724
+
725
+ CONSTRAINT "parental_links_pkey" PRIMARY KEY ("id")
726
+ );
727
+
728
+ -- CreateTable
729
+ CREATE TABLE "notifications" (
730
+ "id" TEXT NOT NULL,
731
+ "user_id" TEXT NOT NULL,
732
+ "type" "NotificationType" NOT NULL,
733
+ "title" TEXT NOT NULL,
734
+ "body" TEXT NOT NULL,
735
+ "data" JSONB,
736
+ "read" BOOLEAN NOT NULL DEFAULT false,
737
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
738
+ "delivered_at" TIMESTAMP(3),
739
+ "batch_id" TEXT,
740
+
741
+ CONSTRAINT "notifications_pkey" PRIMARY KEY ("id")
742
+ );
743
+
744
+ -- CreateTable
745
+ CREATE TABLE "notification_preferences" (
746
+ "id" TEXT NOT NULL,
747
+ "user_id" TEXT NOT NULL,
748
+ "dm_enabled" BOOLEAN NOT NULL DEFAULT true,
749
+ "follow_enabled" BOOLEAN NOT NULL DEFAULT true,
750
+ "digest_enabled" BOOLEAN NOT NULL DEFAULT true,
751
+ "system_enabled" BOOLEAN NOT NULL DEFAULT true,
752
+ "relationship_enabled" BOOLEAN NOT NULL DEFAULT true,
753
+
754
+ CONSTRAINT "notification_preferences_pkey" PRIMARY KEY ("id")
755
+ );
756
+
757
+ -- CreateTable
758
+ CREATE TABLE "connection_codes" (
759
+ "id" TEXT NOT NULL,
760
+ "code" TEXT NOT NULL,
761
+ "creator_id" TEXT NOT NULL,
762
+ "entity_id" TEXT,
763
+ "expires_at" TIMESTAMP(3) NOT NULL,
764
+ "max_uses" INTEGER NOT NULL,
765
+ "use_count" INTEGER NOT NULL DEFAULT 0,
766
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
767
+
768
+ CONSTRAINT "connection_codes_pkey" PRIMARY KEY ("id")
769
+ );
770
+
771
+ -- CreateTable
772
+ CREATE TABLE "connection_code_redemptions" (
773
+ "id" TEXT NOT NULL,
774
+ "code_id" TEXT NOT NULL,
775
+ "user_id" TEXT NOT NULL,
776
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
777
+
778
+ CONSTRAINT "connection_code_redemptions_pkey" PRIMARY KEY ("id")
779
+ );
780
+
781
+ -- CreateIndex
782
+ CREATE UNIQUE INDEX "entities_actor_uri_key" ON "entities"("actor_uri");
783
+
784
+ -- CreateIndex
785
+ CREATE INDEX "entities_status_idx" ON "entities"("status");
786
+
787
+ -- CreateIndex
788
+ CREATE INDEX "entities_entity_type_status_idx" ON "entities"("entity_type", "status");
789
+
790
+ -- CreateIndex
791
+ CREATE INDEX "post_geo_index_entity_ref_idx" ON "post_geo_index"("entity_ref");
792
+
793
+ -- CreateIndex
794
+ CREATE INDEX "post_geo_index_geohash_idx" ON "post_geo_index"("geohash");
795
+
796
+ -- CreateIndex
797
+ CREATE INDEX "post_geo_index_sensitivity_level_idx" ON "post_geo_index"("sensitivity_level");
798
+
799
+ -- CreateIndex
800
+ CREATE UNIQUE INDEX "ingest_state_cursor_key" ON "ingest_state"("cursor");
801
+
802
+ -- CreateIndex
803
+ CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
804
+
805
+ -- CreateIndex
806
+ CREATE UNIQUE INDEX "users_actor_uri_key" ON "users"("actor_uri");
807
+
808
+ -- CreateIndex
809
+ CREATE UNIQUE INDEX "users_cognito_sub_key" ON "users"("cognito_sub");
810
+
811
+ -- CreateIndex
812
+ CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
813
+
814
+ -- CreateIndex
815
+ CREATE UNIQUE INDEX "users_email_hash_key" ON "users"("email_hash");
816
+
817
+ -- CreateIndex
818
+ CREATE UNIQUE INDEX "users_anonymous_id_key" ON "users"("anonymous_id");
819
+
820
+ -- CreateIndex
821
+ CREATE INDEX "users_role_idx" ON "users"("role");
822
+
823
+ -- CreateIndex
824
+ CREATE INDEX "users_region_idx" ON "users"("region");
825
+
826
+ -- CreateIndex
827
+ CREATE INDEX "users_data_region_idx" ON "users"("data_region");
828
+
829
+ -- CreateIndex
830
+ CREATE INDEX "users_suspended_idx" ON "users"("suspended");
831
+
832
+ -- CreateIndex
833
+ CREATE INDEX "users_partnerId_idx" ON "users"("partnerId");
834
+
835
+ -- CreateIndex
836
+ CREATE INDEX "users_username_idx" ON "users"("username");
837
+
838
+ -- CreateIndex
839
+ CREATE INDEX "users_email_verified_idx" ON "users"("email_verified");
840
+
841
+ -- CreateIndex
842
+ CREATE INDEX "users_identity_verified_idx" ON "users"("identity_verified");
843
+
844
+ -- CreateIndex
845
+ CREATE INDEX "users_actor_uri_idx" ON "users"("actor_uri");
846
+
847
+ -- CreateIndex
848
+ CREATE INDEX "users_encryption_key_id_idx" ON "users"("encryption_key_id");
849
+
850
+ -- CreateIndex
851
+ CREATE INDEX "users_travel_mode_active_idx" ON "users"("travel_mode_active");
852
+
853
+ -- CreateIndex
854
+ CREATE INDEX "users_default_context_idx" ON "users"("default_context");
855
+
856
+ -- CreateIndex
857
+ CREATE INDEX "users_email_hash_idx" ON "users"("email_hash");
858
+
859
+ -- CreateIndex
860
+ CREATE INDEX "users_anonymous_id_idx" ON "users"("anonymous_id");
861
+
862
+ -- CreateIndex
863
+ CREATE INDEX "users_cognito_sub_idx" ON "users"("cognito_sub");
864
+
865
+ -- CreateIndex
866
+ CREATE UNIQUE INDEX "mfa_enrollments_user_id_key" ON "mfa_enrollments"("user_id");
867
+
868
+ -- CreateIndex
869
+ CREATE INDEX "user_encryption_keys_user_id_idx" ON "user_encryption_keys"("user_id");
870
+
871
+ -- CreateIndex
872
+ CREATE INDEX "user_encryption_keys_user_id_key_type_idx" ON "user_encryption_keys"("user_id", "key_type");
873
+
874
+ -- CreateIndex
875
+ CREATE UNIQUE INDEX "user_encryption_keys_user_id_context_id_keyPurpose_key_type_key" ON "user_encryption_keys"("user_id", "context_id", "keyPurpose", "key_type");
876
+
877
+ -- CreateIndex
878
+ CREATE INDEX "cross_region_consent_user_id_idx" ON "cross_region_consent"("user_id");
879
+
880
+ -- CreateIndex
881
+ CREATE INDEX "cross_region_consent_consented_idx" ON "cross_region_consent"("consented");
882
+
883
+ -- CreateIndex
884
+ CREATE INDEX "cross_region_consent_data_region_access_region_idx" ON "cross_region_consent"("data_region", "access_region");
885
+
886
+ -- CreateIndex
887
+ CREATE UNIQUE INDEX "cross_region_consent_user_id_data_region_access_region_key" ON "cross_region_consent"("user_id", "data_region", "access_region");
888
+
889
+ -- CreateIndex
890
+ CREATE UNIQUE INDEX "posts_activity_id_key" ON "posts"("activity_id");
891
+
892
+ -- CreateIndex
893
+ CREATE UNIQUE INDEX "posts_object_id_key" ON "posts"("object_id");
894
+
895
+ -- CreateIndex
896
+ CREATE INDEX "posts_author_id_created_at_idx" ON "posts"("author_id", "created_at");
897
+
898
+ -- CreateIndex
899
+ CREATE INDEX "posts_author_id_radius_created_at_idx" ON "posts"("author_id", "radius", "created_at");
900
+
901
+ -- CreateIndex
902
+ CREATE INDEX "posts_primary_entity_id_idx" ON "posts"("primary_entity_id");
903
+
904
+ -- CreateIndex
905
+ CREATE INDEX "posts_created_at_idx" ON "posts"("created_at");
906
+
907
+ -- CreateIndex
908
+ CREATE INDEX "posts_uri_idx" ON "posts"("uri");
909
+
910
+ -- CreateIndex
911
+ CREATE INDEX "posts_deleted_at_idx" ON "posts"("deleted_at");
912
+
913
+ -- CreateIndex
914
+ CREATE INDEX "posts_data_region_created_at_idx" ON "posts"("data_region", "created_at");
915
+
916
+ -- CreateIndex
917
+ CREATE INDEX "posts_activity_id_idx" ON "posts"("activity_id");
918
+
919
+ -- CreateIndex
920
+ CREATE INDEX "posts_object_id_idx" ON "posts"("object_id");
921
+
922
+ -- CreateIndex
923
+ CREATE INDEX "posts_group_id_idx" ON "posts"("group_id");
924
+
925
+ -- CreateIndex
926
+ CREATE INDEX "posts_author_id_owner_context_sensitivity_level_idx" ON "posts"("author_id", "owner_context", "sensitivity_level");
927
+
928
+ -- CreateIndex
929
+ CREATE INDEX "posts_sensitivity_level_idx" ON "posts"("sensitivity_level");
930
+
931
+ -- CreateIndex
932
+ CREATE INDEX "posts_owner_context_idx" ON "posts"("owner_context");
933
+
934
+ -- CreateIndex
935
+ CREATE INDEX "posts_screening_risk_level_idx" ON "posts"("screening_risk_level");
936
+
937
+ -- CreateIndex
938
+ CREATE INDEX "posts_edited_at_idx" ON "posts"("edited_at");
939
+
940
+ -- CreateIndex
941
+ CREATE UNIQUE INDEX "media_files_content_hash_key" ON "media_files"("content_hash");
942
+
943
+ -- CreateIndex
944
+ CREATE UNIQUE INDEX "media_files_cid_key" ON "media_files"("cid");
945
+
946
+ -- CreateIndex
947
+ CREATE INDEX "media_files_content_hash_idx" ON "media_files"("content_hash");
948
+
949
+ -- CreateIndex
950
+ CREATE INDEX "media_files_cid_idx" ON "media_files"("cid");
951
+
952
+ -- CreateIndex
953
+ CREATE INDEX "media_files_hidden_deleted_at_idx" ON "media_files"("hidden", "deleted_at");
954
+
955
+ -- CreateIndex
956
+ CREATE INDEX "media_files_created_at_idx" ON "media_files"("created_at");
957
+
958
+ -- CreateIndex
959
+ CREATE INDEX "media_files_date_taken_idx" ON "media_files"("date_taken");
960
+
961
+ -- CreateIndex
962
+ CREATE INDEX "media_files_metadata_visible_idx" ON "media_files"("metadata_visible");
963
+
964
+ -- CreateIndex
965
+ CREATE INDEX "media_files_location_visible_idx" ON "media_files"("location_visible");
966
+
967
+ -- CreateIndex
968
+ CREATE INDEX "media_files_gps_latitude_gps_longitude_idx" ON "media_files"("gps_latitude", "gps_longitude");
969
+
970
+ -- CreateIndex
971
+ CREATE INDEX "media_files_upload_status_idx" ON "media_files"("upload_status");
972
+
973
+ -- CreateIndex
974
+ CREATE INDEX "media_files_uploaded_by_idx" ON "media_files"("uploaded_by");
975
+
976
+ -- CreateIndex
977
+ CREATE INDEX "media_files_upload_batch_id_idx" ON "media_files"("upload_batch_id");
978
+
979
+ -- CreateIndex
980
+ CREATE INDEX "media_files_reconciled_at_idx" ON "media_files"("reconciled_at");
981
+
982
+ -- CreateIndex
983
+ CREATE INDEX "media_files_upload_status_reconciled_at_idx" ON "media_files"("upload_status", "reconciled_at");
984
+
985
+ -- CreateIndex
986
+ CREATE INDEX "media_files_attached_to_post_created_at_idx" ON "media_files"("attached_to_post", "created_at");
987
+
988
+ -- CreateIndex
989
+ CREATE INDEX "media_files_orphaned_at_idx" ON "media_files"("orphaned_at");
990
+
991
+ -- CreateIndex
992
+ CREATE INDEX "upload_sessions_user_id_status_idx" ON "upload_sessions"("user_id", "status");
993
+
994
+ -- CreateIndex
995
+ CREATE INDEX "upload_sessions_expires_at_idx" ON "upload_sessions"("expires_at");
996
+
997
+ -- CreateIndex
998
+ CREATE INDEX "post_media_post_id_idx" ON "post_media"("post_id");
999
+
1000
+ -- CreateIndex
1001
+ CREATE INDEX "post_media_media_id_idx" ON "post_media"("media_id");
1002
+
1003
+ -- CreateIndex
1004
+ CREATE UNIQUE INDEX "post_media_post_id_media_id_key" ON "post_media"("post_id", "media_id");
1005
+
1006
+ -- CreateIndex
1007
+ CREATE INDEX "post_sentiments_post_id_idx" ON "post_sentiments"("post_id");
1008
+
1009
+ -- CreateIndex
1010
+ CREATE INDEX "post_sentiments_post_uri_idx" ON "post_sentiments"("post_uri");
1011
+
1012
+ -- CreateIndex
1013
+ CREATE INDEX "post_sentiments_author_id_idx" ON "post_sentiments"("author_id");
1014
+
1015
+ -- CreateIndex
1016
+ CREATE INDEX "post_sentiments_post_id_sentiment_idx" ON "post_sentiments"("post_id", "sentiment");
1017
+
1018
+ -- CreateIndex
1019
+ CREATE INDEX "post_sentiments_post_id_created_at_idx" ON "post_sentiments"("post_id", "created_at");
1020
+
1021
+ -- CreateIndex
1022
+ CREATE INDEX "idx_post_sentiment_summary" ON "post_sentiments"("post_id", "sentiment", "created_at" DESC);
1023
+
1024
+ -- CreateIndex
1025
+ CREATE INDEX "idx_post_sentiment_pagination" ON "post_sentiments"("post_id", "sentiment", "created_at" DESC, "id" DESC);
1026
+
1027
+ -- CreateIndex
1028
+ CREATE UNIQUE INDEX "post_sentiments_post_id_author_id_key" ON "post_sentiments"("post_id", "author_id");
1029
+
1030
+ -- CreateIndex
1031
+ CREATE UNIQUE INDEX "post_sentiments_post_uri_author_id_key" ON "post_sentiments"("post_uri", "author_id");
1032
+
1033
+ -- CreateIndex
1034
+ CREATE INDEX "post_comments_post_id_created_at_idx" ON "post_comments"("post_id", "created_at");
1035
+
1036
+ -- CreateIndex
1037
+ CREATE INDEX "post_comments_post_uri_created_at_idx" ON "post_comments"("post_uri", "created_at");
1038
+
1039
+ -- CreateIndex
1040
+ CREATE INDEX "post_comments_author_id_idx" ON "post_comments"("author_id");
1041
+
1042
+ -- CreateIndex
1043
+ CREATE INDEX "post_comments_hidden_by_post_owner_idx" ON "post_comments"("hidden_by_post_owner");
1044
+
1045
+ -- CreateIndex
1046
+ CREATE INDEX "post_comments_deleted_at_idx" ON "post_comments"("deleted_at");
1047
+
1048
+ -- CreateIndex
1049
+ CREATE INDEX "post_comments_author_id_owner_context_idx" ON "post_comments"("author_id", "owner_context");
1050
+
1051
+ -- CreateIndex
1052
+ CREATE INDEX "post_comments_sensitivity_level_idx" ON "post_comments"("sensitivity_level");
1053
+
1054
+ -- CreateIndex
1055
+ CREATE INDEX "post_comments_owner_context_idx" ON "post_comments"("owner_context");
1056
+
1057
+ -- CreateIndex
1058
+ CREATE INDEX "post_comments_screening_risk_level_idx" ON "post_comments"("screening_risk_level");
1059
+
1060
+ -- CreateIndex
1061
+ CREATE INDEX "post_comments_root_uri_idx" ON "post_comments"("root_uri");
1062
+
1063
+ -- CreateIndex
1064
+ CREATE INDEX "post_comments_reply_to_uri_idx" ON "post_comments"("reply_to_uri");
1065
+
1066
+ -- CreateIndex
1067
+ CREATE INDEX "post_comments_root_uri_created_at_idx" ON "post_comments"("root_uri", "created_at");
1068
+
1069
+ -- CreateIndex
1070
+ CREATE INDEX "post_comments_post_id_root_uri_idx" ON "post_comments"("post_id", "root_uri");
1071
+
1072
+ -- CreateIndex
1073
+ CREATE INDEX "post_comment_media_comment_id_idx" ON "post_comment_media"("comment_id");
1074
+
1075
+ -- CreateIndex
1076
+ CREATE INDEX "post_comment_media_media_id_idx" ON "post_comment_media"("media_id");
1077
+
1078
+ -- CreateIndex
1079
+ CREATE UNIQUE INDEX "post_comment_media_comment_id_media_id_key" ON "post_comment_media"("comment_id", "media_id");
1080
+
1081
+ -- CreateIndex
1082
+ CREATE INDEX "comment_sentiments_comment_id_idx" ON "comment_sentiments"("comment_id");
1083
+
1084
+ -- CreateIndex
1085
+ CREATE INDEX "comment_sentiments_comment_uri_idx" ON "comment_sentiments"("comment_uri");
1086
+
1087
+ -- CreateIndex
1088
+ CREATE INDEX "comment_sentiments_author_id_idx" ON "comment_sentiments"("author_id");
1089
+
1090
+ -- CreateIndex
1091
+ CREATE INDEX "comment_sentiments_comment_id_sentiment_idx" ON "comment_sentiments"("comment_id", "sentiment");
1092
+
1093
+ -- CreateIndex
1094
+ CREATE INDEX "comment_sentiments_comment_id_created_at_idx" ON "comment_sentiments"("comment_id", "created_at");
1095
+
1096
+ -- CreateIndex
1097
+ CREATE UNIQUE INDEX "comment_sentiments_comment_id_author_id_key" ON "comment_sentiments"("comment_id", "author_id");
1098
+
1099
+ -- CreateIndex
1100
+ CREATE UNIQUE INDEX "comment_sentiments_comment_uri_author_id_key" ON "comment_sentiments"("comment_uri", "author_id");
1101
+
1102
+ -- CreateIndex
1103
+ CREATE INDEX "post_subjects_post_id_idx" ON "post_subjects"("post_id");
1104
+
1105
+ -- CreateIndex
1106
+ CREATE INDEX "post_subjects_entity_id_created_at_idx" ON "post_subjects"("entity_id", "created_at");
1107
+
1108
+ -- CreateIndex
1109
+ CREATE INDEX "post_subjects_entity_id_idx" ON "post_subjects"("entity_id");
1110
+
1111
+ -- CreateIndex
1112
+ CREATE UNIQUE INDEX "post_subjects_post_id_entity_id_key" ON "post_subjects"("post_id", "entity_id");
1113
+
1114
+ -- CreateIndex
1115
+ CREATE INDEX "security_events_type_idx" ON "security_events"("type");
1116
+
1117
+ -- CreateIndex
1118
+ CREATE INDEX "security_events_severity_idx" ON "security_events"("severity");
1119
+
1120
+ -- CreateIndex
1121
+ CREATE INDEX "security_events_timestamp_idx" ON "security_events"("timestamp");
1122
+
1123
+ -- CreateIndex
1124
+ CREATE INDEX "security_events_userId_idx" ON "security_events"("userId");
1125
+
1126
+ -- CreateIndex
1127
+ CREATE INDEX "security_events_partnerId_idx" ON "security_events"("partnerId");
1128
+
1129
+ -- CreateIndex
1130
+ CREATE INDEX "security_events_ip_address_idx" ON "security_events"("ip_address");
1131
+
1132
+ -- CreateIndex
1133
+ CREATE INDEX "security_events_retention_until_idx" ON "security_events"("retention_until");
1134
+
1135
+ -- CreateIndex
1136
+ CREATE UNIQUE INDEX "feature_toggles_key_key" ON "feature_toggles"("key");
1137
+
1138
+ -- CreateIndex
1139
+ CREATE INDEX "feature_toggles_key_idx" ON "feature_toggles"("key");
1140
+
1141
+ -- CreateIndex
1142
+ CREATE INDEX "feature_toggles_enabled_idx" ON "feature_toggles"("enabled");
1143
+
1144
+ -- CreateIndex
1145
+ CREATE UNIQUE INDEX "invitations_code_key" ON "invitations"("code");
1146
+
1147
+ -- CreateIndex
1148
+ CREATE INDEX "invitations_code_idx" ON "invitations"("code");
1149
+
1150
+ -- CreateIndex
1151
+ CREATE INDEX "invitations_created_by_idx" ON "invitations"("created_by");
1152
+
1153
+ -- CreateIndex
1154
+ CREATE INDEX "invitations_created_by_created_at_idx" ON "invitations"("created_by", "created_at");
1155
+
1156
+ -- CreateIndex
1157
+ CREATE INDEX "invitations_used_by_idx" ON "invitations"("used_by");
1158
+
1159
+ -- CreateIndex
1160
+ CREATE INDEX "invitations_used_idx" ON "invitations"("used");
1161
+
1162
+ -- CreateIndex
1163
+ CREATE INDEX "invitations_email_idx" ON "invitations"("email");
1164
+
1165
+ -- CreateIndex
1166
+ CREATE INDEX "invitations_expires_at_idx" ON "invitations"("expires_at");
1167
+
1168
+ -- CreateIndex
1169
+ CREATE INDEX "taxonomy_dimensions_tenant_id_idx" ON "taxonomy_dimensions"("tenant_id");
1170
+
1171
+ -- CreateIndex
1172
+ CREATE INDEX "taxonomy_dimensions_tenant_id_code_idx" ON "taxonomy_dimensions"("tenant_id", "code");
1173
+
1174
+ -- CreateIndex
1175
+ CREATE INDEX "taxonomy_dimensions_tenant_id_is_active_idx" ON "taxonomy_dimensions"("tenant_id", "is_active");
1176
+
1177
+ -- CreateIndex
1178
+ CREATE UNIQUE INDEX "taxonomy_dimensions_tenant_id_code_key" ON "taxonomy_dimensions"("tenant_id", "code");
1179
+
1180
+ -- CreateIndex
1181
+ CREATE INDEX "taxonomy_categories_tenant_id_idx" ON "taxonomy_categories"("tenant_id");
1182
+
1183
+ -- CreateIndex
1184
+ CREATE INDEX "taxonomy_categories_tenant_id_dimension_id_idx" ON "taxonomy_categories"("tenant_id", "dimension_id");
1185
+
1186
+ -- CreateIndex
1187
+ CREATE INDEX "taxonomy_categories_tenant_id_is_active_idx" ON "taxonomy_categories"("tenant_id", "is_active");
1188
+
1189
+ -- CreateIndex
1190
+ CREATE UNIQUE INDEX "taxonomy_categories_tenant_id_dimension_id_code_key" ON "taxonomy_categories"("tenant_id", "dimension_id", "code");
1191
+
1192
+ -- CreateIndex
1193
+ CREATE INDEX "taxonomy_taxons_tenant_id_idx" ON "taxonomy_taxons"("tenant_id");
1194
+
1195
+ -- CreateIndex
1196
+ CREATE INDEX "taxonomy_taxons_tenant_id_category_id_idx" ON "taxonomy_taxons"("tenant_id", "category_id");
1197
+
1198
+ -- CreateIndex
1199
+ CREATE INDEX "taxonomy_taxons_tenant_id_taxonId_idx" ON "taxonomy_taxons"("tenant_id", "taxonId");
1200
+
1201
+ -- CreateIndex
1202
+ CREATE INDEX "taxonomy_taxons_tenant_id_is_active_idx" ON "taxonomy_taxons"("tenant_id", "is_active");
1203
+
1204
+ -- CreateIndex
1205
+ CREATE INDEX "taxonomy_taxons_parent_taxon_id_idx" ON "taxonomy_taxons"("parent_taxon_id");
1206
+
1207
+ -- CreateIndex
1208
+ CREATE UNIQUE INDEX "taxonomy_taxons_tenant_id_taxonId_key" ON "taxonomy_taxons"("tenant_id", "taxonId");
1209
+
1210
+ -- CreateIndex
1211
+ CREATE INDEX "post_taxonomy_tags_post_id_idx" ON "post_taxonomy_tags"("post_id");
1212
+
1213
+ -- CreateIndex
1214
+ CREATE INDEX "post_taxonomy_tags_taxon_id_idx" ON "post_taxonomy_tags"("taxon_id");
1215
+
1216
+ -- CreateIndex
1217
+ CREATE INDEX "post_taxonomy_tags_added_by_idx" ON "post_taxonomy_tags"("added_by");
1218
+
1219
+ -- CreateIndex
1220
+ CREATE UNIQUE INDEX "post_taxonomy_tags_post_id_taxon_id_key" ON "post_taxonomy_tags"("post_id", "taxon_id");
1221
+
1222
+ -- CreateIndex
1223
+ CREATE INDEX "entity_taxonomy_tags_entity_id_idx" ON "entity_taxonomy_tags"("entity_id");
1224
+
1225
+ -- CreateIndex
1226
+ CREATE INDEX "entity_taxonomy_tags_taxon_id_idx" ON "entity_taxonomy_tags"("taxon_id");
1227
+
1228
+ -- CreateIndex
1229
+ CREATE UNIQUE INDEX "entity_taxonomy_tags_entity_id_taxon_id_key" ON "entity_taxonomy_tags"("entity_id", "taxon_id");
1230
+
1231
+ -- CreateIndex
1232
+ CREATE INDEX "product_taxonomy_tags_product_id_idx" ON "product_taxonomy_tags"("product_id");
1233
+
1234
+ -- CreateIndex
1235
+ CREATE INDEX "product_taxonomy_tags_taxon_id_idx" ON "product_taxonomy_tags"("taxon_id");
1236
+
1237
+ -- CreateIndex
1238
+ CREATE UNIQUE INDEX "product_taxonomy_tags_product_id_taxon_id_key" ON "product_taxonomy_tags"("product_id", "taxon_id");
1239
+
1240
+ -- CreateIndex
1241
+ CREATE INDEX "entity_ownerships_entity_id_idx" ON "entity_ownerships"("entity_id");
1242
+
1243
+ -- CreateIndex
1244
+ CREATE INDEX "entity_ownerships_user_id_idx" ON "entity_ownerships"("user_id");
1245
+
1246
+ -- CreateIndex
1247
+ CREATE INDEX "entity_ownerships_entity_id_role_idx" ON "entity_ownerships"("entity_id", "role");
1248
+
1249
+ -- CreateIndex
1250
+ CREATE UNIQUE INDEX "entity_ownerships_entity_id_user_id_key" ON "entity_ownerships"("entity_id", "user_id");
1251
+
1252
+ -- CreateIndex
1253
+ CREATE UNIQUE INDEX "circle_configs_user_id_key" ON "circle_configs"("user_id");
1254
+
1255
+ -- CreateIndex
1256
+ CREATE INDEX "circle_read_states_user_id_idx" ON "circle_read_states"("user_id");
1257
+
1258
+ -- CreateIndex
1259
+ CREATE UNIQUE INDEX "circle_read_states_user_id_tier_key" ON "circle_read_states"("user_id", "tier");
1260
+
1261
+ -- CreateIndex
1262
+ CREATE UNIQUE INDEX "groups_actor_uri_key" ON "groups"("actor_uri");
1263
+
1264
+ -- CreateIndex
1265
+ CREATE INDEX "groups_actor_uri_idx" ON "groups"("actor_uri");
1266
+
1267
+ -- CreateIndex
1268
+ CREATE INDEX "groups_privacy_idx" ON "groups"("privacy");
1269
+
1270
+ -- CreateIndex
1271
+ CREATE INDEX "group_members_group_id_idx" ON "group_members"("group_id");
1272
+
1273
+ -- CreateIndex
1274
+ CREATE INDEX "group_members_actor_uri_idx" ON "group_members"("actor_uri");
1275
+
1276
+ -- CreateIndex
1277
+ CREATE INDEX "group_members_group_id_role_idx" ON "group_members"("group_id", "role");
1278
+
1279
+ -- CreateIndex
1280
+ CREATE UNIQUE INDEX "group_members_group_id_actor_uri_key" ON "group_members"("group_id", "actor_uri");
1281
+
1282
+ -- CreateIndex
1283
+ CREATE INDEX "activities_actor_uri_idx" ON "activities"("actor_uri");
1284
+
1285
+ -- CreateIndex
1286
+ CREATE INDEX "activities_inbox_actor_uri_received_at_idx" ON "activities"("inbox_actor_uri", "received_at");
1287
+
1288
+ -- CreateIndex
1289
+ CREATE INDEX "activities_outbox_actor_uri_published_idx" ON "activities"("outbox_actor_uri", "published");
1290
+
1291
+ -- CreateIndex
1292
+ CREATE INDEX "activities_published_idx" ON "activities"("published");
1293
+
1294
+ -- CreateIndex
1295
+ CREATE UNIQUE INDEX "direct_messages_object_id_key" ON "direct_messages"("object_id");
1296
+
1297
+ -- CreateIndex
1298
+ CREATE UNIQUE INDEX "direct_messages_activity_id_key" ON "direct_messages"("activity_id");
1299
+
1300
+ -- CreateIndex
1301
+ CREATE INDEX "direct_messages_sender_id_idx" ON "direct_messages"("sender_id");
1302
+
1303
+ -- CreateIndex
1304
+ CREATE INDEX "direct_messages_recipient_id_idx" ON "direct_messages"("recipient_id");
1305
+
1306
+ -- CreateIndex
1307
+ CREATE INDEX "direct_messages_recipient_id_read_idx" ON "direct_messages"("recipient_id", "read");
1308
+
1309
+ -- CreateIndex
1310
+ CREATE INDEX "direct_messages_encryption_key_id_idx" ON "direct_messages"("encryption_key_id");
1311
+
1312
+ -- CreateIndex
1313
+ CREATE UNIQUE INDEX "custom_audiences_collection_id_key" ON "custom_audiences"("collection_id");
1314
+
1315
+ -- CreateIndex
1316
+ CREATE INDEX "custom_audiences_creator_id_idx" ON "custom_audiences"("creator_id");
1317
+
1318
+ -- CreateIndex
1319
+ CREATE INDEX "custom_audience_members_audience_id_idx" ON "custom_audience_members"("audience_id");
1320
+
1321
+ -- CreateIndex
1322
+ CREATE INDEX "custom_audience_members_member_id_idx" ON "custom_audience_members"("member_id");
1323
+
1324
+ -- CreateIndex
1325
+ CREATE UNIQUE INDEX "custom_audience_members_audience_id_member_id_key" ON "custom_audience_members"("audience_id", "member_id");
1326
+
1327
+ -- CreateIndex
1328
+ CREATE UNIQUE INDEX "domain_reputations_domain_key" ON "domain_reputations"("domain");
1329
+
1330
+ -- CreateIndex
1331
+ CREATE INDEX "domain_reputations_domain_idx" ON "domain_reputations"("domain");
1332
+
1333
+ -- CreateIndex
1334
+ CREATE INDEX "domain_reputations_status_idx" ON "domain_reputations"("status");
1335
+
1336
+ -- CreateIndex
1337
+ CREATE INDEX "domain_reputations_reputation_idx" ON "domain_reputations"("reputation");
1338
+
1339
+ -- CreateIndex
1340
+ CREATE INDEX "link_checks_post_id_idx" ON "link_checks"("post_id");
1341
+
1342
+ -- CreateIndex
1343
+ CREATE INDEX "link_checks_comment_id_idx" ON "link_checks"("comment_id");
1344
+
1345
+ -- CreateIndex
1346
+ CREATE INDEX "link_checks_domain_idx" ON "link_checks"("domain");
1347
+
1348
+ -- CreateIndex
1349
+ CREATE INDEX "link_checks_status_idx" ON "link_checks"("status");
1350
+
1351
+ -- CreateIndex
1352
+ CREATE INDEX "link_reports_domain_idx" ON "link_reports"("domain");
1353
+
1354
+ -- CreateIndex
1355
+ CREATE INDEX "link_reports_status_idx" ON "link_reports"("status");
1356
+
1357
+ -- CreateIndex
1358
+ CREATE INDEX "link_reports_user_id_idx" ON "link_reports"("user_id");
1359
+
1360
+ -- CreateIndex
1361
+ CREATE UNIQUE INDEX "EmailSuppression_email_key" ON "EmailSuppression"("email");
1362
+
1363
+ -- CreateIndex
1364
+ CREATE INDEX "EmailSuppression_email_idx" ON "EmailSuppression"("email");
1365
+
1366
+ -- CreateIndex
1367
+ CREATE INDEX "deletion_audit_logs_user_id_idx" ON "deletion_audit_logs"("user_id");
1368
+
1369
+ -- CreateIndex
1370
+ CREATE INDEX "parental_links_guardian_id_idx" ON "parental_links"("guardian_id");
1371
+
1372
+ -- CreateIndex
1373
+ CREATE UNIQUE INDEX "parental_links_child_id_guardian_id_key" ON "parental_links"("child_id", "guardian_id");
1374
+
1375
+ -- CreateIndex
1376
+ CREATE INDEX "notifications_user_id_read_created_at_idx" ON "notifications"("user_id", "read", "created_at");
1377
+
1378
+ -- CreateIndex
1379
+ CREATE INDEX "notifications_user_id_batch_id_idx" ON "notifications"("user_id", "batch_id");
1380
+
1381
+ -- CreateIndex
1382
+ CREATE UNIQUE INDEX "notification_preferences_user_id_key" ON "notification_preferences"("user_id");
1383
+
1384
+ -- CreateIndex
1385
+ CREATE UNIQUE INDEX "connection_codes_code_key" ON "connection_codes"("code");
1386
+
1387
+ -- CreateIndex
1388
+ CREATE INDEX "connection_codes_creator_id_expires_at_idx" ON "connection_codes"("creator_id", "expires_at");
1389
+
1390
+ -- CreateIndex
1391
+ CREATE INDEX "connection_codes_entity_id_idx" ON "connection_codes"("entity_id");
1392
+
1393
+ -- CreateIndex
1394
+ CREATE INDEX "connection_code_redemptions_user_id_idx" ON "connection_code_redemptions"("user_id");
1395
+
1396
+ -- CreateIndex
1397
+ CREATE UNIQUE INDEX "connection_code_redemptions_code_id_user_id_key" ON "connection_code_redemptions"("code_id", "user_id");
1398
+
1399
+ -- AddForeignKey
1400
+ ALTER TABLE "users" ADD CONSTRAINT "users_partnerId_fkey" FOREIGN KEY ("partnerId") REFERENCES "partners"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1401
+
1402
+ -- AddForeignKey
1403
+ ALTER TABLE "mfa_enrollments" ADD CONSTRAINT "mfa_enrollments_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1404
+
1405
+ -- AddForeignKey
1406
+ ALTER TABLE "user_encryption_keys" ADD CONSTRAINT "user_encryption_keys_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1407
+
1408
+ -- AddForeignKey
1409
+ ALTER TABLE "cross_region_consent" ADD CONSTRAINT "cross_region_consent_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1410
+
1411
+ -- AddForeignKey
1412
+ ALTER TABLE "posts" ADD CONSTRAINT "posts_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1413
+
1414
+ -- AddForeignKey
1415
+ ALTER TABLE "posts" ADD CONSTRAINT "posts_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "groups"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1416
+
1417
+ -- AddForeignKey
1418
+ ALTER TABLE "posts" ADD CONSTRAINT "posts_primary_entity_id_fkey" FOREIGN KEY ("primary_entity_id") REFERENCES "entities"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1419
+
1420
+ -- AddForeignKey
1421
+ ALTER TABLE "post_media" ADD CONSTRAINT "post_media_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1422
+
1423
+ -- AddForeignKey
1424
+ ALTER TABLE "post_media" ADD CONSTRAINT "post_media_media_id_fkey" FOREIGN KEY ("media_id") REFERENCES "media_files"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1425
+
1426
+ -- AddForeignKey
1427
+ ALTER TABLE "post_sentiments" ADD CONSTRAINT "post_sentiments_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1428
+
1429
+ -- AddForeignKey
1430
+ ALTER TABLE "post_comments" ADD CONSTRAINT "post_comments_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1431
+
1432
+ -- AddForeignKey
1433
+ ALTER TABLE "post_comment_media" ADD CONSTRAINT "post_comment_media_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "post_comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1434
+
1435
+ -- AddForeignKey
1436
+ ALTER TABLE "comment_sentiments" ADD CONSTRAINT "comment_sentiments_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "post_comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1437
+
1438
+ -- AddForeignKey
1439
+ ALTER TABLE "post_subjects" ADD CONSTRAINT "post_subjects_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1440
+
1441
+ -- AddForeignKey
1442
+ ALTER TABLE "post_subjects" ADD CONSTRAINT "post_subjects_entity_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "entities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1443
+
1444
+ -- AddForeignKey
1445
+ ALTER TABLE "security_events" ADD CONSTRAINT "security_events_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1446
+
1447
+ -- AddForeignKey
1448
+ ALTER TABLE "security_events" ADD CONSTRAINT "security_events_partnerId_fkey" FOREIGN KEY ("partnerId") REFERENCES "partners"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1449
+
1450
+ -- AddForeignKey
1451
+ ALTER TABLE "invitations" ADD CONSTRAINT "invitations_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1452
+
1453
+ -- AddForeignKey
1454
+ ALTER TABLE "invitations" ADD CONSTRAINT "invitations_used_by_fkey" FOREIGN KEY ("used_by") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1455
+
1456
+ -- AddForeignKey
1457
+ ALTER TABLE "taxonomy_categories" ADD CONSTRAINT "taxonomy_categories_dimension_id_fkey" FOREIGN KEY ("dimension_id") REFERENCES "taxonomy_dimensions"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1458
+
1459
+ -- AddForeignKey
1460
+ ALTER TABLE "taxonomy_taxons" ADD CONSTRAINT "taxonomy_taxons_parent_taxon_id_fkey" FOREIGN KEY ("parent_taxon_id") REFERENCES "taxonomy_taxons"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1461
+
1462
+ -- AddForeignKey
1463
+ ALTER TABLE "taxonomy_taxons" ADD CONSTRAINT "taxonomy_taxons_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "taxonomy_categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1464
+
1465
+ -- AddForeignKey
1466
+ ALTER TABLE "post_taxonomy_tags" ADD CONSTRAINT "post_taxonomy_tags_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1467
+
1468
+ -- AddForeignKey
1469
+ ALTER TABLE "post_taxonomy_tags" ADD CONSTRAINT "post_taxonomy_tags_taxon_id_fkey" FOREIGN KEY ("taxon_id") REFERENCES "taxonomy_taxons"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1470
+
1471
+ -- AddForeignKey
1472
+ ALTER TABLE "entity_taxonomy_tags" ADD CONSTRAINT "entity_taxonomy_tags_entity_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "entities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1473
+
1474
+ -- AddForeignKey
1475
+ ALTER TABLE "entity_taxonomy_tags" ADD CONSTRAINT "entity_taxonomy_tags_taxon_id_fkey" FOREIGN KEY ("taxon_id") REFERENCES "taxonomy_taxons"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1476
+
1477
+ -- AddForeignKey
1478
+ ALTER TABLE "product_taxonomy_tags" ADD CONSTRAINT "product_taxonomy_tags_taxon_id_fkey" FOREIGN KEY ("taxon_id") REFERENCES "taxonomy_taxons"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1479
+
1480
+ -- AddForeignKey
1481
+ ALTER TABLE "entity_ownerships" ADD CONSTRAINT "entity_ownerships_entity_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "entities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1482
+
1483
+ -- AddForeignKey
1484
+ ALTER TABLE "entity_ownerships" ADD CONSTRAINT "entity_ownerships_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1485
+
1486
+ -- AddForeignKey
1487
+ ALTER TABLE "entity_ownerships" ADD CONSTRAINT "entity_ownerships_added_by_user_id_fkey" FOREIGN KEY ("added_by_user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1488
+
1489
+ -- AddForeignKey
1490
+ ALTER TABLE "circle_configs" ADD CONSTRAINT "circle_configs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1491
+
1492
+ -- AddForeignKey
1493
+ ALTER TABLE "circle_read_states" ADD CONSTRAINT "circle_read_states_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1494
+
1495
+ -- AddForeignKey
1496
+ ALTER TABLE "group_members" ADD CONSTRAINT "group_members_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "groups"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1497
+
1498
+ -- AddForeignKey
1499
+ ALTER TABLE "direct_messages" ADD CONSTRAINT "direct_messages_sender_id_fkey" FOREIGN KEY ("sender_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1500
+
1501
+ -- AddForeignKey
1502
+ ALTER TABLE "direct_messages" ADD CONSTRAINT "direct_messages_recipient_id_fkey" FOREIGN KEY ("recipient_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1503
+
1504
+ -- AddForeignKey
1505
+ ALTER TABLE "custom_audiences" ADD CONSTRAINT "custom_audiences_creator_id_fkey" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1506
+
1507
+ -- AddForeignKey
1508
+ ALTER TABLE "custom_audience_members" ADD CONSTRAINT "custom_audience_members_audience_id_fkey" FOREIGN KEY ("audience_id") REFERENCES "custom_audiences"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1509
+
1510
+ -- AddForeignKey
1511
+ ALTER TABLE "custom_audience_members" ADD CONSTRAINT "custom_audience_members_member_id_fkey" FOREIGN KEY ("member_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1512
+
1513
+ -- AddForeignKey
1514
+ ALTER TABLE "link_checks" ADD CONSTRAINT "link_checks_post_id_fkey" FOREIGN KEY ("post_id") REFERENCES "posts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1515
+
1516
+ -- AddForeignKey
1517
+ ALTER TABLE "link_checks" ADD CONSTRAINT "link_checks_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "post_comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1518
+
1519
+ -- AddForeignKey
1520
+ ALTER TABLE "link_checks" ADD CONSTRAINT "link_checks_domain_fkey" FOREIGN KEY ("domain") REFERENCES "domain_reputations"("domain") ON DELETE RESTRICT ON UPDATE CASCADE;
1521
+
1522
+ -- AddForeignKey
1523
+ ALTER TABLE "link_reports" ADD CONSTRAINT "link_reports_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
1524
+
1525
+ -- AddForeignKey
1526
+ ALTER TABLE "parental_links" ADD CONSTRAINT "parental_links_child_id_fkey" FOREIGN KEY ("child_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1527
+
1528
+ -- AddForeignKey
1529
+ ALTER TABLE "parental_links" ADD CONSTRAINT "parental_links_guardian_id_fkey" FOREIGN KEY ("guardian_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1530
+
1531
+ -- AddForeignKey
1532
+ ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1533
+
1534
+ -- AddForeignKey
1535
+ ALTER TABLE "notification_preferences" ADD CONSTRAINT "notification_preferences_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1536
+
1537
+ -- AddForeignKey
1538
+ ALTER TABLE "connection_codes" ADD CONSTRAINT "connection_codes_creator_id_fkey" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1539
+
1540
+ -- AddForeignKey
1541
+ ALTER TABLE "connection_codes" ADD CONSTRAINT "connection_codes_entity_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "entities"("id") ON DELETE SET NULL ON UPDATE CASCADE;
1542
+
1543
+ -- AddForeignKey
1544
+ ALTER TABLE "connection_code_redemptions" ADD CONSTRAINT "connection_code_redemptions_code_id_fkey" FOREIGN KEY ("code_id") REFERENCES "connection_codes"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
1545
+
1546
+ -- AddForeignKey
1547
+ ALTER TABLE "connection_code_redemptions" ADD CONSTRAINT "connection_code_redemptions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;