Open lolopinto opened 2 years ago
manual fix:
docker-compose -f docker-compose.dev.yml run --rm app tsent alembic history
update alembic_version set version_num = {rev}
npm run codegen
update alembic_version set version_num = {rev}
another solution is to breakout codegen
into separate commands:
codegen
that only generates code e.g. codegen --step codegen && codegen --step graphql
codegen+db
generates code and updates db
when switching between branches, most times don't need the db change to be reflected anyways since it's just adding on top of other change e.g. adding tables, nullable columns etc
if a column or table is dropped in one or a non-nullable column is added, this is still needed
ran into this again. steps i took:
docker-compose -f docker-compose.dev.yml run --rm app tsent alembic history
to find headupdate alembic_version set version_num = {entry_above}
npm run psql
. drop the tables that had been added. need to fix this soon.
https://alembic.sqlalchemy.org/en/latest/branches.html relevant related: https://github.com/lolopinto/ent/issues/316
when going through to restore to current head or whatever, we can ignore edge changes since they're harmless or make sure to delete from assoc_edge_config which i haven't been doing as I'm dropping columns
another option is reset db and just rerun everything, simpler in the beginning but will be annoying when there's a lot of changes if it takes a while to replay
if you have stacked diffs and change the base of the previous diff because of changes in the stack and come back to new change in the branch, everything is broken
what I did was find current version, get the rev, update down_revision in one diff and that fixes the stack
related: should maybe have a codegen that skips db. if you're in a different branch that doesn't have the db history and just want to recodegen code, it's annoying to have to go to other branch and figure out how many to downgrade by
steps
there should be an easy command that resets the db back to state in a branch