Skip to content

Wire Supabase PostgreSQL into env templates and CI#473

Open
Copilot wants to merge 3 commits intomainfrom
copilot/setup-supabase-database
Open

Wire Supabase PostgreSQL into env templates and CI#473
Copilot wants to merge 3 commits intomainfrom
copilot/setup-supabase-database

Conversation

Copy link
Contributor

Copilot AI commented Mar 8, 2026

Cyrano/src/db.ts already uses drizzle-orm/postgres-js with DATABASE_URL, but both .env.example files pointed at SQLite and CI never forwarded the secret to test runs.

Changes

  • Cyrano/.env.example — replace SQLite placeholder with Supabase PostgreSQL URL using the actual project host (db.xztjiuaemnyfdmiljyif.supabase.co); add commented local-postgres fallback
  • apps/lexfiat/.env.example — same update with the actual Supabase project host
  • .github/workflows/ci.yml — expose DATABASE_URL secret to the three test-running steps (Run unit tests, Generate coverage report, Run tests with coverage)

The password is kept as a YOUR-PASSWORD placeholder in example files — no real credentials are committed.

Required manual step

Add DATABASE_URL as a repository secret (Settings → Secrets and Variables → Actions) with the full Supabase connection string:

DATABASE_URL=postgresql://postgres:<password>@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
Original prompt

Set up the Supabase database for the Cyrano project by integrating the database connection string into the project.

Key Steps:

  1. Add the Database Connection String:

    • Add the following connection string to the project's environment file .env:
      DATABASE_URL=postgresql://postgres:[YOUR-ACTUAL-PASSWORD]@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
      
      Replace [YOUR-ACTUAL-PASSWORD] with the real password associated with the Supabase project.
    • Ensure the connection string is never hardcoded in the application code to maintain security.
  2. Backend Integration:

    • Update the codebase to use the DATABASE_URL from the environment file for database operations.
    • Example for Node.js with pg library:
      const { Pool } = require('pg');
      require('dotenv').config();
      
      const pool = new Pool({
        connectionString: process.env.DATABASE_URL,
      });
      
      pool.connect()
        .then(() => console.log('Connected to Supabase database!'))
        .catch((err) => console.error('Connection error:', err));
      
      module.exports = pool;
  3. CI/CD Configuration:

    • Add the DATABASE_URL as a secret in the GitHub repository for use in CI/CD pipelines:
      • Go to SettingsSecrets and VariablesActions, and add the DATABASE_URL.
      • Use it in GitHub Actions by writing it to the environment at runtime:
        - name: Set DATABASE_URL
          run: echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV
  4. Test the Connection:

    • Test locally and in the CI/CD pipeline to ensure the database integration is functional.
    • Confirm that the application can successfully retrieve and store data.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: MightyPrytanis <219587333+MightyPrytanis@users.noreply.github.com>
Copilot AI changed the title [WIP] Set up Supabase database for Cyrano project Wire Supabase PostgreSQL into env templates and CI Mar 8, 2026
@MightyPrytanis
Copy link
Owner

@copilot after repeated database related failures I set up a new database in supabase: postgresql://postgres:[YOUR-PASSWORD]@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres

Co-authored-by: MightyPrytanis <219587333+MightyPrytanis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot after repeated database related failures I set up a new database in supabase: postgresql://postgres:[YOUR-PASSWORD]@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres

Updated both .env.example files to use the actual Supabase host (db.xztjiuaemnyfdmiljyif.supabase.co) with YOUR-PASSWORD as the only remaining placeholder (commit f23d94e).

To use it, copy the file to .env and replace YOUR-PASSWORD with your actual password. For CI, add DATABASE_URL as a repository secret in Settings → Secrets and Variables → Actions with the full connection string including the real password.

@MightyPrytanis
Copy link
Owner

@copilot in the "secrets" above, the example says "" Does that mean have to insert the password between carets, or just replace all of "" with the actual password?

Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot in the "secrets" above, the example says "" Does that mean have to insert the password between carets, or just replace all of "" with the actual password...

Your comment appears to have been cut off — it ends with the example says " and nothing follows. Could you resend the full message so I can address it?

@MightyPrytanis MightyPrytanis marked this pull request as ready for review March 8, 2026 23:53
@MightyPrytanis MightyPrytanis self-requested a review as a code owner March 8, 2026 23:53
Copilot AI review requested due to automatic review settings March 8, 2026 23:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates environment templates and CI to align with Cyrano’s existing PostgreSQL (DATABASE_URL) usage (via drizzle-orm/postgres-js), replacing the outdated SQLite placeholders and ensuring CI test steps receive the DB connection string.

Changes:

  • Update DATABASE_URL examples in Cyrano and LexFiat env templates to use Supabase PostgreSQL.
  • Add commented local Postgres fallback in Cyrano/.env.example.
  • Forward secrets.DATABASE_URL into the GitHub Actions steps that run tests/coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
apps/lexfiat/.env.example Switches DB template from SQLite to Supabase Postgres connection string.
Cyrano/.env.example Switches DB template from SQLite to Supabase Postgres; adds local Postgres alternative.
.github/workflows/ci.yml Passes DATABASE_URL secret into test/coverage steps.

Comment on lines 71 to 75
- name: Run unit tests
run: npm run test:unit
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
continue-on-error: true
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DATABASE_URL is being repeated on multiple steps. To reduce drift (and ensure future test steps also get the connection string), consider setting env: DATABASE_URL: ${{ secrets.DATABASE_URL }} at the job level instead of per-step.

Copilot uses AI. Check for mistakes.
# Supabase PostgreSQL (Production)
# Replace YOUR-PASSWORD with the password from your Supabase project dashboard.
# Project URL: https://supabase.com/dashboard/project/xztjiuaemnyfdmiljyif
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Supabase DATABASE_URL here omits the SSL requirement that the repo’s security guidance calls out for production DB connections. Consider adding ?sslmode=require (or otherwise ensuring TLS is enforced) so the example matches docs/security/guides/SECURITY_CONFIGURATION_WALKTHROUGH.md and avoids insecure/non-working Supabase connections.

Suggested change
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres?sslmode=require

Copilot uses AI. Check for mistakes.
# Supabase PostgreSQL — replace YOUR-PASSWORD with the password from your
# Supabase project dashboard:
# https://supabase.com/dashboard/project/xztjiuaemnyfdmiljyif
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Supabase DATABASE_URL example doesn’t include an SSL requirement. The repo security guide recommends using ?sslmode=require for encrypted DB connections, and many hosted Postgres providers (including Supabase) require TLS.

Suggested change
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres
DATABASE_URL=postgresql://postgres:YOUR-PASSWORD@db.xztjiuaemnyfdmiljyif.supabase.co:5432/postgres?sslmode=require

Copilot uses AI. Check for mistakes.
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.

3 participants