]> git.ipfire.org Git - thirdparty/asterisk.git/commit
alembic: Allow cdr, config and voicemail to exist in the same schema 18/4018/2
authorGeorge Joseph <gjoseph@digium.com>
Tue, 4 Oct 2016 21:59:54 +0000 (15:59 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Fri, 7 Oct 2016 12:47:11 +0000 (06:47 -0600)
commit86550f9c17c6a7e8454c3a143cddddb8f130d47e
tree38d24d9cb4623f175acee0a0677982230e618fd1
parentb0b106a473dcfe4c26ffd79908b7c4f1794f8987
alembic:  Allow cdr, config and voicemail to exist in the same schema

cdr, config and voicemail are all separate alembic trees.  Because
alembic's default is to use a table named 'alembic_version' to store
the current tree revision, the 3 trees can't exist in the same schema
without stepping on each other.

Now each tree uses 'alembic_version_<tree_name>' as the version table.
Each tree's env.py script now first checks for 'alembic_version'.  If
it finds it AND its revision is in the tree's history, the script
renames it to 'alembic_version_<tree_name>'.  Regardless, the script
then continues with the migration using 'alembic_version_<tree_name>'
and creates that table if it's not found.  The result is that if an
existing 'alembic_version' table was found but it didn't belong to this
tree, it's left alone and 'alembic_version_<tree_name>' is used or
created.

WARNING:  If multiple trees are using the same schema, they MUST NOT
CRU or D any objects with names that might exist in the other trees.
An example would be 'yesno_values' type.  If two trees perform
operations on it, one tree could pull it out from under the other.
Thankfully we currently don't share any names among cdr, config and
voicemail.

NOTE:  Since the env.py scripts in each tree were identical, a common
env.py has been placed in the ast-db-manage directory and a symlink
to it has been placed in each tree directory.

ASTERISK-24311 #close
Reported-by: Dafi Ni
Change-Id: I4d593f000350deb5d21a14fa1e9bc3896844d898
contrib/ast-db-manage/cdr/env.py [changed from file to symlink]
contrib/ast-db-manage/config/env.py [changed from file to symlink]
contrib/ast-db-manage/env.py [new file with mode: 0755]
contrib/ast-db-manage/voicemail/env.py [changed from file to symlink]