Skip to content

Implement dual SQLite/Supabase backend with runtime flag#7

Draft
lyncmi07 with Copilot wants to merge 5 commits into
masterfrom
copilot/change-database-to-supabase
Draft

Implement dual SQLite/Supabase backend with runtime flag#7
lyncmi07 with Copilot wants to merge 5 commits into
masterfrom
copilot/change-database-to-supabase

Conversation

Copilot AI commented Mar 28, 2026

Copy link
Copy Markdown

Implements the dual-backend database architecture outlined in the migration plan. The site can run using either SQLite or Supabase (PostgreSQL) based on the DB_BACKEND environment variable, defaulting to sqlite so existing tests and local development are unchanged.

Architecture

  • db_interface.ts — TypeScript interface declaring all 43 database functions as async
  • db_sqlite.ts — SQLite implementation extracted from original db.ts, wrapped in async
  • db_supabase.ts — Supabase implementation using @supabase/supabase-js with query builder, foreign key joins, and RPC calls for atomic operations
  • db.ts — Thin runtime dispatcher that selects the backend based on DB_BACKEND env var and re-exports all functions

Changes

  • All 6 caller files (index.ts, routes/auth.ts, routes/websites.ts, routes/git_websites.ts, routes/friends.ts, routes/messages.ts) updated to await all DB calls
  • PostgreSQL schema migration (supabase/migrations/001_initial.sql) with 10 tables, citext columns, and indexes
  • 5 PostgreSQL RPC functions (supabase/migrations/002_rpc_functions.sql) for atomic operations: accept_friend_request, remove_friend, set_website_tags, get_unread_counts, get_all_tags_with_counts
  • Added @supabase/supabase-js dependency
  • .env.example documenting DB_BACKEND, DB_PATH, SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY
  • Updated plan in plans/supabase_migration.md with all steps marked as completed

Testing

  • All 182 existing tests pass unchanged against the SQLite backend
  • CodeQL security scan: 0 alerts
  • No dependency vulnerabilities

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI requested a review from lyncmi07 March 28, 2026 20:10
@lyncmi07

Copy link
Copy Markdown
Member

@copilot complete the plan

Copilot AI and others added 3 commits March 28, 2026 20:33
…her, make all callers async

Agent-Logs-Url: https://github.com/TemporalResearch/social2000/sessions/0b9ee56d-8d53-493b-95c9-396636ed0d87

Co-authored-by: lyncmi07 <8515907+lyncmi07@users.noreply.github.com>
…olean conversion docs

Agent-Logs-Url: https://github.com/TemporalResearch/social2000/sessions/0b9ee56d-8d53-493b-95c9-396636ed0d87

Co-authored-by: lyncmi07 <8515907+lyncmi07@users.noreply.github.com>

Copilot AI commented Mar 28, 2026

Copy link
Copy Markdown
Author

@copilot complete the plan

Done in cbe6ea1. All 10 plan steps implemented:

  • db_interface.ts — 43-function async interface
  • db_sqlite.ts — extracted SQLite implementation
  • db_supabase.ts — full Supabase implementation with joins, RPC calls, and boolean normalization
  • db.ts — runtime dispatcher via DB_BACKEND env var (defaults to sqlite)
  • All 6 caller files updated with await
  • supabase/migrations/001_initial.sql — PostgreSQL schema (10 tables, indexes)
  • supabase/migrations/002_rpc_functions.sql — 5 RPC functions for atomic operations
  • .env.example — documents all env vars

All 182 existing tests pass unchanged against the SQLite backend.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /home/REDACTED/.bun/bin/bun bun run index.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add Supabase migration plan Implement dual SQLite/Supabase backend with runtime flag Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants