compassmock/drizzle/0021_early_cerise.sql
Nicholai 40fdf48cbf
feat: add conversations, desktop (Tauri), and offline sync (#81)
* feat: add conversations, desktop (Tauri), and offline sync

Major new features:
- conversations module: Slack-like channels, threads, reactions, pins
- Tauri desktop app with local SQLite for offline-first operation
- Hybrid logical clock sync engine with conflict resolution
- DB provider abstraction (D1/Tauri/memory) with React context

Conversations:
- Text/voice/announcement channels with categories
- Message threads, reactions, attachments, pinning
- Real-time presence and typing indicators
- Full-text search across messages

Desktop (Tauri):
- Local SQLite database with sync to cloud D1
- Offline mutation queue with automatic replay
- Window management and keyboard shortcuts
- Desktop shell with offline banner

Sync infrastructure:
- Vector clock implementation for causality tracking
- Last-write-wins with semantic conflict resolution
- Delta sync via checkpoints for bandwidth efficiency
- Comprehensive test coverage

Also adds e2e test setup with Playwright and CI workflows
for desktop releases.

* fix(tests): sync engine test schema and checkpoint logic

- Add missing process_after column and sync_tombstone table to test schemas
- Fix checkpoint update to save cursor even when records array is empty
- Revert claude-code-review.yml workflow changes to match main

---------

Co-authored-by: Nicholai <nicholaivogelfilms@gmail.com>
2026-02-14 19:32:14 -07:00

55 lines
2.4 KiB
SQL

CREATE TABLE `channel_categories` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`organization_id` text NOT NULL,
`position` integer DEFAULT 0 NOT NULL,
`collapsed_by_default` integer DEFAULT false,
`created_at` text NOT NULL,
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `typing_sessions` (
`id` text PRIMARY KEY NOT NULL,
`channel_id` text NOT NULL,
`user_id` text NOT NULL,
`started_at` text NOT NULL,
`expires_at` text NOT NULL,
FOREIGN KEY (`channel_id`) REFERENCES `channels`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `user_presence` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`status` text DEFAULT 'offline' NOT NULL,
`status_message` text,
`last_seen_at` text NOT NULL,
`updated_at` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_messages` (
`id` text PRIMARY KEY NOT NULL,
`channel_id` text NOT NULL,
`thread_id` text,
`user_id` text NOT NULL,
`content` text NOT NULL,
`content_html` text,
`edited_at` text,
`deleted_at` text,
`deleted_by` text,
`is_pinned` integer DEFAULT false NOT NULL,
`reply_count` integer DEFAULT 0 NOT NULL,
`last_reply_at` text,
`created_at` text NOT NULL,
FOREIGN KEY (`channel_id`) REFERENCES `channels`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`deleted_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_messages`("id", "channel_id", "thread_id", "user_id", "content", "content_html", "edited_at", "deleted_at", "deleted_by", "is_pinned", "reply_count", "last_reply_at", "created_at") SELECT "id", "channel_id", "thread_id", "user_id", "content", "content_html", "edited_at", "deleted_at", "deleted_by", "is_pinned", "reply_count", "last_reply_at", "created_at" FROM `messages`;--> statement-breakpoint
DROP TABLE `messages`;--> statement-breakpoint
ALTER TABLE `__new_messages` RENAME TO `messages`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
ALTER TABLE `channels` ADD `category_id` text REFERENCES channel_categories(id);