Open
Description
There's a simpler and probably more correct way to generate Alembic migration compared to the existing docs from https://inveniordm.docs.cern.ch/develop/howtos/alembic/#failing-alembic-commands
The gist of it is:
# In the module you're creating the recipe
python -m venv .venv
source .venv/bin/activate
# Install the package in editable mode with all dependencies (including tests)
pip install -e .[tests,opensearch2]
# Create the alembic directory in the module
mkdir -p invenio_foobar/alembic
cd invenio_foobar/alembic
# Create the initial recipe
invenio alembic revision --path `pwd` --empty --branch invenio_foobar "Create foobar branch"
# Start a test container for the DB
eval "$(docker-services-cli up --db ${DB:-postgresql} --env)"
# Export the DB URI so that `invenio` commands are aware
export INVENIO_SQLALCHEMY_DATABASE_URI=${SQLALCHEMY_DATABASE_URI}
# Create the database
invenio db create
# Manually delete your module's tables
psql ${SQLALCHEMY_DATABASE_URI} -c "DROP TABLE foobar_table CASCADE;"
# Creat the alembic table on latest known heads
invenio alembic stamp
# Create the migration
invenio alembic revision -p "<parent recipe ID>" -d "<dependent recipe ID>" "Create base tables."
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Ready