cleanup docs for making first alembic version script
This commit is contained in:
parent
0838cdb93c
commit
6a1a77cf64
2 changed files with 7 additions and 15 deletions
docs/data/db
|
@ -23,6 +23,8 @@ by the rattail-corepos package for extension tables it provides).
|
|||
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
|
||||
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
|
||||
|
@ -45,28 +47,17 @@ custom location first, core rattail goes last.
|
|||
script_location = rattail.db:alembic
|
||||
version_locations = poser.db:alembic/versions rattail.db:alembic/versions
|
||||
|
||||
Run a command like this (replacing names etc. as needed) to generate the script
|
||||
in your versions folder::
|
||||
Run a command like this (replacing names etc. as needed) to generate
|
||||
the script in your versions folder. Please pay close attention and
|
||||
make sure you have all args correct::
|
||||
|
||||
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
|
||||
script lives. You will want to review this of course, to make sure it includes
|
||||
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
|
||||
is normal)::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue