Repository navigation
Fix teacher_reported_today migration: dynamic db name + idempotent CR… - #119
Merged
Merged
Conversation
…EATE VIEW
Two real bugs found from a failing production deploy log:
- The migration hardcoded the literal database name "mysql_database" (leaked
from local dev) into the typeorm_metadata bookkeeping statements, instead
of using the dynamic ${dbName} pattern this codebase's other view
migrations use (queryRunner.connection.options.database). Would break
against any database not literally named "mysql_database".
- CREATE VIEW / DROP VIEW aren't idempotent: MySQL DDL causes an implicit
commit independent of the migration's transaction, so if a deploy is
retried after a partial failure (view created, tracking row not yet
committed), the next attempt fails with "table already exists". Switched
to CREATE OR REPLACE VIEW and DROP VIEW IF EXISTS, plus clearing any
stale typeorm_metadata row first.
Verified by reproducing the exact reported failure against a MySQL
database named differently from my sandbox: ran migrations up to this
one, manually created the view outside migration tracking (simulating
the partial-failure state), then confirmed the fixed migration completes
successfully and the view still returns correct data.
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.
…EATE VIEW
Two real bugs found from a failing production deploy log:
Verified by reproducing the exact reported failure against a MySQL database named differently from my sandbox: ran migrations up to this one, manually created the view outside migration tracking (simulating the partial-failure state), then confirmed the fixed migration completes successfully and the view still returns correct data.