alembic: Add support for MS-SQL

MS-SQL has no native Enum-type support and therefore
needs to work with constraints.
Since these constraints need unique names the suggested approach
referenced in the following alembic documentation has been applied:
http://bit.ly/2x9r8pb

ASTERISK-27255 #close

Change-Id: I4a399ba3eed41a33ce8cb294968ad340221580ee
This commit is contained in:
Florian Floimair
2017-09-05 18:13:19 +02:00
committed by Kevin Harwell
parent 9a366d2424
commit ad606844be
29 changed files with 102 additions and 12 deletions

View File

@@ -16,6 +16,8 @@ import sqlalchemy as sa
def enum_update(table_name, column_name, enum_name, enum_values):
if op.get_context().bind.dialect.name != 'postgresql':
if op.get_context().bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_endpoints_identify_by_pjsip_identify_by_values', 'ps_endpoints')
op.alter_column(table_name, column_name,
type_=sa.Enum(*enum_values, name=enum_name))
return