Add database migration via Alembic for the added errorMessage - #137
Draft
mberz wants to merge 5 commits into
Draft
Add database migration via Alembic for the added errorMessage#137mberz wants to merge 5 commits into
mberz wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Alembic migration management and the errorMessage schema update.
Changes:
- Adds baseline and incremental migrations.
- Configures Flask-Migrate/Alembic.
- Runs migrations during application startup.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.gitignore |
Tracks migration files. |
app/db.py |
Removes legacy migration code. |
entrypoint.sh |
Applies migrations at startup. |
migrations/README |
Documents migration workflows. |
migrations/alembic.ini |
Configures Alembic logging. |
migrations/env.py |
Integrates Alembic with Flask. |
migrations/script.py.mako |
Defines the revision template. |
migrations/versions/baseline_and_errormessage.py |
Establishes the baseline schema. |
migrations/versions/9b846e1fdacb_add_errormessage_to_simulations.py |
Adds errorMessage columns. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+211
to
+214
| op.drop_table('simulationRuns') | ||
| op.drop_table('projects') | ||
| op.drop_table('material_categories') | ||
| op.drop_table('files') |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)
README.md:131
flask create-dbis not a safe alternative toflask db upgrade: it callsdb.create_all()(manage.py:85) but never creates or stampsalembic_version. This documented fresh setup therefore leaves a database on which the entrypoint's laterflask db upgradeattempts the baseline and fails because the tables already exist. Runflask db upgradefirst and thenflask create-dbonly for seeding, or makecreate-dbrecord the migration revision.
# Create database and seed initial data (fresh local setup)
flask create-db
# Alternatively, apply migrations (keeps your local DB in sync with production schema)
APP_SETTINGS_MODULE=config.DevelopConfig flask db upgrade
migrations/README:49
- Stamping every pre-Alembic database at the baseline is incorrect. A database created with the current
flask create-dbalready has botherrorMessagecolumns from the models, so stampingaa014146bd5band upgrading makes revision9b846e1fdacbadd existing columns and fail. The transition procedure must distinguish legacy schemas that lack the columns from currentcreate_all()schemas (for example, stamp the latter at head or make the migration idempotently handle this state).
flask db stamp aa014146bd5b
flask db upgrade
mberz
marked this pull request as draft
August 20, 2026 12:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces Alembic-based database migrations to the project, providing a robust and standardized way to manage schema changes. It adds an initial schema baseline migration, a migration to add the
errorMessage(#107 ) field to simulations and simulation runs, and all required Alembic configuration and environment files. The entrypoint script is also updated to automatically apply migrations on startup, ensuring the database schema is always up-to-date.Database migration framework integration:
alembic.ini,env.py,script.py.mako) and a README for migration management.Schema migrations:
aa014146bd5b) capturing the full baseline schema for all tables and relationships.9b846e1fdacb) to include anerrorMessagecolumn in bothsimulationsandsimulationRunstables.Application integration and cleanup:
entrypoint.shscript to automatically apply all pending database migrations on startup, with guidance for first-time upgrades.app/db.pyto avoid conflicts with Alembic