Files
sofa/packages/db/drizzle/20260303200504_ambiguous_korg/snapshot.json
T
jakeandClaude Opus 4.6 a326c968b7 Migrate web app from Next.js to Vite + TanStack Router SPA (#6)
* Convert to Turborepo monorepo with shared API contract package

Restructure the repository as a monorepo in preparation for adding
future clients (mobile app, CLI). Extract the oRPC contract and Zod
schemas into `@sofa/api` (packages/api/) as a JIT internal package,
and relocate the Next.js app to `@sofa/web` (apps/web/).

- Add Turborepo with Bun workspaces for task orchestration and caching
- Extract `contract.ts` and `schemas.ts` into `@sofa/api` package
- Move all app code, configs, tests, and migrations to `apps/web/`
- Update 17 import paths from `@/lib/orpc/schemas` to `@sofa/api/schemas`
- Add `outputFileTracingRoot` and `transpilePackages` to next.config.ts
- Rewrite Dockerfile with `turbo prune --docker` for efficient builds
- Update CI workflows to use `turbo run` for lint/check-types/test
- Update CLAUDE.md with monorepo structure and commands

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Extract standalone Hono API server and split shared packages

Separate all server-side concerns from the Next.js frontend into a new
`apps/server/` Hono app and dedicated shared packages, making `@sofa/web`
a frontend-only app with no direct DB or service access.

- Add `@sofa/server` (`apps/server/`) — Hono API on port 3001 hosting
  oRPC procedures, Better Auth, cron jobs, and non-RPC routes
- Add `@sofa/core` (`packages/core/`) — All 15 business logic services
  moved from `apps/web/lib/services/`; tests moved to `packages/core/test/`
- Add `@sofa/db` (`packages/db/`) — DB client, schema, migrations,
  constants, and logger extracted from `apps/web/lib/db/` and `lib/`
- Add `@sofa/tmdb` (`packages/tmdb/`) — TMDB client and image helpers
  moved from `apps/web/lib/tmdb/`
- Add `@sofa/auth` (`packages/auth/`) — Better Auth server config moved
  from `apps/web/lib/auth/`
- Move oRPC procedures, handler, router, middleware to `apps/server/src/orpc/`
- Move Hono route handlers (avatars, backups, images, lists, webhooks,
  health) to `apps/server/src/routes/`; delete equivalent Next.js API routes
- Strip `apps/web` to frontend-only: no DB imports, no service imports,
  all data via oRPC client calls to the API server
- Add `entrypoint.sh` to start API server, wait for health, then Next.js
- Update `next.config.ts` rewrites to proxy `/rpc/*` and `/api/*` to
  `INTERNAL_API_URL` (default `http://localhost:3001`)
- Update Dockerfile and CLAUDE.md for the new structure

* Migrate web app from Next.js to Vite + TanStack Router SPA and add workspace catalog

Replace Next.js with a pure Vite SPA using TanStack Router for file-based routing,
removing all SSR complexity. The API server (Hono) now serves both API routes and
SPA static files in production, simplifying Docker to a single-process container.

Key changes:
- Vite 7 + @tanstack/react-router with file-based routing via plugin
- Route guards via beforeLoad + authClient.getSession() (replaces server-side auth)
- Route loaders with queryClient.ensureQueryData() (replaces SSR data fetching)
- Self-hosted fonts via @fontsource (replaces next/font/google)
- Tailwind v4 via @tailwindcss/vite (replaces @tailwindcss/postcss)
- Single oRPC client (removed SSR client and server-side session helper)
- Hono serves SPA static files in production (single port 3000)
- Single-process Dockerfile (removed entrypoint.sh)
- Bun workspace catalog for centralized dependency version management

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Extract @sofa/logger and @sofa/config shared packages

- Add `@sofa/logger` (`packages/logger/`) — standalone logger package
  extracted from `@sofa/db/logger`; update all imports across server,
  core, auth, db, and tmdb packages
- Add `@sofa/config` (`packages/config/`) — standalone config/constants
  package extracted from `@sofa/db/constants`; exports `DATA_DIR`,
  `DATABASE_URL`, `CACHE_DIR`, `AVATAR_DIR`, `BACKUP_DIR`
- Move `.env.example` from `apps/web/` to repo root; update server dev
  scripts to load it via `--env-file=../../.env`
- Move image serving from `/api/images` to `/images`; add `serveStatic`
  fast path in `index.ts` for cached files before falling back to the
  TMDB fetch route; add `/images` proxy to Vite dev config
- Fix `Sparkline` component: replace `ResponsiveContainer` with
  `ResizeObserver` to avoid SSR/hydration issues with recharts
- Replace `VITE_SERVER_URL` env var with `window.location.origin` in
  the oRPC client (always same-origin in both dev and production)

* Fix asset caching, SPA 404 fallback, and DATA_DIR resolution

- Add `Cache-Control: immutable` header for hashed `/assets/*` files;
  return 404 for missing asset paths instead of falling back to
  `index.html` (prevents serving stale chunks after deploy)
- Wrap `query.invalidate` in an arrow function in the oRPC QueryClient
  error handler to avoid illegal invocation errors
- Resolve `DATA_DIR` to an absolute path via `path.resolve()` so
  relative paths work regardless of the process working directory

* Migrate @sofa/logger to pino for structured logging

- Replace custom logger implementation in `packages/logger/` with pino
  + pino-pretty; add both as workspace catalog dependencies
- Add `pino` and `pino-pretty` to the workspace catalog in `package.json`
- Fix `log.error()` calls in oRPC and OpenAPI handlers to pass the
  error directly instead of wrapping it in `{ error }` to match pino's
  serializer expectations

* Rename discoverProcedure/statsProcedure exports to discover/stats

* Add TanStackDevtools unified panel and VS Code workspace config

- Replace separate Router/Query devtools with unified `TanStackDevtools`
  from `@tanstack/react-devtools` + `@tanstack/devtools-vite` plugin
- Wrap app in `<StrictMode>` in `main.tsx`
- Add `.vscode/settings.json` (Biome formatter, format-on-save, readonly
  `routeTree.gen.ts`) and `.vscode/extensions.json` (recommended extensions)

* Move test DB helpers to @sofa/db/test-utils and add root bunfig.toml

Extract in-memory SQLite setup and fixture helpers (insertUser, insertTitle,
etc.) from packages/core/test/sqlite.ts into packages/db/src/test-utils.ts
so DB test utilities live alongside the schema they depend on. Use
import.meta.dir for CWD-independent migration path resolution.

Add root bunfig.toml so `bun test` works from the repo root in addition
to `bun run test` (turbo).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix devtools plugin order and whitespace-only TMDB token check

Move devtools() to first position in Vite plugins array per TanStack
docs, and trim TMDB_API_READ_ACCESS_TOKEN before boolean coercion so
whitespace-only values are treated as unconfigured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:50:34 -04:00

1871 lines
41 KiB
JSON

{
"version": "7",
"dialect": "sqlite",
"id": "df501e82-b113-4048-9b80-14b0c37b6b1f",
"prevIds": ["0d9a9bb2-878a-4c48-9e48-b7f17b7cc54a"],
"ddl": [
{
"name": "account",
"entityType": "tables"
},
{
"name": "appSettings",
"entityType": "tables"
},
{
"name": "availabilityOffers",
"entityType": "tables"
},
{
"name": "episodes",
"entityType": "tables"
},
{
"name": "seasons",
"entityType": "tables"
},
{
"name": "session",
"entityType": "tables"
},
{
"name": "titleRecommendations",
"entityType": "tables"
},
{
"name": "titles",
"entityType": "tables"
},
{
"name": "user",
"entityType": "tables"
},
{
"name": "userEpisodeWatches",
"entityType": "tables"
},
{
"name": "userMovieWatches",
"entityType": "tables"
},
{
"name": "userRatings",
"entityType": "tables"
},
{
"name": "userTitleStatus",
"entityType": "tables"
},
{
"name": "verification",
"entityType": "tables"
},
{
"name": "webhookConnections",
"entityType": "tables"
},
{
"name": "webhookEventLog",
"entityType": "tables"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "accountId",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "providerId",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "accessToken",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "refreshToken",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "idToken",
"entityType": "columns",
"table": "account"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "accessTokenExpiresAt",
"entityType": "columns",
"table": "account"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "refreshTokenExpiresAt",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "scope",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "password",
"entityType": "columns",
"table": "account"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "createdAt",
"entityType": "columns",
"table": "account"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "updatedAt",
"entityType": "columns",
"table": "account"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "key",
"entityType": "columns",
"table": "appSettings"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "value",
"entityType": "columns",
"table": "appSettings"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": "'US'",
"generated": null,
"name": "region",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "providerId",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "providerName",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "logoPath",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "offerType",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "link",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "lastFetchedAt",
"entityType": "columns",
"table": "availabilityOffers"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "seasonId",
"entityType": "columns",
"table": "episodes"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "episodeNumber",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "name",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "overview",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "stillPath",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "airDate",
"entityType": "columns",
"table": "episodes"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "runtimeMinutes",
"entityType": "columns",
"table": "episodes"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "seasons"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "seasonNumber",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "name",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "overview",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "posterPath",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "airDate",
"entityType": "columns",
"table": "seasons"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "lastFetchedAt",
"entityType": "columns",
"table": "seasons"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "token",
"entityType": "columns",
"table": "session"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "expiresAt",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "ipAddress",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userAgent",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "impersonatedBy",
"entityType": "columns",
"table": "session"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "createdAt",
"entityType": "columns",
"table": "session"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "updatedAt",
"entityType": "columns",
"table": "session"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "titleRecommendations"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "recommendedTitleId",
"entityType": "columns",
"table": "titleRecommendations"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "source",
"entityType": "columns",
"table": "titleRecommendations"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "rank",
"entityType": "columns",
"table": "titleRecommendations"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "lastFetchedAt",
"entityType": "columns",
"table": "titleRecommendations"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "titles"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "tmdbId",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "type",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "title",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "originalTitle",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "overview",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "releaseDate",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "firstAirDate",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "posterPath",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "backdropPath",
"entityType": "columns",
"table": "titles"
},
{
"type": "real",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "popularity",
"entityType": "columns",
"table": "titles"
},
{
"type": "real",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "voteAverage",
"entityType": "columns",
"table": "titles"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "voteCount",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "status",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "colorPalette",
"entityType": "columns",
"table": "titles"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "lastFetchedAt",
"entityType": "columns",
"table": "titles"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "name",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "email",
"entityType": "columns",
"table": "user"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": "false",
"generated": null,
"name": "emailVerified",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "image",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": "'user'",
"generated": null,
"name": "role",
"entityType": "columns",
"table": "user"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": "false",
"generated": null,
"name": "banned",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "banReason",
"entityType": "columns",
"table": "user"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "banExpires",
"entityType": "columns",
"table": "user"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "createdAt",
"entityType": "columns",
"table": "user"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "updatedAt",
"entityType": "columns",
"table": "user"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "userEpisodeWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "userEpisodeWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "episodeId",
"entityType": "columns",
"table": "userEpisodeWatches"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "watchedAt",
"entityType": "columns",
"table": "userEpisodeWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": "'manual'",
"generated": null,
"name": "source",
"entityType": "columns",
"table": "userEpisodeWatches"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "userMovieWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "userMovieWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "userMovieWatches"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "watchedAt",
"entityType": "columns",
"table": "userMovieWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": "'manual'",
"generated": null,
"name": "source",
"entityType": "columns",
"table": "userMovieWatches"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "userRatings"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "userRatings"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "ratingStars",
"entityType": "columns",
"table": "userRatings"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "ratedAt",
"entityType": "columns",
"table": "userRatings"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "userTitleStatus"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "titleId",
"entityType": "columns",
"table": "userTitleStatus"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "status",
"entityType": "columns",
"table": "userTitleStatus"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "addedAt",
"entityType": "columns",
"table": "userTitleStatus"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "updatedAt",
"entityType": "columns",
"table": "userTitleStatus"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "verification"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "identifier",
"entityType": "columns",
"table": "verification"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "value",
"entityType": "columns",
"table": "verification"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "expiresAt",
"entityType": "columns",
"table": "verification"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "createdAt",
"entityType": "columns",
"table": "verification"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "updatedAt",
"entityType": "columns",
"table": "verification"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "userId",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "provider",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "token",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "mediaServerUsername",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": "true",
"generated": null,
"name": "enabled",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "createdAt",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "integer",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "lastEventAt",
"entityType": "columns",
"table": "webhookConnections"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "id",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "connectionId",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "eventType",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "mediaType",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "mediaTitle",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "status",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "text",
"notNull": false,
"autoincrement": false,
"default": null,
"generated": null,
"name": "errorMessage",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"type": "integer",
"notNull": true,
"autoincrement": false,
"default": null,
"generated": null,
"name": "receivedAt",
"entityType": "columns",
"table": "webhookEventLog"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_account_userId_user_id_fk",
"entityType": "fks",
"table": "account"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_availabilityOffers_titleId_titles_id_fk",
"entityType": "fks",
"table": "availabilityOffers"
},
{
"columns": ["seasonId"],
"tableTo": "seasons",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_episodes_seasonId_seasons_id_fk",
"entityType": "fks",
"table": "episodes"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_seasons_titleId_titles_id_fk",
"entityType": "fks",
"table": "seasons"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_session_userId_user_id_fk",
"entityType": "fks",
"table": "session"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_titleRecommendations_titleId_titles_id_fk",
"entityType": "fks",
"table": "titleRecommendations"
},
{
"columns": ["recommendedTitleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_titleRecommendations_recommendedTitleId_titles_id_fk",
"entityType": "fks",
"table": "titleRecommendations"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userEpisodeWatches_userId_user_id_fk",
"entityType": "fks",
"table": "userEpisodeWatches"
},
{
"columns": ["episodeId"],
"tableTo": "episodes",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userEpisodeWatches_episodeId_episodes_id_fk",
"entityType": "fks",
"table": "userEpisodeWatches"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userMovieWatches_userId_user_id_fk",
"entityType": "fks",
"table": "userMovieWatches"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userMovieWatches_titleId_titles_id_fk",
"entityType": "fks",
"table": "userMovieWatches"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userRatings_userId_user_id_fk",
"entityType": "fks",
"table": "userRatings"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userRatings_titleId_titles_id_fk",
"entityType": "fks",
"table": "userRatings"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userTitleStatus_userId_user_id_fk",
"entityType": "fks",
"table": "userTitleStatus"
},
{
"columns": ["titleId"],
"tableTo": "titles",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_userTitleStatus_titleId_titles_id_fk",
"entityType": "fks",
"table": "userTitleStatus"
},
{
"columns": ["userId"],
"tableTo": "user",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_webhookConnections_userId_user_id_fk",
"entityType": "fks",
"table": "webhookConnections"
},
{
"columns": ["connectionId"],
"tableTo": "webhookConnections",
"columnsTo": ["id"],
"onUpdate": "NO ACTION",
"onDelete": "CASCADE",
"nameExplicit": false,
"name": "fk_webhookEventLog_connectionId_webhookConnections_id_fk",
"entityType": "fks",
"table": "webhookEventLog"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "account_pk",
"table": "account",
"entityType": "pks"
},
{
"columns": ["key"],
"nameExplicit": false,
"name": "appSettings_pk",
"table": "appSettings",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "episodes_pk",
"table": "episodes",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "seasons_pk",
"table": "seasons",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "session_pk",
"table": "session",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "titles_pk",
"table": "titles",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "user_pk",
"table": "user",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "userEpisodeWatches_pk",
"table": "userEpisodeWatches",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "userMovieWatches_pk",
"table": "userMovieWatches",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "verification_pk",
"table": "verification",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "webhookConnections_pk",
"table": "webhookConnections",
"entityType": "pks"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "webhookEventLog_pk",
"table": "webhookEventLog",
"entityType": "pks"
},
{
"columns": [
{
"value": "titleId",
"isExpression": false
},
{
"value": "region",
"isExpression": false
},
{
"value": "providerId",
"isExpression": false
},
{
"value": "offerType",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "availabilityOffers_unique",
"entityType": "indexes",
"table": "availabilityOffers"
},
{
"columns": [
{
"value": "seasonId",
"isExpression": false
},
{
"value": "episodeNumber",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "episodes_seasonId_episodeNumber",
"entityType": "indexes",
"table": "episodes"
},
{
"columns": [
{
"value": "titleId",
"isExpression": false
},
{
"value": "seasonNumber",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "seasons_titleId_seasonNumber",
"entityType": "indexes",
"table": "seasons"
},
{
"columns": [
{
"value": "titleId",
"isExpression": false
},
{
"value": "recommendedTitleId",
"isExpression": false
},
{
"value": "source",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "titleRecommendations_unique",
"entityType": "indexes",
"table": "titleRecommendations"
},
{
"columns": [
{
"value": "tmdbId",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "titles_tmdbId_unique",
"entityType": "indexes",
"table": "titles"
},
{
"columns": [
{
"value": "type",
"isExpression": false
},
{
"value": "releaseDate",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "titles_type_releaseDate",
"entityType": "indexes",
"table": "titles"
},
{
"columns": [
{
"value": "type",
"isExpression": false
},
{
"value": "firstAirDate",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "titles_type_firstAirDate",
"entityType": "indexes",
"table": "titles"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "watchedAt",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "userEpisodeWatches_userId_watchedAt",
"entityType": "indexes",
"table": "userEpisodeWatches"
},
{
"columns": [
{
"value": "episodeId",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "userEpisodeWatches_episodeId",
"entityType": "indexes",
"table": "userEpisodeWatches"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "watchedAt",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "userMovieWatches_userId_watchedAt",
"entityType": "indexes",
"table": "userMovieWatches"
},
{
"columns": [
{
"value": "titleId",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "userMovieWatches_titleId",
"entityType": "indexes",
"table": "userMovieWatches"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "titleId",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "userRatings_userId_titleId",
"entityType": "indexes",
"table": "userRatings"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "titleId",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "userTitleStatus_userId_titleId",
"entityType": "indexes",
"table": "userTitleStatus"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "status",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "userTitleStatus_userId_status",
"entityType": "indexes",
"table": "userTitleStatus"
},
{
"columns": [
{
"value": "userId",
"isExpression": false
},
{
"value": "provider",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "webhookConnections_userId_provider",
"entityType": "indexes",
"table": "webhookConnections"
},
{
"columns": [
{
"value": "token",
"isExpression": false
}
],
"isUnique": true,
"where": null,
"origin": "manual",
"name": "webhookConnections_token",
"entityType": "indexes",
"table": "webhookConnections"
},
{
"columns": [
{
"value": "connectionId",
"isExpression": false
},
{
"value": "receivedAt",
"isExpression": false
}
],
"isUnique": false,
"where": null,
"origin": "manual",
"name": "webhookEventLog_connectionId_receivedAt",
"entityType": "indexes",
"table": "webhookEventLog"
},
{
"columns": ["token"],
"nameExplicit": false,
"name": "session_token_unique",
"entityType": "uniques",
"table": "session"
},
{
"columns": ["email"],
"nameExplicit": false,
"name": "user_email_unique",
"entityType": "uniques",
"table": "user"
}
],
"renames": []
}