Skip to content

Update deploy_database.sh#2601

Draft
Beatrys-lira wants to merge 1 commit into
evolution-foundation:mainfrom
Beatrys-lira:patch-3
Draft

Update deploy_database.sh#2601
Beatrys-lira wants to merge 1 commit into
evolution-foundation:mainfrom
Beatrys-lira:patch-3

Conversation

@Beatrys-lira

@Beatrys-lira Beatrys-lira commented Jun 23, 2026

Copy link
Copy Markdown

📋 Description

🔗 Related Issue

Closes #(issue_number)

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧹 Code cleanup
  • 🔒 Security fix

🧪 Testing

  • Manual testing completed
  • Functionality verified in development environment
  • No breaking changes introduced
  • Tested with different connection types (if applicable)

📸 Screenshots (if applicable)

✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have manually tested my changes thoroughly
  • I have verified the changes work with different scenarios
  • Any dependent changes have been merged and published

📝 Additional Notes

Summary by Sourcery

Update database deployment script to derive provider and connection URI from environment or .env and run Prisma migrations using provider-specific schemas and migrations.

Enhancements:

  • Normalize database provider resolution (including psql_bouncer) and persist key runtime settings to the .env file during deployment.
  • Unify handling of database connection URI from multiple environment variables and enforce its presence before running migrations.
  • Switch migration execution to Prisma CLI with provider-specific schema and migrations directories while simplifying success/failure handling.

@sourcery-ai

sourcery-ai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors deploy_database.sh to infer and normalize database provider configuration, persist relevant environment variables into .env (including database connection URI), and run Prisma migrations using provider-specific schema and migration directories instead of the previous npm scripts and env_functions helper.

Flow diagram for updated deploy_database.sh deployment logic

flowchart TD
    A[Start deploy_database.sh] --> B{DATABASE_PROVIDER set?}
    B -- Yes --> C[PROVIDER = DATABASE_PROVIDER]
    B -- No --> D[Read PROVIDER from .env DATABASE_PROVIDER]
    C --> E[Normalize PROVIDER to lowercase]
    D --> E[Normalize PROVIDER to lowercase]
    E --> F{PROVIDER is psql_bouncer?}
    F -- Yes --> G[PRISMA_PROVIDER = postgresql]
    F -- No --> H[PRISMA_PROVIDER = PROVIDER]

    G --> I[update_env for core vars
DATABASE_PROVIDER
DATABASE_ENABLED
SERVER_PORT
AUTHENTICATION_API_KEY
CACHE_REDIS_ENABLED
CACHE_LOCAL_ENABLED]
    H --> I

    I --> J{DATABASE_CONNECTION_URI set?}
    J -- Yes --> K[update_env DATABASE_CONNECTION_URI from DATABASE_CONNECTION_URI]
    J -- No --> L{DATABASE_CONNECTION_URL set?}
    L -- Yes --> M[update_env DATABASE_CONNECTION_URI from DATABASE_CONNECTION_URL]
    L -- No --> N{DATABASE_URL set?}
    N -- Yes --> O[update_env DATABASE_CONNECTION_URI from DATABASE_URL]
    N -- No --> P[Error: DATABASE_CONNECTION_URI not defined; exit 1]

    K --> Q[Read DATABASE_CONNECTION_URI from .env into DB_URI]
    M --> Q
    O --> Q
    Q --> R[rm -rf ./prisma/migrations]
    R --> S[cp -r ./prisma/PRISMA_PROVIDER-migrations ./prisma/migrations]
    S --> T[npx prisma migrate deploy --schema ./prisma/PRISMA_PROVIDER-schema.prisma]
    T --> U[End: migrations applied]
Loading

File-Level Changes

Change Details Files
Inline environment management and provider detection to remove dependency on env_functions.sh and DOCKER_ENV.
  • Remove sourcing of env_functions.sh and the DOCKER_ENV gate that previously called export_env_vars
  • Introduce a PROVIDER variable resolved from DATABASE_PROVIDER or existing .env and normalize it to lowercase
  • Map psql_bouncer to a Prisma provider of postgresql while leaving other providers unchanged
Docker/scripts/deploy_database.sh
Persist configuration and connection settings into .env within the script.
  • Add update_env helper that upserts key/value pairs into .env, skipping empty values
  • Write DATABASE_PROVIDER, DATABASE_ENABLED, SERVER_PORT, AUTHENTICATION_API_KEY, CACHE_REDIS_ENABLED, and CACHE_LOCAL_ENABLED from the current environment into .env when present
  • Resolve DATABASE_CONNECTION_URI from DATABASE_CONNECTION_URI, DATABASE_CONNECTION_URL, or DATABASE_URL env vars (in that priority) and store it in .env
Docker/scripts/deploy_database.sh
Switch migration execution to Prisma CLI with provider-specific schema and migrations, enforcing a required DATABASE_CONNECTION_URI.
  • Read DATABASE_CONNECTION_URI from .env and exit with an error if it is unset
  • Replace npm run db:deploy / db:generate calls with npx prisma migrate deploy using a provider-specific schema file
  • Always replace ./prisma/migrations with the contents of the selected provider's migration directory before running migrations
Docker/scripts/deploy_database.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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