Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Migration Failure: Adding legalConsent boolean field to existing user table fails due to null values #17

@allandelmare

Description

@allandelmare

When enabling a legalConsent option (e.g., requirePrivacyPolicy: true) which adds a new boolean column (e.g., privacyPolicyAccepted) to the user table, running npx @better-auth/cli migrate fails if the user table already contains existing rows.

error: column "privacyPolicyAccepted" of relation "user" contains null values at /path/to/node_modules/.pnpm/pg@8.x.x/node_modules/pg/lib/client.js:... ... (rest of stack trace) ...

Steps to Reproduce:

  1. Have an existing Better Auth setup with users in the user table.
  2. Enable a new legalConsent option in auth.ts (e.g., legalConsent({ requirePrivacyPolicy: true })).
  3. Run npx @better-auth/cli migrate.

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