Steps to generate alembic migrations in api container
Delete the api container
Rebuild the api image with changed code ./manage build api
Then start the containers ./manage start
Shell into running api container
[Optional] Inside api container shell: use alembic check command to see if alembic is able to see the changes otherwise repeat the above steps
use alembic revision --autogenerate -m "Replace this with a description of your DB migration change"
The above command should generate a revision file in api/alembic/versions folder
If the newly generated file is not reflected on your local file system then copy the newly generated DB migration revision file to your local file system so that we can commit that to git.
Check: Now after copying the file to local file system we rebuild the api image and run the containers check the Postgres Db to see if your changes are reflected in the local database container
Check: alembic_version database table to see if it has your latest Db migration id
Automate the above steps using a manage script
Ex: ./manage autogenerate-migrations
Steps to generate alembic migrations in
api
containerapi
containerapi
image with changed code./manage build api
./manage start
api
containerapi
container shell: usealembic check
command to see if alembic is able to see the changes otherwise repeat the above stepsalembic revision --autogenerate -m "Replace this with a description of your DB migration change"
api/alembic/versions
folderrebuild
theapi
image and run the containers check the Postgres Db to see if your changes are reflected in the local database containeralembic_version
database table to see if it has your latestDb
migration idAutomate the above steps using a manage script Ex:
./manage autogenerate-migrations