calcom / docker

The Docker configuration for Cal.com is an effort powered by people within the community. Cal.com, Inc. does not provide official support for Docker, but we will accept fixes and documentation. Use at your own risk.
MIT License
619 stars 323 forks source link

Table public.users does not exist #323

Open MarioNoll opened 5 months ago

MarioNoll commented 5 months ago

I had an active selfhosted instance running, that must have stopped working after an upgrade, opening the corresponding page to schedule an event returned a 500. Iirc logs sayed something along the lines of public.OutOfOfficeEntity does not exist. Now I'm trying to start from scratch using the latest version v3.7.11 but running into errors as well.

On container start I can see in the logs:

The table `public.App` does not exist in the current database.
    at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
    at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
    at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
    at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
    at async createApp (/calcom/packages/prisma/seed-app-store.ts:169:22)
    at async main (/calcom/packages/prisma/seed-app-store.ts:374:5) {
  code: 'P2021',
  clientVersion: '5.4.2',
  meta: { table: 'public.App' }
}
PrismaClientKnownRequestError: 
Invalid `prisma.app_RoutingForms_Form.findUnique()` invocation:

The table `public.App_RoutingForms_Form` does not exist in the current database.
    at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
    at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
    at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
    at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
    at async seedAppData (/calcom/packages/prisma/seed-app-store.ts:21:16)
    at async main (/calcom/packages/prisma/seed-app-store.ts:384:3) {
  code: 'P2021',
  clientVersion: '5.4.2',
  meta: { table: 'public.App_RoutingForms_Form' }
}

Opening the web url fails with a 500 from the logs:

@calcom/web:start: 11:54:54:357 ERROR[redactError] Error:  {"name":"PrismaClientKnownRequestError","code":"P2021","clientVersion":"5.4.2","meta":{"table":"public.Feature"}}
@calcom/web:start: PrismaClientKnownRequestError: 
@calcom/web:start: Invalid `prisma.user.count()` invocation:
@calcom/web:start: 
@calcom/web:start: 
@calcom/web:start: The table `public.users` does not exist in the current database.
@calcom/web:start:     at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
@calcom/web:start:     at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
@calcom/web:start:     at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
@calcom/web:start:     at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
@calcom/web:start:     at async getServerSideProps (/calcom/apps/web/.next/server/pages/auth/login.js:1:10204) {
@calcom/web:start:   code: 'P2021',
@calcom/web:start:   clientVersion: '5.4.2',
@calcom/web:start:   meta: { table: 'public.users' }
@calcom/web:start: }
@calcom/web:start: react-i18next:: You will need to pass in an i18next instance by using initReactI18next
@calcom/web:start: 11:55:12:015 ERROR[redactError] Error:  {"name":"PrismaClientKnownRequestError","code":"P2021","clientVersion":"5.4.2","meta":{"table":"public.Feature"}}
@calcom/web:start: PrismaClientKnownRequestError: 
@calcom/web:start: Invalid `prisma.user.count()` invocation:
@calcom/web:start: 
@calcom/web:start: 
@calcom/web:start: The table `public.users` does not exist in the current database.
@calcom/web:start:     at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
@calcom/web:start:     at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
@calcom/web:start:     at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
@calcom/web:start:     at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
@calcom/web:start:     at async getServerSideProps (/calcom/apps/web/.next/server/pages/auth/login.js:1:10204) {
@calcom/web:start:   code: 'P2021',
@calcom/web:start:   clientVersion: '5.4.2',
@calcom/web:start:   meta: { table: 'public.users' }
@calcom/web:start: }
asm0dey commented 5 months ago

@MarioNoll did you find a workaround? I have the same issue

zomars commented 5 months ago

It seems like you have pending migrations to run on your database. You should be able to run prisma migrate deploy inside your container. Also we recently added a new DATABSE_DIRECT_URL to enable connection pooling. But AFAIK it should backwards compatible and fallback to DATABASE_URL.

MarioNoll commented 5 months ago

I tried again with v3.7.15 the error remains on a fresh install without upgrading. Still running into the following error when opening the login page:

@calcom/web:start: 12:16:11:429 ERROR[redactError] Error:  {"name":"PrismaClientKnownRequestError","code":"P2021","clientVersion":"5.4.2","meta":{"table":"public.Feature"}}
@calcom/web:start: PrismaClientKnownRequestError: 
@calcom/web:start: Invalid `prisma.user.count()` invocation:
@calcom/web:start: 
@calcom/web:start: 
@calcom/web:start: The table `public.users` does not exist in the current database.
@calcom/web:start:     at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
@calcom/web:start:     at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
@calcom/web:start:     at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
@calcom/web:start:     at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
@calcom/web:start:     at async getServerSideProps (/calcom/apps/web/.next/server/pages/auth/login.js:1:10204) {
@calcom/web:start:   code: 'P2021',
@calcom/web:start:   clientVersion: '5.4.2',
@calcom/web:start:   meta: { table: 'public.users' }
@calcom/web:start: }

Running either yarn workspace @calcom/prisma db-migrate or yarn workspace @calcom/prisma db-deploy inside the container does not have any effect.

Here's my compose:

  calcom:
    image: "calcom/cal.com:v3.7.15"
    restart: "unless-stopped"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000"]
    networks:
      - "calcom_postgres"
      - "traefik_calcom"
    environment:
      CALENDSO_ENCRYPTION_KEY: "{{ vault_calcom_encryption_key }}"
      CALCOM_TELEMETRY_DISABLED: 1
      DATABASE_DIRECT_URL: "postgresql://{{ calcom_postgres_user }}:{{ calcom_postgres_password }}@calcom_postgres:5432/{{ calcom_postgres_database }}"
      DATABASE_URL: "postgresql://{{ calcom_postgres_user }}:{{ calcom_postgres_password }}@calcom_postgres:5432/{{ calcom_postgres_database }}"
      GOOGLE_API_CREDENTIALS: '{{ calcom_google_api_credentials }}'
      NEXTAUTH_SECRET: "{{ vault_calcom_auth_secret }}"
      NEXT_PUBLIC_WEBAPP_URL: "{{ cal_com_web }}"
      NODE_TLS_REJECT_UNAUTHORIZED: 0
      EMAIL_FROM: "{{ calcom_email_server_user }}"
      EMAIL_SERVER_HOST: "{{ calcom_email_server_host }}"
      EMAIL_SERVER_PORT: "{{ calcom_email_server_port }}"
      EMAIL_SERVER_USER: "{{ calcom_email_server_user }}"
      EMAIL_SERVER_PASSWORD: "{{ calcom_mail_app_password }}"
      NODE_ENV: "production"
    depends_on:
      - "calcom_postgres"

  calcom_postgres:
    image: "postgres"
    restart: "unless-stopped"
    volumes:
      - "calcom_postgres:/var/lib/postgresql/data/"
    <<: *postgres_healthcheck
    environment:
      POSTGRES_USER: "{{ calcom_postgres_user }}"
      PGUSER: "{{ calcom_postgres_user }}"
      POSTGRES_PASSWORD: "{{ calcom_postgres_password }}"
      POSTGRES_DB: "{{ calcom_postgres_database }}"
    networks:
      - "calcom_postgres"
naesean commented 2 weeks ago

https://github.com/calcom/docker/issues/329#issuecomment-1981249041