Skip to content

Fresh install fails: DB tables never created in production mode #13

Description

@Thoroslives

Bug

Fresh installs with the Docker image (ghcr.io/navino16/librarr:latest or :develop) fail with SqliteError: no such table: user on every route. The setup wizard returns Internal Server Error when attempting to create an admin account.

Root Cause

In server/datasource.ts, the synchronize option is:

synchronize: isProduction ? false : synchronize,

When NODE_ENV=production (set by the Dockerfile), synchronize is always false regardless of DB_SYNCHRONIZE. The code falls through to use migrations instead, but no migration files ship with the image:

$ find /app/dist/server/migration -type f
(empty)

This means a fresh install in production mode can never create its database tables.

Steps to Reproduce

  1. docker compose up -d with the docker-compose from the docs
  2. Open http://localhost:5055
  3. Complete step 1 (admin account) → Internal Server Error
  4. Container logs show: SqliteError: no such table: user

Workaround

Temporarily set NODE_ENV=development and DB_SYNCHRONIZE=true to let TypeORM create the tables, then switch back to NODE_ENV=production (keeping DB_SYNCHRONIZE=true). The app crashes under NODE_ENV=development because Next.js standalone mode requires production, so you must switch back after the DB initializes.

Suggested Fix

Either:

  1. Ship migration files with the image so typeorm can run them on first start
  2. Change the synchronize logic to allow initial schema creation in production (e.g., sync if the DB is empty)
  3. Remove the isProduction guard: synchronize: synchronize — let DB_SYNCHRONIZE control it directly

Environment

  • Image: ghcr.io/navino16/librarr:latest and :develop
  • Docker, Unraid host
  • Node 24 Alpine base

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions