Skip to content

fix: update database commands in package.json to include dotenv for local development #2065

Open
heyy-kartik wants to merge 1 commit intoMail-0:stagingfrom
heyy-kartik:origin/package.json-auth.ts-changes
Open

fix: update database commands in package.json to include dotenv for local development #2065
heyy-kartik wants to merge 1 commit intoMail-0:stagingfrom
heyy-kartik:origin/package.json-auth.ts-changes

Conversation

@heyy-kartik
Copy link
Copy Markdown

fix: add localhost backend port for local development in auth.ts
fix: correct valkey image reference in docker-compose.db.yaml

Description

Ensure drizzle-kit loads environment variables from .dev.vars

  • This PR fixes an issue where running pnpm db:push or pnpm db:generate inside the server workspace fails because drizzle-kit
    doesn't automatically load the DATABASE_URL from Cloudflare's .dev.vars file.

  • Why is this needed?

    • Currently, new developers setting up the project locally run into Error: password authentication failed or completely missing relations when trying to sign in. The pnpm db:push command exits silently or fails if DATABASE_URL isn't globally exported in the shell.

By prefixing the database scripts with dotenv -e .dev.vars, we guarantee that Drizzle always has the correct database connection string available during local setup and schema migrations

Type of Change

Please delete options that are not relevant.

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature with breaking changes)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • 🔒 Security enhancement
  • ⚡ Performance improvement

Areas Affected

Please check all that apply:

  • Email Integration (Gmail, IMAP, etc.)
  • User Interface/Experience
  • Authentication/Authorization
  • Data Storage/Management
  • API Endpoints
  • Documentation
  • Testing Infrastructure
  • Development Workflow
  • Deployment/Infrastructure

Security Considerations

For changes involving data or authentication:

  • No sensitive data is exposed
  • Authentication checks are in place
  • Input validation is implemented
  • Rate limiting is considered (if applicable)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • I have updated the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix/feature works
  • All tests pass locally
  • Any dependent changes are merged and published

Additional Notes

During my initial local development setup, I got completely stuck because the database container initialized with the default postgres password, but the Drizzle migrations (pnpm db:push) were failing silently or throwing 500 Internal Server Error and missing relation errors because drizzle-kit wasn't picking up the DATABASE_URL from .dev.vars. Once I explicitly passed the environment variables using dotenv-cli, the schema pushed perfectly and the authentication errors disappeared.


By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

…ocal development

fix: add localhost backend port for local development in auth.ts
fix: correct valkey image reference in docker-compose.db.yaml
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.

1 participant