@meith/db 0.16.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 (205) hide show
  1. package/LICENSE.md +165 -0
  2. package/migrations/0000_initial_schema.sql +538 -0
  3. package/migrations/0001_seed_usergroups.sql +111 -0
  4. package/migrations/0002_group_promotions.sql +25 -0
  5. package/migrations/0003_counter_maintenance.sql +34 -0
  6. package/migrations/0004_post_render_cache.sql +7 -0
  7. package/migrations/0005_reports.sql +51 -0
  8. package/migrations/0006_warnings.sql +91 -0
  9. package/migrations/0007_notifications.sql +44 -0
  10. package/migrations/0008_subscriptions.sql +48 -0
  11. package/migrations/0009_member_preferences.sql +13 -0
  12. package/migrations/0010_profile_fields.sql +53 -0
  13. package/migrations/0011_private_messages.sql +63 -0
  14. package/migrations/0012_user_relations.sql +18 -0
  15. package/migrations/0013_reputation.sql +45 -0
  16. package/migrations/0014_signatures.sql +16 -0
  17. package/migrations/0015_admin_sessions.sql +24 -0
  18. package/migrations/0016_attachments.sql +51 -0
  19. package/migrations/0017_avatars.sql +33 -0
  20. package/migrations/0018_mass_mail.sql +15 -0
  21. package/migrations/0019_word_filters.sql +8 -0
  22. package/migrations/0020_searches.sql +15 -0
  23. package/migrations/0021_presence_stats.sql +18 -0
  24. package/migrations/0022_api_tokens_webhooks.sql +58 -0
  25. package/migrations/0023_install_state.sql +6 -0
  26. package/migrations/0024_component_versions.sql +13 -0
  27. package/migrations/0025_import.sql +25 -0
  28. package/migrations/0026_polls.sql +40 -0
  29. package/migrations/0027_drafts.sql +13 -0
  30. package/migrations/0028_board_vocabulary.sql +32 -0
  31. package/migrations/0029_announcements.sql +16 -0
  32. package/migrations/0030_antispam.sql +18 -0
  33. package/migrations/0031_markdown.sql +24 -0
  34. package/migrations/0032_theme_enablement.sql +1 -0
  35. package/migrations/0033_group_identity.sql +5 -0
  36. package/migrations/0034_search_document_version.sql +4 -0
  37. package/migrations/0035_categories_hold_no_threads.sql +1 -0
  38. package/migrations/0036_expiring_group_grants.sql +6 -0
  39. package/migrations/0037_automatic_timezone.sql +3 -0
  40. package/migrations/0038_primary_group_grants.sql +3 -0
  41. package/migrations/0039_moderator_log_forum_scope.sql +1 -0
  42. package/migrations/0040_moderator_restore_grants.sql +1 -0
  43. package/migrations/0041_drop_placebo_moderator_rights.sql +3 -0
  44. package/migrations/0042_drop_placebo_delete_others.sql +2 -0
  45. package/migrations/0043_federated_identity.sql +28 -0
  46. package/migrations/0044_second_factor.sql +34 -0
  47. package/migrations/0045_drop_dead_task_due_index.sql +1 -0
  48. package/migrations/0046_member_locale.sql +1 -0
  49. package/migrations/0047_navigation_items.sql +34 -0
  50. package/migrations/0048_web_push.sql +16 -0
  51. package/migrations/0049_plugin_health.sql +7 -0
  52. package/migrations/0050_drop_forum_password_grants.sql +1 -0
  53. package/migrations/0051_glossy_barracuda.sql +1 -0
  54. package/migrations/0052_many_professor_monster.sql +2 -0
  55. package/migrations/0053_strange_maximus.sql +14 -0
  56. package/migrations/0054_legacy_import_sources.sql +25 -0
  57. package/migrations/0055_poll_parity.sql +14 -0
  58. package/migrations/0056_marketplace_catalog.sql +11 -0
  59. package/migrations/meta/0000_snapshot.json +4412 -0
  60. package/migrations/meta/0006_snapshot.json +5411 -0
  61. package/migrations/meta/0007_snapshot.json +5634 -0
  62. package/migrations/meta/0008_snapshot.json +5779 -0
  63. package/migrations/meta/0009_snapshot.json +5816 -0
  64. package/migrations/meta/0010_snapshot.json +6117 -0
  65. package/migrations/meta/0011_snapshot.json +6406 -0
  66. package/migrations/meta/0012_snapshot.json +6517 -0
  67. package/migrations/meta/0013_snapshot.json +6722 -0
  68. package/migrations/meta/0014_snapshot.json +6777 -0
  69. package/migrations/meta/0015_snapshot.json +6914 -0
  70. package/migrations/meta/0016_snapshot.json +7192 -0
  71. package/migrations/meta/0017_snapshot.json +7248 -0
  72. package/migrations/meta/0018_snapshot.json +7355 -0
  73. package/migrations/meta/0019_snapshot.json +7419 -0
  74. package/migrations/meta/0020_snapshot.json +7562 -0
  75. package/migrations/meta/0021_snapshot.json +7653 -0
  76. package/migrations/meta/0031_snapshot.json +8162 -0
  77. package/migrations/meta/0032_snapshot.json +8169 -0
  78. package/migrations/meta/0033_snapshot.json +8193 -0
  79. package/migrations/meta/0034_snapshot.json +8221 -0
  80. package/migrations/meta/0036_snapshot.json +8262 -0
  81. package/migrations/meta/0037_snapshot.json +8262 -0
  82. package/migrations/meta/0038_snapshot.json +8293 -0
  83. package/migrations/meta/0039_snapshot.json +8308 -0
  84. package/migrations/meta/0041_snapshot.json +8287 -0
  85. package/migrations/meta/0042_snapshot.json +8274 -0
  86. package/migrations/meta/0043_snapshot.json +8521 -0
  87. package/migrations/meta/0044_snapshot.json +8814 -0
  88. package/migrations/meta/0045_snapshot.json +8797 -0
  89. package/migrations/meta/0046_snapshot.json +8804 -0
  90. package/migrations/meta/0047_snapshot.json +9018 -0
  91. package/migrations/meta/0048_snapshot.json +9145 -0
  92. package/migrations/meta/0049_snapshot.json +9190 -0
  93. package/migrations/meta/0050_snapshot.json +9126 -0
  94. package/migrations/meta/0051_snapshot.json +9132 -0
  95. package/migrations/meta/0052_snapshot.json +9148 -0
  96. package/migrations/meta/0053_snapshot.json +9268 -0
  97. package/migrations/meta/0054_snapshot.json +9378 -0
  98. package/migrations/meta/0056_snapshot.json +9447 -0
  99. package/migrations/meta/_journal.json +405 -0
  100. package/package.json +64 -0
  101. package/src/account-repos.ts +580 -0
  102. package/src/actor-builder.ts +130 -0
  103. package/src/admin-repo.ts +85 -0
  104. package/src/admin-session-repo.ts +205 -0
  105. package/src/admin-undo-repo.ts +128 -0
  106. package/src/announcement-repo.ts +176 -0
  107. package/src/antispam-repo.ts +145 -0
  108. package/src/api-repo.ts +276 -0
  109. package/src/attachment-admin-repo.ts +161 -0
  110. package/src/attachment-repo.ts +240 -0
  111. package/src/authorization-source.ts +138 -0
  112. package/src/avatar-repo.ts +185 -0
  113. package/src/ban-repos.ts +146 -0
  114. package/src/client.ts +85 -0
  115. package/src/content-admin-repo.ts +298 -0
  116. package/src/content-counters.ts +152 -0
  117. package/src/counter-recount.ts +263 -0
  118. package/src/cursor.ts +16 -0
  119. package/src/denormalised-username.ts +34 -0
  120. package/src/discovery-repo.ts +140 -0
  121. package/src/draft-repo.ts +59 -0
  122. package/src/feed-repo.ts +219 -0
  123. package/src/forum-admin-repo.ts +310 -0
  124. package/src/forum-repo.ts +206 -0
  125. package/src/group-admin-repo.ts +256 -0
  126. package/src/group-identity-repo.ts +84 -0
  127. package/src/identity-link-repo.ts +145 -0
  128. package/src/import-repo.ts +123 -0
  129. package/src/import-sink.ts +1377 -0
  130. package/src/index.ts +316 -0
  131. package/src/inline-moderation.ts +344 -0
  132. package/src/install-repo.ts +67 -0
  133. package/src/latest-repo.ts +115 -0
  134. package/src/maintenance-repo.ts +54 -0
  135. package/src/marketplace-repo.ts +111 -0
  136. package/src/member-profile-repo.ts +82 -0
  137. package/src/member-settings-repo.ts +160 -0
  138. package/src/message-repo.ts +384 -0
  139. package/src/migrate-run.ts +18 -0
  140. package/src/migrate.ts +129 -0
  141. package/src/modcp-repo.ts +253 -0
  142. package/src/moderation-queue.ts +279 -0
  143. package/src/navigation-repo.ts +288 -0
  144. package/src/notification-repo.ts +402 -0
  145. package/src/orphan-keys.ts +19 -0
  146. package/src/outbox-repo.ts +78 -0
  147. package/src/permission-version.ts +24 -0
  148. package/src/permissions-map.ts +52 -0
  149. package/src/pglite.fixture.ts +87 -0
  150. package/src/plugin-data.ts +88 -0
  151. package/src/plugin-grants.ts +369 -0
  152. package/src/plugin-health-repo.ts +80 -0
  153. package/src/plugin-purge-repo.ts +91 -0
  154. package/src/plugin-users.ts +39 -0
  155. package/src/poll-repo.ts +334 -0
  156. package/src/post-repo.ts +261 -0
  157. package/src/post-writes.ts +227 -0
  158. package/src/presence-repo.ts +220 -0
  159. package/src/profile-field-repo.ts +182 -0
  160. package/src/promotion-repo.ts +152 -0
  161. package/src/read-state-repo.ts +81 -0
  162. package/src/relation-repo.ts +113 -0
  163. package/src/render-backfill.ts +110 -0
  164. package/src/render-signature.ts +33 -0
  165. package/src/report-repo.ts +349 -0
  166. package/src/reputation-repo.ts +295 -0
  167. package/src/result-rows.ts +13 -0
  168. package/src/row-values.ts +7 -0
  169. package/src/schema/content.ts +451 -0
  170. package/src/schema/identity.ts +699 -0
  171. package/src/schema/index.ts +10 -0
  172. package/src/schema/messages.ts +76 -0
  173. package/src/schema/permission-columns.ts +34 -0
  174. package/src/schema/platform.ts +376 -0
  175. package/src/schema/structure.ts +164 -0
  176. package/src/search-repo.ts +359 -0
  177. package/src/search-store.ts +113 -0
  178. package/src/seed-groups.ts +11 -0
  179. package/src/settings-repo.ts +32 -0
  180. package/src/signature-repo.ts +102 -0
  181. package/src/sql-lists.ts +17 -0
  182. package/src/staff-groups.ts +50 -0
  183. package/src/stats-repo.ts +151 -0
  184. package/src/subscription-repo.ts +350 -0
  185. package/src/system-health-repo.ts +130 -0
  186. package/src/task-repo.ts +104 -0
  187. package/src/theme-admin-repo.ts +172 -0
  188. package/src/theme-repo.ts +43 -0
  189. package/src/thread-audience.ts +45 -0
  190. package/src/thread-counters.ts +107 -0
  191. package/src/thread-repo.ts +255 -0
  192. package/src/thread-surgery.ts +282 -0
  193. package/src/thread-tools.ts +311 -0
  194. package/src/thread-views.ts +41 -0
  195. package/src/thread-writes.ts +356 -0
  196. package/src/two-factor-repo.ts +235 -0
  197. package/src/upgrade-repo.ts +66 -0
  198. package/src/user-admin-repo.ts +367 -0
  199. package/src/user-bulk-repo.ts +397 -0
  200. package/src/user-merge-map.ts +111 -0
  201. package/src/user-merge-repo.ts +304 -0
  202. package/src/visibility-counters.ts +190 -0
  203. package/src/visibility.ts +17 -0
  204. package/src/vocabulary-repo.ts +54 -0
  205. package/src/warning-repo.ts +328 -0
@@ -0,0 +1,51 @@
1
+ CREATE TABLE "attachments" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
3
+
4
+ "post_id" integer NOT NULL REFERENCES "posts"("id") ON DELETE cascade,
5
+ "forum_id" integer NOT NULL REFERENCES "forums"("id") ON DELETE cascade,
6
+ "uploader_user_id" integer REFERENCES "users"("id") ON DELETE set null,
7
+
8
+ "filename" text NOT NULL,
9
+ "content_type" text NOT NULL,
10
+ "size_bytes" integer NOT NULL,
11
+
12
+ "storage_key" text,
13
+ "source_key" text,
14
+ "thumbnail_key" text,
15
+
16
+ "width" integer,
17
+ "height" integer,
18
+
19
+ "status" text NOT NULL DEFAULT 'pending',
20
+ "failure_reason" text,
21
+
22
+ "download_count" integer NOT NULL DEFAULT 0,
23
+ "created_at" timestamp with time zone NOT NULL DEFAULT now(),
24
+ "ready_at" timestamp with time zone
25
+ );
26
+ --> statement-breakpoint
27
+
28
+ CREATE INDEX "attachments_post_idx" ON "attachments" ("post_id");
29
+ --> statement-breakpoint
30
+
31
+ CREATE INDEX "attachments_uploader_idx" ON "attachments" ("uploader_user_id");
32
+ --> statement-breakpoint
33
+
34
+ CREATE INDEX "attachments_pending_idx" ON "attachments" ("created_at")
35
+ WHERE "status" = 'pending';
36
+ --> statement-breakpoint
37
+
38
+ CREATE UNIQUE INDEX "attachments_storage_key_key" ON "attachments" ("storage_key")
39
+ WHERE "storage_key" IS NOT NULL;
40
+ --> statement-breakpoint
41
+ CREATE UNIQUE INDEX "attachments_source_key_key" ON "attachments" ("source_key")
42
+ WHERE "source_key" IS NOT NULL;
43
+ --> statement-breakpoint
44
+
45
+ CREATE TABLE "attachment_orphans" (
46
+ "storage_key" text PRIMARY KEY,
47
+ "created_at" timestamp with time zone NOT NULL DEFAULT now()
48
+ );
49
+ --> statement-breakpoint
50
+
51
+ CREATE INDEX "attachment_orphans_age_idx" ON "attachment_orphans" ("created_at");
@@ -0,0 +1,33 @@
1
+ ALTER TABLE "users" ADD COLUMN "avatar_status" text NOT NULL DEFAULT 'none';
2
+ --> statement-breakpoint
3
+
4
+ ALTER TABLE "users" ADD COLUMN "avatar_key" text;
5
+ --> statement-breakpoint
6
+ ALTER TABLE "users" ADD COLUMN "avatar_source_key" text;
7
+ --> statement-breakpoint
8
+
9
+ ALTER TABLE "users" ADD COLUMN "avatar_width" integer;
10
+ --> statement-breakpoint
11
+ ALTER TABLE "users" ADD COLUMN "avatar_height" integer;
12
+ --> statement-breakpoint
13
+
14
+ ALTER TABLE "users" ADD COLUMN "avatar_failure_reason" text;
15
+ --> statement-breakpoint
16
+
17
+ ALTER TABLE "users" ADD COLUMN "avatar_updated_at" timestamp with time zone;
18
+ --> statement-breakpoint
19
+
20
+ ALTER TABLE "users" ADD COLUMN "avatar_locked" boolean NOT NULL DEFAULT false;
21
+ --> statement-breakpoint
22
+ ALTER TABLE "users" ADD COLUMN "avatar_locked_reason" text;
23
+ --> statement-breakpoint
24
+
25
+ CREATE UNIQUE INDEX "users_avatar_key_key" ON "users" ("avatar_key")
26
+ WHERE "avatar_key" IS NOT NULL;
27
+ --> statement-breakpoint
28
+ CREATE UNIQUE INDEX "users_avatar_source_key_key" ON "users" ("avatar_source_key")
29
+ WHERE "avatar_source_key" IS NOT NULL;
30
+ --> statement-breakpoint
31
+
32
+ CREATE INDEX "users_avatar_pending_idx" ON "users" ("avatar_updated_at")
33
+ WHERE "avatar_status" = 'pending';
@@ -0,0 +1,15 @@
1
+ CREATE TABLE "mass_mails" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "mass_mails_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "subject" text NOT NULL,
4
+ "body" text NOT NULL,
5
+ "target_group_id" integer,
6
+ "last_user_id" integer DEFAULT 0 NOT NULL,
7
+ "queued_count" integer DEFAULT 0 NOT NULL,
8
+ "status" text DEFAULT 'sending' NOT NULL,
9
+ "created_by_user_id" integer,
10
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
11
+ "finished_at" timestamp with time zone
12
+ );
13
+ --> statement-breakpoint
14
+ ALTER TABLE "mass_mails" ADD CONSTRAINT "mass_mails_target_group_id_usergroups_id_fk" FOREIGN KEY ("target_group_id") REFERENCES "public"."usergroups"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
15
+ ALTER TABLE "mass_mails" ADD CONSTRAINT "mass_mails_created_by_user_id_users_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
@@ -0,0 +1,8 @@
1
+ CREATE TABLE "word_filters" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "word_filters_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "pattern" text NOT NULL,
4
+ "replacement" text DEFAULT '' NOT NULL,
5
+ "whole_word" boolean DEFAULT true NOT NULL,
6
+ "enabled" boolean DEFAULT true NOT NULL,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
8
+ );
@@ -0,0 +1,15 @@
1
+ CREATE TABLE "searches" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "searches_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "token" text NOT NULL,
4
+ "user_id" integer,
5
+ "session_key" text,
6
+ "terms" text NOT NULL,
7
+ "filters" jsonb DEFAULT '{}'::jsonb NOT NULL,
8
+ "hit_count" integer DEFAULT 0 NOT NULL,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "searches" ADD CONSTRAINT "searches_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
13
+ CREATE UNIQUE INDEX "searches_token_key" ON "searches" USING btree ("token");--> statement-breakpoint
14
+ CREATE INDEX "searches_user_recent_idx" ON "searches" USING btree ("user_id","created_at");--> statement-breakpoint
15
+ CREATE INDEX "searches_session_recent_idx" ON "searches" USING btree ("session_key","created_at");
@@ -0,0 +1,18 @@
1
+ CREATE TABLE "board_stats" (
2
+ "id" smallint PRIMARY KEY DEFAULT 1 NOT NULL,
3
+ "thread_count" integer DEFAULT 0 NOT NULL,
4
+ "post_count" integer DEFAULT 0 NOT NULL,
5
+ "member_count" integer DEFAULT 0 NOT NULL,
6
+ "newest_user_id" integer,
7
+ "newest_username" text,
8
+ "most_online_count" integer DEFAULT 0 NOT NULL,
9
+ "most_online_at" timestamp with time zone,
10
+ "computed_at" timestamp with time zone,
11
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
12
+ CONSTRAINT "board_stats_singleton" CHECK ("board_stats"."id" = 1)
13
+ );
14
+ --> statement-breakpoint
15
+ ALTER TABLE "users" ADD COLUMN "invisible" boolean DEFAULT false NOT NULL;
16
+
17
+ --> statement-breakpoint
18
+ INSERT INTO "board_stats" ("id") VALUES (1) ON CONFLICT ("id") DO NOTHING;
@@ -0,0 +1,58 @@
1
+ CREATE TABLE "api_tokens" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
3
+ "user_id" integer NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
4
+ "name" text NOT NULL,
5
+ "lookup" text NOT NULL,
6
+ "secret_hash" text NOT NULL,
7
+ "scopes" jsonb DEFAULT '[]'::jsonb NOT NULL,
8
+ "expires_at" timestamp with time zone,
9
+ "revoked_at" timestamp with time zone,
10
+ "last_used_at" timestamp with time zone,
11
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE UNIQUE INDEX "api_tokens_lookup_idx" ON "api_tokens" ("lookup");
15
+ --> statement-breakpoint
16
+ CREATE INDEX "api_tokens_user_idx" ON "api_tokens" ("user_id");
17
+ --> statement-breakpoint
18
+
19
+ CREATE TABLE "api_rate_limits" (
20
+ "token_id" integer NOT NULL REFERENCES "api_tokens"("id") ON DELETE CASCADE,
21
+ "window_start" timestamp with time zone NOT NULL,
22
+ "used" integer DEFAULT 0 NOT NULL,
23
+ PRIMARY KEY ("token_id", "window_start")
24
+ );
25
+ --> statement-breakpoint
26
+ CREATE INDEX "api_rate_limits_window_idx" ON "api_rate_limits" ("window_start");
27
+ --> statement-breakpoint
28
+
29
+ CREATE TABLE "webhooks" (
30
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
31
+ "url" text NOT NULL,
32
+ "secret" text NOT NULL,
33
+ "topics" jsonb DEFAULT '[]'::jsonb NOT NULL,
34
+ "active" boolean DEFAULT true NOT NULL,
35
+ "created_by" integer REFERENCES "users"("id") ON DELETE SET NULL,
36
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
37
+ );
38
+ --> statement-breakpoint
39
+
40
+ CREATE TABLE "webhook_deliveries" (
41
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
42
+ "webhook_id" integer NOT NULL REFERENCES "webhooks"("id") ON DELETE CASCADE,
43
+ "delivery_id" text NOT NULL,
44
+ "topic" text NOT NULL,
45
+ "payload" jsonb NOT NULL,
46
+ "status" text DEFAULT 'pending' NOT NULL,
47
+ "attempts" smallint DEFAULT 0 NOT NULL,
48
+ "next_attempt_at" timestamp with time zone DEFAULT now() NOT NULL,
49
+ "last_status_code" smallint,
50
+ "last_error" text,
51
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
52
+ "completed_at" timestamp with time zone
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE UNIQUE INDEX "webhook_deliveries_delivery_idx" ON "webhook_deliveries" ("webhook_id", "delivery_id");
56
+ --> statement-breakpoint
57
+ CREATE INDEX "webhook_deliveries_due_idx" ON "webhook_deliveries" ("next_attempt_at")
58
+ WHERE "status" = 'pending';
@@ -0,0 +1,6 @@
1
+ CREATE TABLE "install_state" (
2
+ "id" smallint PRIMARY KEY DEFAULT 1 NOT NULL,
3
+ "completed_at" timestamp with time zone DEFAULT now() NOT NULL,
4
+ "installed_version" text NOT NULL,
5
+ CONSTRAINT "install_state_single_row" CHECK ("id" = 1)
6
+ );
@@ -0,0 +1,13 @@
1
+ CREATE TABLE "component_versions" (
2
+ "component" text PRIMARY KEY,
3
+ "version" text NOT NULL,
4
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
5
+ );
6
+ --> statement-breakpoint
7
+
8
+ CREATE TABLE "plugin_migrations" (
9
+ "plugin_key" text NOT NULL,
10
+ "migration_id" text NOT NULL,
11
+ "applied_at" timestamp with time zone DEFAULT now() NOT NULL,
12
+ PRIMARY KEY ("plugin_key", "migration_id")
13
+ );
@@ -0,0 +1,25 @@
1
+ CREATE TABLE "legacy_ids" (
2
+ "kind" text NOT NULL,
3
+ "legacy_id" integer NOT NULL,
4
+ "new_id" integer NOT NULL,
5
+ "imported_at" timestamp with time zone DEFAULT now() NOT NULL,
6
+ PRIMARY KEY ("kind", "legacy_id")
7
+ );
8
+ --> statement-breakpoint
9
+ CREATE INDEX "legacy_ids_new_idx" ON "legacy_ids" ("kind", "new_id");
10
+ --> statement-breakpoint
11
+
12
+ CREATE TABLE "import_runs" (
13
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
14
+ "source" text DEFAULT 'mybb' NOT NULL,
15
+ "cursors" jsonb DEFAULT '{}'::jsonb NOT NULL,
16
+ "status" text DEFAULT 'running' NOT NULL,
17
+ "rows_read" integer DEFAULT 0 NOT NULL,
18
+ "report" jsonb DEFAULT '{}'::jsonb NOT NULL,
19
+ "last_error" text,
20
+ "started_at" timestamp with time zone DEFAULT now() NOT NULL,
21
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
22
+ );
23
+ --> statement-breakpoint
24
+ CREATE UNIQUE INDEX "import_runs_one_running_idx" ON "import_runs" ("source")
25
+ WHERE "status" = 'running';
@@ -0,0 +1,40 @@
1
+ ALTER TABLE "threads" ADD COLUMN "rating_total" integer NOT NULL DEFAULT 0;
2
+ --> statement-breakpoint
3
+ ALTER TABLE "threads" ADD COLUMN "rating_count" integer NOT NULL DEFAULT 0;
4
+ --> statement-breakpoint
5
+
6
+ CREATE TABLE "polls" (
7
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
8
+ "thread_id" integer NOT NULL UNIQUE REFERENCES "threads"("id") ON DELETE CASCADE,
9
+ "question" text NOT NULL,
10
+ "closes_at" timestamp with time zone,
11
+ "created_at" timestamp with time zone NOT NULL DEFAULT now()
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE TABLE "poll_options" (
15
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
16
+ "poll_id" integer NOT NULL REFERENCES "polls"("id") ON DELETE CASCADE,
17
+ "label" text NOT NULL,
18
+ "display_order" integer NOT NULL,
19
+ "vote_count" integer NOT NULL DEFAULT 0,
20
+ UNIQUE ("poll_id", "id")
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE INDEX "poll_options_poll_order_idx" ON "poll_options" ("poll_id", "display_order", "id");
24
+ --> statement-breakpoint
25
+ CREATE TABLE "poll_votes" (
26
+ "poll_id" integer NOT NULL REFERENCES "polls"("id") ON DELETE CASCADE,
27
+ "user_id" integer NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
28
+ "option_id" integer NOT NULL,
29
+ "created_at" timestamp with time zone NOT NULL DEFAULT now(),
30
+ PRIMARY KEY ("poll_id", "user_id"),
31
+ FOREIGN KEY ("poll_id", "option_id") REFERENCES "poll_options"("poll_id", "id") ON DELETE CASCADE
32
+ );
33
+ --> statement-breakpoint
34
+ CREATE TABLE "thread_ratings" (
35
+ "thread_id" integer NOT NULL REFERENCES "threads"("id") ON DELETE CASCADE,
36
+ "user_id" integer NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
37
+ "rating" smallint NOT NULL CHECK ("rating" BETWEEN 1 AND 5),
38
+ "updated_at" timestamp with time zone NOT NULL DEFAULT now(),
39
+ PRIMARY KEY ("thread_id", "user_id")
40
+ );
@@ -0,0 +1,13 @@
1
+ CREATE TABLE "post_drafts" (
2
+ "user_id" integer NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
3
+ "forum_id" integer NOT NULL REFERENCES "forums"("id") ON DELETE CASCADE,
4
+ "thread_id" integer REFERENCES "threads"("id") ON DELETE CASCADE,
5
+ "title" text NOT NULL DEFAULT '',
6
+ "message" text NOT NULL DEFAULT '',
7
+ "prefix_id" integer REFERENCES "thread_prefixes"("id") ON DELETE SET NULL,
8
+ "updated_at" timestamp with time zone NOT NULL DEFAULT now()
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE UNIQUE INDEX "post_drafts_new_thread_key" ON "post_drafts" ("user_id", "forum_id") WHERE "thread_id" IS NULL;
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX "post_drafts_reply_key" ON "post_drafts" ("user_id", "thread_id") WHERE "thread_id" IS NOT NULL;
@@ -0,0 +1,32 @@
1
+ CREATE TABLE "smilies" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "smilies_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "code" text NOT NULL,
4
+ "src" text NOT NULL,
5
+ "alt" text,
6
+ "enabled" boolean DEFAULT true NOT NULL,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
8
+ );
9
+ --> statement-breakpoint
10
+ CREATE UNIQUE INDEX "smilies_code_key" ON "smilies" ("code");
11
+ --> statement-breakpoint
12
+
13
+ CREATE TABLE "custom_bbcode" (
14
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "custom_bbcode_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
15
+ "name" text NOT NULL,
16
+ "block" boolean DEFAULT false NOT NULL,
17
+ "description" text,
18
+ "enabled" boolean DEFAULT true NOT NULL,
19
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE UNIQUE INDEX "custom_bbcode_name_key" ON "custom_bbcode" ("name");
23
+ --> statement-breakpoint
24
+
25
+ ALTER TABLE "posts" ADD COLUMN "vocab_version" smallint DEFAULT 0 NOT NULL;
26
+ --> statement-breakpoint
27
+ ALTER TABLE "private_messages" ADD COLUMN "vocab_version" smallint DEFAULT 0 NOT NULL;
28
+ --> statement-breakpoint
29
+
30
+ CREATE INDEX "posts_vocab_version_idx" ON "posts" ("vocab_version", "id");
31
+ --> statement-breakpoint
32
+ CREATE INDEX "private_messages_vocab_version_idx" ON "private_messages" ("vocab_version", "id");
@@ -0,0 +1,16 @@
1
+ CREATE TABLE "announcements" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "announcements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "forum_id" integer REFERENCES "forums"("id") ON DELETE CASCADE,
4
+ "title" text NOT NULL,
5
+ "message" text NOT NULL,
6
+ "author_user_id" integer REFERENCES "users"("id") ON DELETE SET NULL,
7
+ "author_username" text DEFAULT '' NOT NULL,
8
+ "starts_at" timestamp with time zone DEFAULT now() NOT NULL,
9
+ "ends_at" timestamp with time zone,
10
+ "enabled" boolean DEFAULT true NOT NULL,
11
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE INDEX "announcements_live_idx" ON "announcements" ("starts_at" DESC) WHERE "enabled";
15
+ --> statement-breakpoint
16
+ CREATE INDEX "announcements_forum_idx" ON "announcements" ("forum_id");
@@ -0,0 +1,18 @@
1
+ CREATE TABLE "rate_limits" (
2
+ "scope" text NOT NULL,
3
+ "subject" text NOT NULL,
4
+ "window_start" timestamp with time zone NOT NULL,
5
+ "used" integer DEFAULT 0 NOT NULL,
6
+ CONSTRAINT "rate_limits_pkey" PRIMARY KEY ("scope", "subject", "window_start")
7
+ );
8
+ --> statement-breakpoint
9
+ CREATE INDEX "rate_limits_window_idx" ON "rate_limits" ("window_start");
10
+ --> statement-breakpoint
11
+
12
+ CREATE TABLE "captcha_questions" (
13
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "captcha_questions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
14
+ "question" text NOT NULL,
15
+ "answers" text NOT NULL,
16
+ "enabled" boolean DEFAULT true NOT NULL,
17
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
18
+ );
@@ -0,0 +1,24 @@
1
+ ALTER TABLE "posts" ADD COLUMN "body_format" smallint DEFAULT 0 NOT NULL;--> statement-breakpoint
2
+ ALTER TABLE "posts" ALTER COLUMN "body_format" SET DEFAULT 1;--> statement-breakpoint
3
+
4
+ ALTER TABLE "private_messages" ADD COLUMN "body_format" smallint DEFAULT 0 NOT NULL;--> statement-breakpoint
5
+ ALTER TABLE "private_messages" ALTER COLUMN "body_format" SET DEFAULT 1;--> statement-breakpoint
6
+
7
+ ALTER TABLE "users" ADD COLUMN "signature_format" smallint DEFAULT 0 NOT NULL;--> statement-breakpoint
8
+ ALTER TABLE "users" ALTER COLUMN "signature_format" SET DEFAULT 1;--> statement-breakpoint
9
+
10
+ ALTER TABLE "announcements" ADD COLUMN "body_format" smallint DEFAULT 0 NOT NULL;--> statement-breakpoint
11
+ ALTER TABLE "announcements" ALTER COLUMN "body_format" SET DEFAULT 1;--> statement-breakpoint
12
+
13
+ ALTER TABLE "post_drafts" ADD COLUMN "body_format" smallint DEFAULT 0 NOT NULL;--> statement-breakpoint
14
+ ALTER TABLE "post_drafts" ALTER COLUMN "body_format" SET DEFAULT 1;--> statement-breakpoint
15
+
16
+ DROP INDEX IF EXISTS "posts_vocab_version_idx";--> statement-breakpoint
17
+ CREATE INDEX "posts_render_state_idx" ON "posts" ("body_format", "vocab_version", "id");--> statement-breakpoint
18
+ DROP INDEX IF EXISTS "private_messages_vocab_version_idx";--> statement-breakpoint
19
+ CREATE INDEX "private_messages_render_state_idx" ON "private_messages" ("body_format", "vocab_version", "id");--> statement-breakpoint
20
+
21
+ ALTER TABLE "custom_bbcode" RENAME TO "custom_directives";--> statement-breakpoint
22
+ ALTER INDEX "custom_bbcode_name_key" RENAME TO "custom_directives_name_key";--> statement-breakpoint
23
+
24
+ UPDATE "cache_versions" SET "key" = 'markdown_vocabulary' WHERE "key" = 'bbcode_vocabulary';
@@ -0,0 +1 @@
1
+ ALTER TABLE "themes" ADD COLUMN "enabled" boolean DEFAULT true NOT NULL;
@@ -0,0 +1,5 @@
1
+ ALTER TABLE "usergroups" ADD COLUMN "name_color_light" text;--> statement-breakpoint
2
+ ALTER TABLE "usergroups" ADD COLUMN "name_color_dark" text;--> statement-breakpoint
3
+
4
+ ALTER TABLE "usergroups" ADD COLUMN "badge_image_light" text;--> statement-breakpoint
5
+ ALTER TABLE "usergroups" ADD COLUMN "badge_image_dark" text;
@@ -0,0 +1,4 @@
1
+ ALTER TABLE "posts" ADD COLUMN "search_version" smallint NOT NULL DEFAULT 0;--> statement-breakpoint
2
+ ALTER TABLE "posts" ALTER COLUMN "search_version" SET DEFAULT 1;--> statement-breakpoint
3
+
4
+ CREATE INDEX "posts_search_version_idx" ON "posts" USING btree ("search_version","id");
@@ -0,0 +1 @@
1
+ UPDATE "forums" SET "allow_threads" = false WHERE "type" <> 'forum';
@@ -0,0 +1,6 @@
1
+ ALTER TABLE "user_group_memberships" ADD COLUMN "expires_at" timestamp with time zone;--> statement-breakpoint
2
+ ALTER TABLE "user_group_memberships" ADD COLUMN "granted_by_plugin" text;--> statement-breakpoint
3
+ ALTER TABLE "user_group_memberships" ADD COLUMN "grant_reason" text;--> statement-breakpoint
4
+ CREATE INDEX "user_group_memberships_expiry_idx" ON "user_group_memberships" ("expires_at") WHERE "expires_at" is not null;--> statement-breakpoint
5
+
6
+ ALTER TABLE "usergroups" ADD COLUMN "plugin_grantable" boolean NOT NULL DEFAULT false;
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "users" ALTER COLUMN "timezone" SET DEFAULT 'auto';--> statement-breakpoint
2
+
3
+ UPDATE "users" SET "timezone" = 'auto' WHERE "timezone" = 'UTC';
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "user_group_memberships" ADD COLUMN "previous_primary_group_id" integer;--> statement-breakpoint
2
+ ALTER TABLE "user_group_memberships" ADD CONSTRAINT "user_group_memberships_previous_primary_group_id_usergroups_id_fk" FOREIGN KEY ("previous_primary_group_id") REFERENCES "public"."usergroups"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
3
+ CREATE INDEX "user_group_memberships_previous_primary_idx" ON "user_group_memberships" USING btree ("user_id") WHERE "user_group_memberships"."previous_primary_group_id" is not null;
@@ -0,0 +1 @@
1
+ CREATE INDEX "admin_log_forum_scope_idx" ON "admin_log" USING gin (("detail" -> 'forumIds') jsonb_path_ops);
@@ -0,0 +1 @@
1
+ UPDATE "forum_moderators" SET "can_restore_posts" = true WHERE "can_soft_delete_posts" = true;
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "forum_moderators" DROP COLUMN "can_hard_delete_posts";--> statement-breakpoint
2
+ ALTER TABLE "forum_moderators" DROP COLUMN "can_manage_polls";--> statement-breakpoint
3
+ ALTER TABLE "forum_moderators" DROP COLUMN "can_view_ips";
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "usergroups" DROP COLUMN "can_delete_others_posts";--> statement-breakpoint
2
+ ALTER TABLE "forum_permissions" DROP COLUMN "can_delete_others_posts";
@@ -0,0 +1,28 @@
1
+ CREATE TABLE "passkeys" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "passkeys_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "user_id" integer NOT NULL,
4
+ "credential_id" text NOT NULL,
5
+ "public_key" text NOT NULL,
6
+ "sign_count" integer DEFAULT 0 NOT NULL,
7
+ "label" text NOT NULL,
8
+ "transports" text,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
10
+ "last_used_at" timestamp with time zone
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "user_identities" (
14
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "user_identities_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
15
+ "user_id" integer NOT NULL,
16
+ "provider" text NOT NULL,
17
+ "subject" text NOT NULL,
18
+ "label" text,
19
+ "linked_at" timestamp with time zone DEFAULT now() NOT NULL,
20
+ "last_used_at" timestamp with time zone
21
+ );
22
+ --> statement-breakpoint
23
+ ALTER TABLE "passkeys" ADD CONSTRAINT "passkeys_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
24
+ ALTER TABLE "user_identities" ADD CONSTRAINT "user_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
25
+ CREATE UNIQUE INDEX "passkeys_credential_id_key" ON "passkeys" USING btree ("credential_id");--> statement-breakpoint
26
+ CREATE INDEX "passkeys_user_idx" ON "passkeys" USING btree ("user_id","id");--> statement-breakpoint
27
+ CREATE UNIQUE INDEX "user_identities_provider_subject_key" ON "user_identities" USING btree ("provider","subject");--> statement-breakpoint
28
+ CREATE INDEX "user_identities_user_idx" ON "user_identities" USING btree ("user_id","id");
@@ -0,0 +1,34 @@
1
+ CREATE TABLE "auth_events" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "auth_events_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "user_id" integer,
4
+ "kind" text NOT NULL,
5
+ "ip_prefix" text,
6
+ "user_agent" text,
7
+ "detail" jsonb DEFAULT '{}'::jsonb NOT NULL,
8
+ "at" timestamp with time zone DEFAULT now() NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE TABLE "recovery_codes" (
12
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "recovery_codes_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
13
+ "user_id" integer NOT NULL,
14
+ "code_hash" text NOT NULL,
15
+ "used_at" timestamp with time zone,
16
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE TABLE "user_two_factor" (
20
+ "user_id" integer PRIMARY KEY NOT NULL,
21
+ "sealed_secret" text NOT NULL,
22
+ "confirmed_at" timestamp with time zone,
23
+ "last_step" bigint,
24
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
25
+ );
26
+ --> statement-breakpoint
27
+ ALTER TABLE "auth_events" ADD CONSTRAINT "auth_events_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
28
+ ALTER TABLE "recovery_codes" ADD CONSTRAINT "recovery_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
29
+ ALTER TABLE "user_two_factor" ADD CONSTRAINT "user_two_factor_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
30
+ CREATE INDEX "auth_events_user_idx" ON "auth_events" USING btree ("user_id","id" DESC NULLS LAST);--> statement-breakpoint
31
+ CREATE INDEX "auth_events_recent_idx" ON "auth_events" USING btree ("id" DESC NULLS LAST);--> statement-breakpoint
32
+ CREATE INDEX "auth_events_kind_idx" ON "auth_events" USING btree ("kind","id" DESC NULLS LAST);--> statement-breakpoint
33
+ CREATE UNIQUE INDEX "recovery_codes_user_hash_key" ON "recovery_codes" USING btree ("user_id","code_hash");--> statement-breakpoint
34
+ CREATE INDEX "recovery_codes_unused_idx" ON "recovery_codes" USING btree ("user_id") WHERE "recovery_codes"."used_at" is null;
@@ -0,0 +1 @@
1
+ DROP INDEX "tasks_due_idx";
@@ -0,0 +1 @@
1
+ ALTER TABLE "users" ADD COLUMN "locale" text DEFAULT 'auto' NOT NULL;
@@ -0,0 +1,34 @@
1
+ CREATE TABLE "navigation_item_groups" (
2
+ "item_id" integer NOT NULL,
3
+ "group_id" integer NOT NULL,
4
+ CONSTRAINT "navigation_item_groups_item_id_group_id_pk" PRIMARY KEY("item_id","group_id")
5
+ );
6
+ --> statement-breakpoint
7
+ CREATE TABLE "navigation_items" (
8
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "navigation_items_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
9
+ "key" text,
10
+ "parent_id" integer,
11
+ "label" text DEFAULT '' NOT NULL,
12
+ "href" text NOT NULL,
13
+ "display_order" integer DEFAULT 0 NOT NULL,
14
+ "audience" text DEFAULT 'all' NOT NULL,
15
+ "new_tab" boolean DEFAULT false NOT NULL,
16
+ "enabled" boolean DEFAULT true NOT NULL,
17
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
18
+ CONSTRAINT "navigation_items_audience_check" CHECK ("navigation_items"."audience" in ('all', 'guests', 'members', 'staff'))
19
+ );
20
+ --> statement-breakpoint
21
+ ALTER TABLE "navigation_item_groups" ADD CONSTRAINT "navigation_item_groups_item_id_navigation_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."navigation_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
22
+ ALTER TABLE "navigation_item_groups" ADD CONSTRAINT "navigation_item_groups_group_id_usergroups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."usergroups"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
23
+ ALTER TABLE "navigation_items" ADD CONSTRAINT "navigation_items_parent_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."navigation_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
24
+ CREATE INDEX "navigation_item_groups_group_idx" ON "navigation_item_groups" USING btree ("group_id");--> statement-breakpoint
25
+ CREATE UNIQUE INDEX "navigation_items_key_key" ON "navigation_items" USING btree ("key") WHERE "navigation_items"."key" is not null;--> statement-breakpoint
26
+ CREATE INDEX "navigation_items_order_idx" ON "navigation_items" USING btree ("parent_id","display_order","id");--> statement-breakpoint
27
+
28
+ INSERT INTO "navigation_items" ("key", "href", "display_order", "audience")
29
+ VALUES ('home', '/', 0, 'all'),
30
+ ('new-posts', '/discover/new', 10, 'all'),
31
+ ('unanswered', '/discover/unanswered', 20, 'all'),
32
+ ('my-posts', '/discover/participated', 30, 'members'),
33
+ ('search', '/search', 40, 'all'),
34
+ ('online', '/online', 50, 'all');
@@ -0,0 +1,16 @@
1
+ CREATE TABLE "push_subscriptions" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "push_subscriptions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "user_id" integer NOT NULL,
4
+ "endpoint" text NOT NULL,
5
+ "p256dh" text NOT NULL,
6
+ "auth" text NOT NULL,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
8
+ "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ ALTER TABLE "notification_preferences" ALTER COLUMN "email" DROP NOT NULL;--> statement-breakpoint
12
+ ALTER TABLE "notification_preferences" ADD COLUMN "push" boolean;--> statement-breakpoint
13
+ ALTER TABLE "notifications" ADD COLUMN "push_sent_at" timestamp with time zone;--> statement-breakpoint
14
+ ALTER TABLE "push_subscriptions" ADD CONSTRAINT "push_subscriptions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
15
+ CREATE UNIQUE INDEX "push_subscriptions_endpoint_key" ON "push_subscriptions" USING btree ("endpoint");--> statement-breakpoint
16
+ CREATE INDEX "push_subscriptions_user_idx" ON "push_subscriptions" USING btree ("user_id","id");
@@ -0,0 +1,7 @@
1
+ CREATE TABLE "plugin_health" (
2
+ "plugin_key" text PRIMARY KEY NOT NULL,
3
+ "failures" integer DEFAULT 0 NOT NULL,
4
+ "disabled_at" timestamp with time zone,
5
+ "reason" text,
6
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
7
+ );
@@ -0,0 +1 @@
1
+ DROP TABLE "forum_password_grants" CASCADE;
@@ -0,0 +1 @@
1
+ ALTER TABLE "sessions" ADD COLUMN "credential_proved_at" timestamp with time zone;
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "attachments" ALTER COLUMN "post_id" DROP NOT NULL;--> statement-breakpoint
2
+ CREATE INDEX "attachments_orphan_idx" ON "attachments" USING btree ("created_at") WHERE "attachments"."post_id" is null;
@@ -0,0 +1,14 @@
1
+ CREATE TABLE "admin_undo_operations" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "admin_undo_operations_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "token_hash" text NOT NULL,
4
+ "actor_user_id" integer NOT NULL,
5
+ "operation" text NOT NULL,
6
+ "snapshot" jsonb NOT NULL,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
8
+ "expires_at" timestamp with time zone NOT NULL,
9
+ "consumed_at" timestamp with time zone
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "admin_undo_operations" ADD CONSTRAINT "admin_undo_operations_actor_user_id_users_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
13
+ CREATE UNIQUE INDEX "admin_undo_operations_token_key" ON "admin_undo_operations" USING btree ("token_hash");--> statement-breakpoint
14
+ CREATE INDEX "admin_undo_operations_live_idx" ON "admin_undo_operations" USING btree ("actor_user_id","expires_at");