refactor(server): squash drizzle migrations 0000-0004 into single baseline

Generated by pnpm db:generate against the current schema.ts — replaces
five historical migrations (0000_initial, 0001_clear_earthquake,
0002_peer_approval_requests, 0003_classy_loki, 0004_cooing_black_knight)
with one baseline that matches the schema shape all five produced together.

Pi + VM __drizzle_migrations rows will be rewritten per the Phase 2
surgery procedure before this deploys to either instance; DBs already
match the new baseline, no DDL runs. Phase 1 audit verified no still-present
bugs depend on any of the squashed migrations.

Refs backlog #31 Phase 2.
This commit is contained in:
Jannis Braun
2026-04-24 23:26:20 +02:00
parent a181b1ad10
commit 707d3217f1
10 changed files with 92 additions and 9682 deletions
@@ -188,7 +188,8 @@ CREATE TABLE `federation_peers` (
`status` text DEFAULT 'active' NOT NULL,
`last_seen_at` integer,
`last_failure_at` integer,
`consecutive_failures` integer DEFAULT 0,
`consecutive_failures` integer DEFAULT 0 NOT NULL,
`consecutive_auth_failures` integer DEFAULT 0 NOT NULL,
`last_synced_at` integer DEFAULT 0,
`remote_max_upload_size` integer,
`nonce_supported` integer DEFAULT 0 NOT NULL,
@@ -238,6 +239,7 @@ CREATE TABLE `instance_settings` (
`federation_relay_enabled` integer DEFAULT 1 NOT NULL,
`federation_relay_ttl_days` integer DEFAULT 30 NOT NULL,
`default_auto_rotate_interval_days` integer DEFAULT 90 NOT NULL,
`auto_accept_peering` integer DEFAULT 1 NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
@@ -278,6 +280,15 @@ CREATE TABLE `messages` (
FOREIGN KEY (`reply_to_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `peer_approval_requests` (
`id` text PRIMARY KEY NOT NULL,
`origin` text NOT NULL,
`instance_name` text,
`hmac_secret` text NOT NULL,
`requested_at` integer NOT NULL,
`expires_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `reactions` (
`id` text PRIMARY KEY NOT NULL,
`message_id` text NOT NULL,
@@ -436,6 +447,7 @@ CREATE INDEX `idx_join_requests_space_id_status` ON `join_requests` (`space_id`,
CREATE INDEX `idx_member_roles_user_id_space_id` ON `member_roles` (`user_id`,`space_id`);--> statement-breakpoint
CREATE INDEX `idx_messages_channel_id` ON `messages` (`channel_id`);--> statement-breakpoint
CREATE INDEX `idx_messages_user_id` ON `messages` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `peer_approval_requests_origin_unique` ON `peer_approval_requests` (`origin`);--> statement-breakpoint
CREATE INDEX `idx_reactions_message_id` ON `reactions` (`message_id`);--> statement-breakpoint
CREATE INDEX `idx_read_states_user_id` ON `read_states` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_roles_space_id` ON `roles` (`space_id`);--> statement-breakpoint
@@ -1 +0,0 @@
ALTER TABLE `instance_settings` ADD `auto_accept_peering` integer DEFAULT 1 NOT NULL;
@@ -1,10 +0,0 @@
CREATE TABLE `peer_approval_requests` (
`id` text PRIMARY KEY NOT NULL,
`origin` text NOT NULL,
`instance_name` text,
`hmac_secret` text NOT NULL,
`requested_at` integer NOT NULL,
`expires_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `peer_approval_requests_origin_unique` ON `peer_approval_requests` (`origin`);
@@ -1 +0,0 @@
ALTER TABLE `federation_peers` ADD `consecutive_auth_failures` integer DEFAULT 0 NOT NULL;
@@ -1,29 +0,0 @@
PRAGMA defer_foreign_keys=ON;
--> statement-breakpoint
CREATE TABLE `__new_federation_peers` (
`id` text PRIMARY KEY NOT NULL,
`origin` text NOT NULL,
`instance_name` text,
`hmac_secret` text NOT NULL,
`status` text DEFAULT 'active' NOT NULL,
`last_seen_at` integer,
`last_failure_at` integer,
`consecutive_failures` integer DEFAULT 0 NOT NULL,
`consecutive_auth_failures` integer DEFAULT 0 NOT NULL,
`last_synced_at` integer DEFAULT 0,
`remote_max_upload_size` integer,
`nonce_supported` integer DEFAULT 0 NOT NULL,
`pending_hmac_secret` text,
`secret_rotation_at` integer,
`secret_rotated_at` integer,
`auto_rotate_interval_days` integer DEFAULT 90 NOT NULL,
`created_at` integer NOT NULL
);
--> statement-breakpoint
INSERT INTO `__new_federation_peers`("id", "origin", "instance_name", "hmac_secret", "status", "last_seen_at", "last_failure_at", "consecutive_failures", "consecutive_auth_failures", "last_synced_at", "remote_max_upload_size", "nonce_supported", "pending_hmac_secret", "secret_rotation_at", "secret_rotated_at", "auto_rotate_interval_days", "created_at") SELECT "id", "origin", "instance_name", "hmac_secret", "status", "last_seen_at", "last_failure_at", COALESCE("consecutive_failures", 0), "consecutive_auth_failures", "last_synced_at", "remote_max_upload_size", "nonce_supported", "pending_hmac_secret", "secret_rotation_at", "secret_rotated_at", "auto_rotate_interval_days", "created_at" FROM `federation_peers`;
--> statement-breakpoint
DROP TABLE `federation_peers`;
--> statement-breakpoint
ALTER TABLE `__new_federation_peers` RENAME TO `federation_peers`;
--> statement-breakpoint
CREATE UNIQUE INDEX `federation_peers_origin_unique` ON `federation_peers` (`origin`);
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "092e4ee0-51c4-4332-890c-fa011657a9a5",
"id": "b5b7d74f-4158-4798-9f01-2cbab126f9da",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"attachments": {
@@ -1456,7 +1456,15 @@
"name": "consecutive_failures",
"type": "integer",
"primaryKey": false,
"notNull": false,
"notNull": true,
"autoincrement": false,
"default": 0
},
"consecutive_auth_failures": {
"name": "consecutive_auth_failures",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
},
@@ -1850,6 +1858,14 @@
"autoincrement": false,
"default": 90
},
"auto_accept_peering": {
"name": "auto_accept_peering",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 1
},
"updated_at": {
"name": "updated_at",
"type": "integer",
@@ -2179,6 +2195,65 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"peer_approval_requests": {
"name": "peer_approval_requests",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"origin": {
"name": "origin",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"instance_name": {
"name": "instance_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hmac_secret": {
"name": "hmac_secret",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"requested_at": {
"name": "requested_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"peer_approval_requests_origin_unique": {
"name": "peer_approval_requests_origin_unique",
"columns": [
"origin"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"reactions": {
"name": "reactions",
"columns": {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -30
View File
@@ -5,36 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1775687181033,
"tag": "0000_initial",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1775734599940,
"tag": "0001_clear_earthquake",
"breakpoints": true
},
{
"idx": 2,
"version": "6",
"when": 1776689384005,
"tag": "0002_peer_approval_requests",
"breakpoints": true
},
{
"idx": 3,
"version": "6",
"when": 1776789567488,
"tag": "0003_classy_loki",
"breakpoints": true
},
{
"idx": 4,
"version": "6",
"when": 1776802580650,
"tag": "0004_cooing_black_knight",
"when": 1777065939127,
"tag": "0000_lethal_wildside",
"breakpoints": true
}
]