This directory contains alembic configuration and database versions to manage database migrations. Migrations are compatible with SQLite, Postgres & MariaDB.
-
alembic.ini
: Contains alembic configuration. -
migrate.py
: A wrapper script to programmatically run migrations. Example: using Lambdas. -
pyproject.toml
: This is the configuration file for thepoetry
package manager, which is used to manage dependencies for the script. -
db
: This directory contains alembic env config and versions.
- To run, setup the DB_URL environment variables. DB_URL environment variable value should be FQDN. Example:
postgresql://myuser:mypassword@127.0.0.1:5432/mydatabase
- Setup the poetry environment
poetry install
- Run migration
poetry run alembic upgrade head
New migration revisions are needed whenever there are modifications to the database schema, such as adding a new table, adding a new column, or updating an existing column.
- Setup the poetry environment, if not already done
poetry install
- Run command. Provide a comment for the revision
This command will create a new revision file under
poetry run alembic revision -m "<comment here>"
db/revisions
. Complete definition forupgrade
anddowngrade
function.
- Python 3.9 or higher
poetry
package manager- Connectivity to the database
By default the database created will be private, you may have to run this script from a compute resource that is authorized to connect
- alembic = "^1.13.1"
- psycopg2-binary = "^2.9.9"