cleanup docs for making first alembic version script

This commit is contained in:
Lance Edgar 2024-08-27 19:59:08 -05:00
parent 0838cdb93c
commit 6a1a77cf64
2 changed files with 7 additions and 15 deletions

View file

@ -38,6 +38,7 @@ extensions = [
] ]
intersphinx_mapping = { intersphinx_mapping = {
'alembic': ('https://alembic.sqlalchemy.org/en/latest/', None),
'rattail': ('https://rattailproject.org/docs/rattail/', None), 'rattail': ('https://rattailproject.org/docs/rattail/', None),
'tailbone': ('https://rattailproject.org/docs/tailbone/', None), 'tailbone': ('https://rattailproject.org/docs/tailbone/', None),
'wuttjamaican': ('https://rattailproject.org/docs/wuttjamaican/', None), 'wuttjamaican': ('https://rattailproject.org/docs/wuttjamaican/', None),

View file

@ -23,6 +23,8 @@ by the rattail-corepos package for extension tables it provides).
First Alembic Version First Alembic Version
--------------------- ---------------------
(For more authoritative docs see :ref:`alembic:multiple_bases`.)
In order to add custom extensions to the schema, you will need to establish In order to add custom extensions to the schema, you will need to establish
some things for sake of Alembic. Note that these steps are only required for some things for sake of Alembic. Note that these steps are only required for
the "first" extension you add; subsequent versions are somewhat simpler and are the "first" extension you add; subsequent versions are somewhat simpler and are
@ -45,28 +47,17 @@ custom location first, core rattail goes last.
script_location = rattail.db:alembic script_location = rattail.db:alembic
version_locations = poser.db:alembic/versions rattail.db:alembic/versions version_locations = poser.db:alembic/versions rattail.db:alembic/versions
Run a command like this (replacing names etc. as needed) to generate the script Run a command like this (replacing names etc. as needed) to generate
in your versions folder:: the script in your versions folder. Please pay close attention and
make sure you have all args correct::
cd /srv/envs/poser cd /srv/envs/poser
bin/alembic -c app/rattail.conf revision --autogenerate --head rattail@head --version-path ~/src/poser/poser/db/alembic/versions/ -m 'initial Poser tables' bin/alembic -c app/rattail.conf revision --autogenerate --head base --branch-label=poser --version-path ~/src/poser/poser/db/alembic/versions/ -m 'initial Poser tables'
If all goes well that command output should end by telling you where the new If all goes well that command output should end by telling you where the new
script lives. You will want to review this of course, to make sure it includes script lives. You will want to review this of course, to make sure it includes
all your new tables. all your new tables.
But you must also declare this version as a new branch head. This lets your
custom versions have a life of their own, essentially. So going forward, when
you upgrade your DB schema, both the core Rattail tables, as well as your own,
will be migrated properly.
There are two variables near the top of the script which you must edit, like so:
.. code-block:: python
down_revision = None
branch_labels = ('poser',)
And with all that in place, you can apply the migration to your DB (this part And with all that in place, you can apply the migration to your DB (this part
is normal):: is normal)::