Initial hop. implementation and UGREEN NAS deployment guide

This commit is contained in:
2026-10-12 13:37:50 +09:00
commit 439c2ae61b
93 changed files with 42434 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
CREATE TABLE `item_access` (
`id` text PRIMARY KEY NOT NULL,
`itemId` text NOT NULL,
`guestId` text NOT NULL,
`role` text NOT NULL,
`read` integer DEFAULT false NOT NULL,
`deletedAt` integer,
FOREIGN KEY (`itemId`) REFERENCES `items`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `access_subject_role` ON `item_access` (`itemId`,`guestId`,`role`);--> statement-breakpoint
CREATE INDEX `access_guest` ON `item_access` (`guestId`,`deletedAt`);--> statement-breakpoint
CREATE TABLE `transfer_batches` (
`id` text PRIMARY KEY NOT NULL,
`requestId` text NOT NULL,
`status` text NOT NULL,
`storedAt` integer,
FOREIGN KEY (`requestId`) REFERENCES `transfer_requests`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `transfer_batches_requestId_unique` ON `transfer_batches` (`requestId`);--> statement-breakpoint
CREATE TABLE `guest_blocks` (
`id` text PRIMARY KEY NOT NULL,
`guestId` text NOT NULL,
`targetGuestId` text NOT NULL,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`targetGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `guest_block_pair` ON `guest_blocks` (`guestId`,`targetGuestId`);--> statement-breakpoint
CREATE TABLE `browser_devices` (
`id` text PRIMARY KEY NOT NULL,
`guestId` text NOT NULL,
`name` text NOT NULL,
`code` text NOT NULL,
`discoverable` integer DEFAULT true NOT NULL,
`lastSeen` integer NOT NULL,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "device_name_length" CHECK(length("browser_devices"."name") between 1 and 40)
);
--> statement-breakpoint
CREATE UNIQUE INDEX `browser_devices_guestId_unique` ON `browser_devices` (`guestId`);--> statement-breakpoint
CREATE UNIQUE INDEX `browser_devices_code_unique` ON `browser_devices` (`code`);--> statement-breakpoint
CREATE TABLE `guest_sessions` (
`id` text PRIMARY KEY NOT NULL,
`tokenHash` text NOT NULL,
`expiresAt` integer NOT NULL,
`revokedAt` integer,
`createdAt` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `guest_sessions_tokenHash_unique` ON `guest_sessions` (`tokenHash`);--> statement-breakpoint
CREATE INDEX `guest_expiry` ON `guest_sessions` (`expiresAt`);--> statement-breakpoint
CREATE TABLE `idempotency_records` (
`id` text PRIMARY KEY NOT NULL,
`guestId` text NOT NULL,
`operation` text NOT NULL,
`key` text NOT NULL,
`payloadHash` text NOT NULL,
`response` text NOT NULL,
`createdAt` integer NOT NULL,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `idempotency_scope` ON `idempotency_records` (`guestId`,`operation`,`key`);--> statement-breakpoint
CREATE TABLE `items` (
`id` text PRIMARY KEY NOT NULL,
`batchId` text NOT NULL,
`kind` text NOT NULL,
`text` text,
`url` text,
`createdAt` integer NOT NULL,
`expiresAt` integer NOT NULL,
FOREIGN KEY (`batchId`) REFERENCES `transfer_batches`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "item_payload" CHECK(("items"."kind" = 'text' AND "items"."text" IS NOT NULL AND "items"."url" IS NULL) OR ("items"."kind" = 'url' AND "items"."url" IS NOT NULL AND "items"."text" IS NULL))
);
--> statement-breakpoint
CREATE INDEX `items_expiry` ON `items` (`expiresAt`);--> statement-breakpoint
CREATE TABLE `space_members` (
`id` text PRIMARY KEY NOT NULL,
`spaceId` text NOT NULL,
`deviceId` text NOT NULL,
`status` text NOT NULL,
`joinedAt` integer NOT NULL,
FOREIGN KEY (`spaceId`) REFERENCES `connection_spaces`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`deviceId`) REFERENCES `browser_devices`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `space_device` ON `space_members` (`spaceId`,`deviceId`);--> statement-breakpoint
CREATE TABLE `transfer_requests` (
`id` text PRIMARY KEY NOT NULL,
`mode` text DEFAULT 'local' NOT NULL,
`senderGuestId` text NOT NULL,
`recipientGuestId` text NOT NULL,
`kind` text NOT NULL,
`byteSize` integer NOT NULL,
`count` integer NOT NULL,
`status` text NOT NULL,
`createdAt` integer NOT NULL,
`expiresAt` integer NOT NULL,
`acceptedAt` integer,
`startBy` integer,
FOREIGN KEY (`senderGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`recipientGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "request_different_guests" CHECK("transfer_requests"."senderGuestId" <> "transfer_requests"."recipientGuestId")
);
--> statement-breakpoint
CREATE INDEX `requests_sender_time` ON `transfer_requests` (`senderGuestId`,`createdAt`);--> statement-breakpoint
CREATE INDEX `requests_recipient_time` ON `transfer_requests` (`recipientGuestId`,`createdAt`);--> statement-breakpoint
CREATE INDEX `requests_expiry` ON `transfer_requests` (`status`,`expiresAt`);--> statement-breakpoint
CREATE TABLE `connection_spaces` (
`id` text PRIMARY KEY NOT NULL,
`creatorGuestId` text NOT NULL,
`tokenHash` text NOT NULL,
`codeHash` text NOT NULL,
`approvalRequired` integer NOT NULL,
`expiresAt` integer NOT NULL,
`closedAt` integer,
`createdAt` integer NOT NULL,
FOREIGN KEY (`creatorGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `connection_spaces_tokenHash_unique` ON `connection_spaces` (`tokenHash`);--> statement-breakpoint
CREATE UNIQUE INDEX `connection_spaces_codeHash_unique` ON `connection_spaces` (`codeHash`);--> statement-breakpoint
CREATE INDEX `space_expiry` ON `connection_spaces` (`expiresAt`);

View File

@@ -0,0 +1 @@
ALTER TABLE `transfer_requests` ADD `rejectedAt` integer;

View File

@@ -0,0 +1,71 @@
CREATE TABLE `deletion_targets` (
`id` text PRIMARY KEY NOT NULL,
`operationId` text NOT NULL,
`accessId` text NOT NULL,
FOREIGN KEY (`operationId`) REFERENCES `deletion_operations`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `deletion_operations` (
`id` text PRIMARY KEY NOT NULL,
`guestId` text NOT NULL,
`undoUntil` integer NOT NULL,
`createdAt` integer NOT NULL,
`restoredAt` integer,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `files` (
`id` text PRIMARY KEY NOT NULL,
`requestId` text NOT NULL,
`ownerGuestId` text NOT NULL,
`position` integer NOT NULL,
`storageKey` text NOT NULL,
`name` text NOT NULL,
`type` text NOT NULL,
`size` integer NOT NULL,
`checksum` text,
`status` text NOT NULL,
`uploadId` text,
`updatedAt` integer NOT NULL,
FOREIGN KEY (`requestId`) REFERENCES `transfer_requests`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`ownerGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "file_nonnegative_size" CHECK("files"."size" >= 0)
);
--> statement-breakpoint
CREATE UNIQUE INDEX `files_storageKey_unique` ON `files` (`storageKey`);--> statement-breakpoint
CREATE UNIQUE INDEX `request_file_position` ON `files` (`requestId`,`position`);--> statement-breakpoint
CREATE INDEX `files_owner_state` ON `files` (`ownerGuestId`,`status`);--> statement-breakpoint
CREATE TABLE `quota_reservations` (
`id` text PRIMARY KEY NOT NULL,
`fileId` text NOT NULL,
`guestId` text NOT NULL,
`bytes` integer NOT NULL,
`expiresAt` integer NOT NULL,
FOREIGN KEY (`fileId`) REFERENCES `files`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "reservation_nonnegative" CHECK("quota_reservations"."bytes" >= 0)
);
--> statement-breakpoint
CREATE UNIQUE INDEX `quota_reservations_fileId_unique` ON `quota_reservations` (`fileId`);--> statement-breakpoint
CREATE INDEX `quota_guest_expiry` ON `quota_reservations` (`guestId`,`expiresAt`);--> statement-breakpoint
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_items` (
`id` text PRIMARY KEY NOT NULL,
`batchId` text NOT NULL,
`kind` text NOT NULL,
`text` text,
`url` text,
`fileId` text,
`createdAt` integer NOT NULL,
`expiresAt` integer NOT NULL,
FOREIGN KEY (`batchId`) REFERENCES `transfer_batches`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`fileId`) REFERENCES `files`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "item_payload" CHECK(("__new_items"."kind" = 'text' AND "__new_items"."text" IS NOT NULL AND "__new_items"."url" IS NULL AND "__new_items"."fileId" IS NULL) OR ("__new_items"."kind" = 'url' AND "__new_items"."url" IS NOT NULL AND "__new_items"."text" IS NULL AND "__new_items"."fileId" IS NULL) OR ("__new_items"."kind" = 'file' AND "__new_items"."fileId" IS NOT NULL AND "__new_items"."text" IS NULL AND "__new_items"."url" IS NULL))
);
--> statement-breakpoint
INSERT INTO `__new_items`("id", "batchId", "kind", "text", "url", "fileId", "createdAt", "expiresAt") SELECT "id", "batchId", "kind", "text", "url", NULL, "createdAt", "expiresAt" FROM `items`;--> statement-breakpoint
DROP TABLE `items`;--> statement-breakpoint
ALTER TABLE `__new_items` RENAME TO `items`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE INDEX `items_expiry` ON `items` (`expiresAt`);--> statement-breakpoint
ALTER TABLE `transfer_requests` ADD `manifest` text;

View File

@@ -0,0 +1 @@
ALTER TABLE `files` ADD `uploadKey` text;

View File

@@ -0,0 +1,191 @@
CREATE TABLE `account_sessions` (
`id` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
`tokenHash` text NOT NULL,
`createdAt` integer NOT NULL,
`lastSeen` integer NOT NULL,
`expiresAt` integer NOT NULL,
`revokedAt` integer,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `account_sessions_tokenHash_unique` ON `account_sessions` (`tokenHash`);--> statement-breakpoint
CREATE INDEX `account_session_user` ON `account_sessions` (`userId`,`expiresAt`);--> statement-breakpoint
CREATE TABLE `account_tokens` (
`id` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
`purpose` text NOT NULL,
`tokenHash` text NOT NULL,
`value` text,
`createdAt` integer NOT NULL,
`expiresAt` integer NOT NULL,
`usedAt` integer,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `account_tokens_tokenHash_unique` ON `account_tokens` (`tokenHash`);--> statement-breakpoint
CREATE INDEX `account_token_expiry` ON `account_tokens` (`expiresAt`);--> statement-breakpoint
CREATE TABLE `user_rules` (
`id` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
`targetUserId` text NOT NULL,
`action` text NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`targetUserId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "rule_not_self" CHECK("user_rules"."userId" <> "user_rules"."targetUserId")
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_rule_pair` ON `user_rules` (`userId`,`targetUserId`);--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`email` text,
`displayName` text NOT NULL,
`passwordHash` text,
`role` text DEFAULT 'user' NOT NULL,
`status` text NOT NULL,
`verifiedAt` integer,
`createdAt` integer NOT NULL,
`receivePolicy` text DEFAULT 'requests' NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_transfer_requests` (
`id` text PRIMARY KEY NOT NULL,
`mode` text DEFAULT 'local' NOT NULL,
`senderGuestId` text,
`recipientGuestId` text,
`senderUserId` text,
`recipientUserId` text,
`kind` text NOT NULL,
`byteSize` integer NOT NULL,
`manifest` text,
`count` integer NOT NULL,
`status` text NOT NULL,
`createdAt` integer NOT NULL,
`expiresAt` integer NOT NULL,
`acceptedAt` integer,
`rejectedAt` integer,
`startBy` integer,
FOREIGN KEY (`senderGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`recipientGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`senderUserId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`recipientUserId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "request_different_guests" CHECK("__new_transfer_requests"."mode" <> 'local' OR "__new_transfer_requests"."senderGuestId" <> "__new_transfer_requests"."recipientGuestId"),
CONSTRAINT "request_sender_subject" CHECK(("__new_transfer_requests"."senderGuestId" IS NOT NULL) + ("__new_transfer_requests"."senderUserId" IS NOT NULL) = 1),
CONSTRAINT "request_recipient_subject" CHECK(("__new_transfer_requests"."recipientGuestId" IS NOT NULL) + ("__new_transfer_requests"."recipientUserId" IS NOT NULL) = 1),
CONSTRAINT "request_mode_subjects" CHECK(("__new_transfer_requests"."mode" = 'local' AND "__new_transfer_requests"."senderGuestId" IS NOT NULL AND "__new_transfer_requests"."recipientGuestId" IS NOT NULL) OR ("__new_transfer_requests"."mode" = 'email' AND "__new_transfer_requests"."senderUserId" IS NOT NULL AND "__new_transfer_requests"."recipientUserId" IS NOT NULL))
);
--> statement-breakpoint
INSERT INTO `__new_transfer_requests`("id", "mode", "senderGuestId", "recipientGuestId", "senderUserId", "recipientUserId", "kind", "byteSize", "manifest", "count", "status", "createdAt", "expiresAt", "acceptedAt", "rejectedAt", "startBy") SELECT "id", "mode", "senderGuestId", "recipientGuestId", NULL, NULL, "kind", "byteSize", "manifest", "count", "status", "createdAt", "expiresAt", "acceptedAt", "rejectedAt", "startBy" FROM `transfer_requests`;--> statement-breakpoint
DROP TABLE `transfer_requests`;--> statement-breakpoint
ALTER TABLE `__new_transfer_requests` RENAME TO `transfer_requests`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE INDEX `requests_sender_time` ON `transfer_requests` (`senderGuestId`,`createdAt`);--> statement-breakpoint
CREATE INDEX `requests_recipient_time` ON `transfer_requests` (`recipientGuestId`,`createdAt`);--> statement-breakpoint
CREATE INDEX `requests_expiry` ON `transfer_requests` (`status`,`expiresAt`);--> statement-breakpoint
CREATE INDEX `requests_sender_user` ON `transfer_requests` (`senderUserId`,`createdAt`);--> statement-breakpoint
CREATE INDEX `requests_recipient_user` ON `transfer_requests` (`recipientUserId`,`createdAt`);--> statement-breakpoint
CREATE TABLE `__new_item_access` (
`id` text PRIMARY KEY NOT NULL,
`itemId` text NOT NULL,
`userId` text,
`guestId` text,
`role` text NOT NULL,
`read` integer DEFAULT false NOT NULL,
`deletedAt` integer,
`favorite` integer DEFAULT false NOT NULL,
FOREIGN KEY (`itemId`) REFERENCES `items`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "access_subject" CHECK(("__new_item_access"."guestId" IS NOT NULL) + ("__new_item_access"."userId" IS NOT NULL) = 1)
);
--> statement-breakpoint
INSERT INTO `__new_item_access`("id", "itemId", "userId", "guestId", "role", "read", "deletedAt", "favorite") SELECT "id", "itemId", NULL, "guestId", "role", "read", "deletedAt", 0 FROM `item_access`;--> statement-breakpoint
DROP TABLE `item_access`;--> statement-breakpoint
ALTER TABLE `__new_item_access` RENAME TO `item_access`;--> statement-breakpoint
CREATE UNIQUE INDEX `access_subject_role` ON `item_access` (`itemId`,`guestId`,`role`);--> statement-breakpoint
CREATE UNIQUE INDEX `access_account_role` ON `item_access` (`itemId`,`userId`,`role`);--> statement-breakpoint
CREATE INDEX `access_account` ON `item_access` (`userId`,`deletedAt`);--> statement-breakpoint
CREATE INDEX `access_guest` ON `item_access` (`guestId`,`deletedAt`);--> statement-breakpoint
CREATE TABLE `__new_deletion_operations` (
`id` text PRIMARY KEY NOT NULL,
`userId` text,
`guestId` text,
`undoUntil` integer NOT NULL,
`createdAt` integer NOT NULL,
`restoredAt` integer,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "deletion_subject" CHECK(("__new_deletion_operations"."guestId" IS NOT NULL) + ("__new_deletion_operations"."userId" IS NOT NULL) = 1)
);
--> statement-breakpoint
INSERT INTO `__new_deletion_operations`("id", "userId", "guestId", "undoUntil", "createdAt", "restoredAt") SELECT "id", NULL, "guestId", "undoUntil", "createdAt", "restoredAt" FROM `deletion_operations`;--> statement-breakpoint
DROP TABLE `deletion_operations`;--> statement-breakpoint
ALTER TABLE `__new_deletion_operations` RENAME TO `deletion_operations`;--> statement-breakpoint
CREATE TABLE `__new_files` (
`id` text PRIMARY KEY NOT NULL,
`requestId` text NOT NULL,
`ownerGuestId` text,
`ownerUserId` text,
`position` integer NOT NULL,
`storageKey` text NOT NULL,
`name` text NOT NULL,
`type` text NOT NULL,
`size` integer NOT NULL,
`checksum` text,
`status` text NOT NULL,
`uploadId` text,
`uploadKey` text,
`updatedAt` integer NOT NULL,
FOREIGN KEY (`requestId`) REFERENCES `transfer_requests`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`ownerGuestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`ownerUserId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "file_nonnegative_size" CHECK("__new_files"."size" >= 0),
CONSTRAINT "file_owner_subject" CHECK(("__new_files"."ownerGuestId" IS NOT NULL) + ("__new_files"."ownerUserId" IS NOT NULL) = 1)
);
--> statement-breakpoint
INSERT INTO `__new_files`("id", "requestId", "ownerGuestId", "ownerUserId", "position", "storageKey", "name", "type", "size", "checksum", "status", "uploadId", "uploadKey", "updatedAt") SELECT "id", "requestId", "ownerGuestId", NULL, "position", "storageKey", "name", "type", "size", "checksum", "status", "uploadId", "uploadKey", "updatedAt" FROM `files`;--> statement-breakpoint
DROP TABLE `files`;--> statement-breakpoint
ALTER TABLE `__new_files` RENAME TO `files`;--> statement-breakpoint
CREATE UNIQUE INDEX `files_storageKey_unique` ON `files` (`storageKey`);--> statement-breakpoint
CREATE UNIQUE INDEX `request_file_position` ON `files` (`requestId`,`position`);--> statement-breakpoint
CREATE INDEX `files_owner_state` ON `files` (`ownerGuestId`,`status`);--> statement-breakpoint
CREATE TABLE `__new_idempotency_records` (
`id` text PRIMARY KEY NOT NULL,
`userId` text,
`guestId` text,
`operation` text NOT NULL,
`key` text NOT NULL,
`payloadHash` text NOT NULL,
`response` text NOT NULL,
`createdAt` integer NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "idempotency_subject" CHECK(("__new_idempotency_records"."guestId" IS NOT NULL) + ("__new_idempotency_records"."userId" IS NOT NULL) = 1)
);
--> statement-breakpoint
INSERT INTO `__new_idempotency_records`("id", "userId", "guestId", "operation", "key", "payloadHash", "response", "createdAt") SELECT "id", NULL, "guestId", "operation", "key", "payloadHash", "response", "createdAt" FROM `idempotency_records`;--> statement-breakpoint
DROP TABLE `idempotency_records`;--> statement-breakpoint
ALTER TABLE `__new_idempotency_records` RENAME TO `idempotency_records`;--> statement-breakpoint
CREATE UNIQUE INDEX `idempotency_scope` ON `idempotency_records` (`guestId`,`operation`,`key`);--> statement-breakpoint
CREATE UNIQUE INDEX `account_idempotency_scope` ON `idempotency_records` (`userId`,`operation`,`key`);--> statement-breakpoint
CREATE TABLE `__new_quota_reservations` (
`id` text PRIMARY KEY NOT NULL,
`fileId` text NOT NULL,
`userId` text,
`guestId` text,
`bytes` integer NOT NULL,
`expiresAt` integer NOT NULL,
FOREIGN KEY (`fileId`) REFERENCES `files`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "reservations_subject" CHECK(("__new_quota_reservations"."guestId" IS NOT NULL) + ("__new_quota_reservations"."userId" IS NOT NULL) = 1),
CONSTRAINT "reservation_nonnegative" CHECK("__new_quota_reservations"."bytes" >= 0)
);
--> statement-breakpoint
INSERT INTO `__new_quota_reservations`("id", "fileId", "userId", "guestId", "bytes", "expiresAt") SELECT "id", "fileId", NULL, "guestId", "bytes", "expiresAt" FROM `quota_reservations`;--> statement-breakpoint
DROP TABLE `quota_reservations`;--> statement-breakpoint
ALTER TABLE `__new_quota_reservations` RENAME TO `quota_reservations`;--> statement-breakpoint
CREATE UNIQUE INDEX `quota_reservations_fileId_unique` ON `quota_reservations` (`fileId`);--> statement-breakpoint
CREATE INDEX `quota_guest_expiry` ON `quota_reservations` (`guestId`,`expiresAt`);

View File

@@ -0,0 +1,17 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_deletion_operations` (
`id` text PRIMARY KEY NOT NULL,
`userId` text,
`guestId` text,
`undoUntil` integer NOT NULL,
`createdAt` integer NOT NULL,
`restoredAt` integer,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "deletion_subject" CHECK(("__new_deletion_operations"."guestId" IS NOT NULL) + ("__new_deletion_operations"."userId" IS NOT NULL) = 1)
);
--> statement-breakpoint
INSERT INTO `__new_deletion_operations`("id", "userId", "guestId", "undoUntil", "createdAt", "restoredAt") SELECT "id", "userId", "guestId", "undoUntil", "createdAt", "restoredAt" FROM `deletion_operations`;--> statement-breakpoint
DROP TABLE `deletion_operations`;--> statement-breakpoint
ALTER TABLE `__new_deletion_operations` RENAME TO `deletion_operations`;--> statement-breakpoint
PRAGMA foreign_keys=ON;

View File

@@ -0,0 +1,3 @@
UPDATE transfer_requests SET status = 'cancelled' WHERE kind = 'text' AND status IN ('pending','accepted') AND EXISTS (SELECT 1 FROM transfer_batches b WHERE b.requestId = transfer_requests.id AND b.status IN ('waiting','uploading'));
--> statement-breakpoint
UPDATE transfer_batches SET status = 'failed' WHERE status IN ('waiting','uploading') AND EXISTS (SELECT 1 FROM transfer_requests r WHERE r.id = transfer_batches.requestId AND r.kind = 'text');

View File

@@ -0,0 +1,21 @@
CREATE TABLE `request_receipt_accounts` (
`requestId` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
`sessionId` text NOT NULL,
FOREIGN KEY (`requestId`) REFERENCES `transfer_requests`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`sessionId`) REFERENCES `account_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `vault_transfers` (
`requestId` text PRIMARY KEY NOT NULL,
`accessId` text NOT NULL,
`userId` text NOT NULL,
`sessionId` text NOT NULL,
FOREIGN KEY (`requestId`) REFERENCES `transfer_requests`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`accessId`) REFERENCES `item_access`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`sessionId`) REFERENCES `account_sessions`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
ALTER TABLE `item_access` ADD `note` text;

View File

@@ -0,0 +1,10 @@
-- Custom SQL migration file, put your code below! --
UPDATE items SET expiresAt = min(expiresAt, CAST(strftime('%s', 'now') AS INTEGER) * 1000 + 604800000);
--> statement-breakpoint
UPDATE item_access SET favorite = 0;
--> statement-breakpoint
UPDATE transfer_requests SET status = 'cancelled' WHERE mode = 'email' AND senderUserId <> recipientUserId AND status IN ('pending', 'accepted') AND id IN (SELECT requestId FROM transfer_batches WHERE status <> 'stored');
--> statement-breakpoint
UPDATE transfer_batches SET status = 'failed' WHERE requestId IN (SELECT id FROM transfer_requests WHERE mode = 'email' AND senderUserId <> recipientUserId AND status = 'cancelled');
--> statement-breakpoint
DELETE FROM quota_reservations WHERE fileId IN (SELECT files.id FROM files INNER JOIN transfer_requests ON files.requestId = transfer_requests.id WHERE transfer_requests.mode = 'email' AND transfer_requests.senderUserId <> transfer_requests.recipientUserId AND transfer_requests.status = 'cancelled');

View File

@@ -0,0 +1 @@
ALTER TABLE `transfer_requests` ADD `note` text;

View File

@@ -0,0 +1,7 @@
UPDATE space_members SET status = 'removed' WHERE spaceId IN (SELECT id FROM connection_spaces WHERE closedAt IS NOT NULL OR expiresAt <= CAST(strftime('%s','now') AS INTEGER)*1000);
--> statement-breakpoint
UPDATE space_members AS member SET status = 'removed' WHERE status IN ('pending','approved') AND EXISTS (SELECT 1 FROM space_members newer WHERE newer.deviceId = member.deviceId AND newer.status IN ('pending','approved') AND (newer.joinedAt > member.joinedAt OR (newer.joinedAt = member.joinedAt AND newer.id > member.id)));
--> statement-breakpoint
UPDATE connection_spaces SET closedAt = CAST(strftime('%s','now') AS INTEGER)*1000 WHERE closedAt IS NULL AND NOT EXISTS (SELECT 1 FROM space_members m INNER JOIN browser_devices d ON d.id = m.deviceId WHERE m.spaceId = connection_spaces.id AND m.status = 'approved' AND d.guestId = connection_spaces.creatorGuestId);
--> statement-breakpoint
UPDATE space_members SET status = 'removed' WHERE spaceId IN (SELECT id FROM connection_spaces WHERE closedAt IS NOT NULL);

View File

@@ -0,0 +1 @@
CREATE UNIQUE INDEX `member_single_active_device` ON `space_members` (`deviceId`) WHERE "space_members"."status" IN ('pending', 'approved');

View File

@@ -0,0 +1,894 @@
{
"version": "6",
"dialect": "sqlite",
"id": "11892dda-406f-413c-ba07-9b439d0549db",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"item_access": {
"name": "item_access",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"itemId": {
"name": "itemId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"read": {
"name": "read",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"deletedAt": {
"name": "deletedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"access_subject_role": {
"name": "access_subject_role",
"columns": [
"itemId",
"guestId",
"role"
],
"isUnique": true
},
"access_guest": {
"name": "access_guest",
"columns": [
"guestId",
"deletedAt"
],
"isUnique": false
}
},
"foreignKeys": {
"item_access_itemId_items_id_fk": {
"name": "item_access_itemId_items_id_fk",
"tableFrom": "item_access",
"tableTo": "items",
"columnsFrom": [
"itemId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"item_access_guestId_guest_sessions_id_fk": {
"name": "item_access_guestId_guest_sessions_id_fk",
"tableFrom": "item_access",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"transfer_batches": {
"name": "transfer_batches",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requestId": {
"name": "requestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"storedAt": {
"name": "storedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"transfer_batches_requestId_unique": {
"name": "transfer_batches_requestId_unique",
"columns": [
"requestId"
],
"isUnique": true
}
},
"foreignKeys": {
"transfer_batches_requestId_transfer_requests_id_fk": {
"name": "transfer_batches_requestId_transfer_requests_id_fk",
"tableFrom": "transfer_batches",
"tableTo": "transfer_requests",
"columnsFrom": [
"requestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"guest_blocks": {
"name": "guest_blocks",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"targetGuestId": {
"name": "targetGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"guest_block_pair": {
"name": "guest_block_pair",
"columns": [
"guestId",
"targetGuestId"
],
"isUnique": true
}
},
"foreignKeys": {
"guest_blocks_guestId_guest_sessions_id_fk": {
"name": "guest_blocks_guestId_guest_sessions_id_fk",
"tableFrom": "guest_blocks",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"guest_blocks_targetGuestId_guest_sessions_id_fk": {
"name": "guest_blocks_targetGuestId_guest_sessions_id_fk",
"tableFrom": "guest_blocks",
"tableTo": "guest_sessions",
"columnsFrom": [
"targetGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"browser_devices": {
"name": "browser_devices",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"discoverable": {
"name": "discoverable",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
},
"lastSeen": {
"name": "lastSeen",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"browser_devices_guestId_unique": {
"name": "browser_devices_guestId_unique",
"columns": [
"guestId"
],
"isUnique": true
},
"browser_devices_code_unique": {
"name": "browser_devices_code_unique",
"columns": [
"code"
],
"isUnique": true
}
},
"foreignKeys": {
"browser_devices_guestId_guest_sessions_id_fk": {
"name": "browser_devices_guestId_guest_sessions_id_fk",
"tableFrom": "browser_devices",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"device_name_length": {
"name": "device_name_length",
"value": "length(\"browser_devices\".\"name\") between 1 and 40"
}
}
},
"guest_sessions": {
"name": "guest_sessions",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"tokenHash": {
"name": "tokenHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"revokedAt": {
"name": "revokedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"guest_sessions_tokenHash_unique": {
"name": "guest_sessions_tokenHash_unique",
"columns": [
"tokenHash"
],
"isUnique": true
},
"guest_expiry": {
"name": "guest_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"idempotency_records": {
"name": "idempotency_records",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"operation": {
"name": "operation",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"key": {
"name": "key",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"payloadHash": {
"name": "payloadHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"response": {
"name": "response",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idempotency_scope": {
"name": "idempotency_scope",
"columns": [
"guestId",
"operation",
"key"
],
"isUnique": true
}
},
"foreignKeys": {
"idempotency_records_guestId_guest_sessions_id_fk": {
"name": "idempotency_records_guestId_guest_sessions_id_fk",
"tableFrom": "idempotency_records",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"items": {
"name": "items",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"batchId": {
"name": "batchId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"text": {
"name": "text",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"items_expiry": {
"name": "items_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"items_batchId_transfer_batches_id_fk": {
"name": "items_batchId_transfer_batches_id_fk",
"tableFrom": "items",
"tableTo": "transfer_batches",
"columnsFrom": [
"batchId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"item_payload": {
"name": "item_payload",
"value": "(\"items\".\"kind\" = 'text' AND \"items\".\"text\" IS NOT NULL AND \"items\".\"url\" IS NULL) OR (\"items\".\"kind\" = 'url' AND \"items\".\"url\" IS NOT NULL AND \"items\".\"text\" IS NULL)"
}
}
},
"space_members": {
"name": "space_members",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"spaceId": {
"name": "spaceId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"deviceId": {
"name": "deviceId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"joinedAt": {
"name": "joinedAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"space_device": {
"name": "space_device",
"columns": [
"spaceId",
"deviceId"
],
"isUnique": true
}
},
"foreignKeys": {
"space_members_spaceId_connection_spaces_id_fk": {
"name": "space_members_spaceId_connection_spaces_id_fk",
"tableFrom": "space_members",
"tableTo": "connection_spaces",
"columnsFrom": [
"spaceId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"space_members_deviceId_browser_devices_id_fk": {
"name": "space_members_deviceId_browser_devices_id_fk",
"tableFrom": "space_members",
"tableTo": "browser_devices",
"columnsFrom": [
"deviceId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"transfer_requests": {
"name": "transfer_requests",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"mode": {
"name": "mode",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'local'"
},
"senderGuestId": {
"name": "senderGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"recipientGuestId": {
"name": "recipientGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"byteSize": {
"name": "byteSize",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"count": {
"name": "count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"acceptedAt": {
"name": "acceptedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"startBy": {
"name": "startBy",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"requests_sender_time": {
"name": "requests_sender_time",
"columns": [
"senderGuestId",
"createdAt"
],
"isUnique": false
},
"requests_recipient_time": {
"name": "requests_recipient_time",
"columns": [
"recipientGuestId",
"createdAt"
],
"isUnique": false
},
"requests_expiry": {
"name": "requests_expiry",
"columns": [
"status",
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"transfer_requests_senderGuestId_guest_sessions_id_fk": {
"name": "transfer_requests_senderGuestId_guest_sessions_id_fk",
"tableFrom": "transfer_requests",
"tableTo": "guest_sessions",
"columnsFrom": [
"senderGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"transfer_requests_recipientGuestId_guest_sessions_id_fk": {
"name": "transfer_requests_recipientGuestId_guest_sessions_id_fk",
"tableFrom": "transfer_requests",
"tableTo": "guest_sessions",
"columnsFrom": [
"recipientGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"request_different_guests": {
"name": "request_different_guests",
"value": "\"transfer_requests\".\"senderGuestId\" <> \"transfer_requests\".\"recipientGuestId\""
}
}
},
"connection_spaces": {
"name": "connection_spaces",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"creatorGuestId": {
"name": "creatorGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tokenHash": {
"name": "tokenHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"codeHash": {
"name": "codeHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"approvalRequired": {
"name": "approvalRequired",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"closedAt": {
"name": "closedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"connection_spaces_tokenHash_unique": {
"name": "connection_spaces_tokenHash_unique",
"columns": [
"tokenHash"
],
"isUnique": true
},
"connection_spaces_codeHash_unique": {
"name": "connection_spaces_codeHash_unique",
"columns": [
"codeHash"
],
"isUnique": true
},
"space_expiry": {
"name": "space_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"connection_spaces_creatorGuestId_guest_sessions_id_fk": {
"name": "connection_spaces_creatorGuestId_guest_sessions_id_fk",
"tableFrom": "connection_spaces",
"tableTo": "guest_sessions",
"columnsFrom": [
"creatorGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@@ -0,0 +1,901 @@
{
"version": "6",
"dialect": "sqlite",
"id": "583c8a7b-3fe7-47d9-b150-a93d5a7d8de3",
"prevId": "11892dda-406f-413c-ba07-9b439d0549db",
"tables": {
"item_access": {
"name": "item_access",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"itemId": {
"name": "itemId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"read": {
"name": "read",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"deletedAt": {
"name": "deletedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"access_subject_role": {
"name": "access_subject_role",
"columns": [
"itemId",
"guestId",
"role"
],
"isUnique": true
},
"access_guest": {
"name": "access_guest",
"columns": [
"guestId",
"deletedAt"
],
"isUnique": false
}
},
"foreignKeys": {
"item_access_itemId_items_id_fk": {
"name": "item_access_itemId_items_id_fk",
"tableFrom": "item_access",
"tableTo": "items",
"columnsFrom": [
"itemId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"item_access_guestId_guest_sessions_id_fk": {
"name": "item_access_guestId_guest_sessions_id_fk",
"tableFrom": "item_access",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"transfer_batches": {
"name": "transfer_batches",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requestId": {
"name": "requestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"storedAt": {
"name": "storedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"transfer_batches_requestId_unique": {
"name": "transfer_batches_requestId_unique",
"columns": [
"requestId"
],
"isUnique": true
}
},
"foreignKeys": {
"transfer_batches_requestId_transfer_requests_id_fk": {
"name": "transfer_batches_requestId_transfer_requests_id_fk",
"tableFrom": "transfer_batches",
"tableTo": "transfer_requests",
"columnsFrom": [
"requestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"guest_blocks": {
"name": "guest_blocks",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"targetGuestId": {
"name": "targetGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"guest_block_pair": {
"name": "guest_block_pair",
"columns": [
"guestId",
"targetGuestId"
],
"isUnique": true
}
},
"foreignKeys": {
"guest_blocks_guestId_guest_sessions_id_fk": {
"name": "guest_blocks_guestId_guest_sessions_id_fk",
"tableFrom": "guest_blocks",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"guest_blocks_targetGuestId_guest_sessions_id_fk": {
"name": "guest_blocks_targetGuestId_guest_sessions_id_fk",
"tableFrom": "guest_blocks",
"tableTo": "guest_sessions",
"columnsFrom": [
"targetGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"browser_devices": {
"name": "browser_devices",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"discoverable": {
"name": "discoverable",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": true
},
"lastSeen": {
"name": "lastSeen",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"browser_devices_guestId_unique": {
"name": "browser_devices_guestId_unique",
"columns": [
"guestId"
],
"isUnique": true
},
"browser_devices_code_unique": {
"name": "browser_devices_code_unique",
"columns": [
"code"
],
"isUnique": true
}
},
"foreignKeys": {
"browser_devices_guestId_guest_sessions_id_fk": {
"name": "browser_devices_guestId_guest_sessions_id_fk",
"tableFrom": "browser_devices",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"device_name_length": {
"name": "device_name_length",
"value": "length(\"browser_devices\".\"name\") between 1 and 40"
}
}
},
"guest_sessions": {
"name": "guest_sessions",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"tokenHash": {
"name": "tokenHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"revokedAt": {
"name": "revokedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"guest_sessions_tokenHash_unique": {
"name": "guest_sessions_tokenHash_unique",
"columns": [
"tokenHash"
],
"isUnique": true
},
"guest_expiry": {
"name": "guest_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"idempotency_records": {
"name": "idempotency_records",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"guestId": {
"name": "guestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"operation": {
"name": "operation",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"key": {
"name": "key",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"payloadHash": {
"name": "payloadHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"response": {
"name": "response",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idempotency_scope": {
"name": "idempotency_scope",
"columns": [
"guestId",
"operation",
"key"
],
"isUnique": true
}
},
"foreignKeys": {
"idempotency_records_guestId_guest_sessions_id_fk": {
"name": "idempotency_records_guestId_guest_sessions_id_fk",
"tableFrom": "idempotency_records",
"tableTo": "guest_sessions",
"columnsFrom": [
"guestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"items": {
"name": "items",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"batchId": {
"name": "batchId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"text": {
"name": "text",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"items_expiry": {
"name": "items_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"items_batchId_transfer_batches_id_fk": {
"name": "items_batchId_transfer_batches_id_fk",
"tableFrom": "items",
"tableTo": "transfer_batches",
"columnsFrom": [
"batchId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"item_payload": {
"name": "item_payload",
"value": "(\"items\".\"kind\" = 'text' AND \"items\".\"text\" IS NOT NULL AND \"items\".\"url\" IS NULL) OR (\"items\".\"kind\" = 'url' AND \"items\".\"url\" IS NOT NULL AND \"items\".\"text\" IS NULL)"
}
}
},
"space_members": {
"name": "space_members",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"spaceId": {
"name": "spaceId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"deviceId": {
"name": "deviceId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"joinedAt": {
"name": "joinedAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"space_device": {
"name": "space_device",
"columns": [
"spaceId",
"deviceId"
],
"isUnique": true
}
},
"foreignKeys": {
"space_members_spaceId_connection_spaces_id_fk": {
"name": "space_members_spaceId_connection_spaces_id_fk",
"tableFrom": "space_members",
"tableTo": "connection_spaces",
"columnsFrom": [
"spaceId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"space_members_deviceId_browser_devices_id_fk": {
"name": "space_members_deviceId_browser_devices_id_fk",
"tableFrom": "space_members",
"tableTo": "browser_devices",
"columnsFrom": [
"deviceId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"transfer_requests": {
"name": "transfer_requests",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"mode": {
"name": "mode",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'local'"
},
"senderGuestId": {
"name": "senderGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"recipientGuestId": {
"name": "recipientGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"kind": {
"name": "kind",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"byteSize": {
"name": "byteSize",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"count": {
"name": "count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"acceptedAt": {
"name": "acceptedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"rejectedAt": {
"name": "rejectedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"startBy": {
"name": "startBy",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"requests_sender_time": {
"name": "requests_sender_time",
"columns": [
"senderGuestId",
"createdAt"
],
"isUnique": false
},
"requests_recipient_time": {
"name": "requests_recipient_time",
"columns": [
"recipientGuestId",
"createdAt"
],
"isUnique": false
},
"requests_expiry": {
"name": "requests_expiry",
"columns": [
"status",
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"transfer_requests_senderGuestId_guest_sessions_id_fk": {
"name": "transfer_requests_senderGuestId_guest_sessions_id_fk",
"tableFrom": "transfer_requests",
"tableTo": "guest_sessions",
"columnsFrom": [
"senderGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"transfer_requests_recipientGuestId_guest_sessions_id_fk": {
"name": "transfer_requests_recipientGuestId_guest_sessions_id_fk",
"tableFrom": "transfer_requests",
"tableTo": "guest_sessions",
"columnsFrom": [
"recipientGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {
"request_different_guests": {
"name": "request_different_guests",
"value": "\"transfer_requests\".\"senderGuestId\" <> \"transfer_requests\".\"recipientGuestId\""
}
}
},
"connection_spaces": {
"name": "connection_spaces",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"creatorGuestId": {
"name": "creatorGuestId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tokenHash": {
"name": "tokenHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"codeHash": {
"name": "codeHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"approvalRequired": {
"name": "approvalRequired",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"closedAt": {
"name": "closedAt",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"connection_spaces_tokenHash_unique": {
"name": "connection_spaces_tokenHash_unique",
"columns": [
"tokenHash"
],
"isUnique": true
},
"connection_spaces_codeHash_unique": {
"name": "connection_spaces_codeHash_unique",
"columns": [
"codeHash"
],
"isUnique": true
},
"space_expiry": {
"name": "space_expiry",
"columns": [
"expiresAt"
],
"isUnique": false
}
},
"foreignKeys": {
"connection_spaces_creatorGuestId_guest_sessions_id_fk": {
"name": "connection_spaces_creatorGuestId_guest_sessions_id_fk",
"tableFrom": "connection_spaces",
"tableTo": "guest_sessions",
"columnsFrom": [
"creatorGuestId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

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

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

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1791445972914,
"tag": "0000_aberrant_scourge",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1791447103463,
"tag": "0001_numerous_dust",
"breakpoints": true
},
{
"idx": 2,
"version": "6",
"when": 1791447352994,
"tag": "0002_orange_norrin_radd",
"breakpoints": true
},
{
"idx": 3,
"version": "6",
"when": 1791448071863,
"tag": "0003_spooky_blob",
"breakpoints": true
},
{
"idx": 4,
"version": "6",
"when": 1791449604794,
"tag": "0004_bright_wildside",
"breakpoints": true
},
{
"idx": 5,
"version": "6",
"when": 1791450987520,
"tag": "0005_tan_miracleman",
"breakpoints": true
},
{
"idx": 6,
"version": "6",
"when": 1791453590596,
"tag": "0006_file_url_only",
"breakpoints": true
},
{
"idx": 7,
"version": "6",
"when": 1791770452198,
"tag": "0007_rapid_morph",
"breakpoints": true
},
{
"idx": 8,
"version": "6",
"when": 1791770486677,
"tag": "0008_temporary-retention",
"breakpoints": true
},
{
"idx": 9,
"version": "6",
"when": 1791770606214,
"tag": "0009_vault-note",
"breakpoints": true
},
{
"idx": 10,
"version": "6",
"when": 1791771685461,
"tag": "0010_single-room",
"breakpoints": true
},
{
"idx": 11,
"version": "6",
"when": 1791771741603,
"tag": "0011_single-room-index",
"breakpoints": true
}
]
}