Specify text-length for MySQL only

text-length argument breaks migration in Postgres.
Fix based on this patch:
https://git.openstack.org/cgit/openstack/networking-midonet/commit/?id=67e19d9ccc3fbc48d44065754dc0e0825f7e307f

Change-Id: Iebeea2bae7ddd2e8cd5d9fd4c3bc9a0dc8106ce9
This commit is contained in:
Eric K 2016-09-29 12:04:20 -07:00
parent f4488be27a
commit 380dcaee8c
2 changed files with 9 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class DSTableData(model_base.BASE):
ds_id = sa.Column(sa.String(36), nullable=False, primary_key=True)
tablename = sa.Column(sa.String(255), nullable=False, primary_key=True)
# choose long length compatible with MySQL, SQLite, Postgres
tabledata = sa.Column(sa.Text(1000000000), nullable=False)
tabledata = sa.Column(sa.Text(), nullable=False)
def store_ds_table_data(ds_id, tablename, tabledata, session=None):

View File

@ -30,11 +30,18 @@ import sqlalchemy as sa
def upgrade():
if op.get_bind().engine.dialect.name == 'mysql':
# NOTE: Specify a length long enough to choose MySQL
# LONGTEXT
text_type = sa.Text(length=1000000000)
else:
text_type = sa.Text()
op.create_table(
'dstabledata',
sa.Column('ds_id', sa.String(length=36), nullable=False),
sa.Column('tablename', sa.String(length=255), nullable=False),
sa.Column('tabledata', sa.Text(length=1000000000), nullable=False),
sa.Column('tabledata', text_type, nullable=False),
sa.PrimaryKeyConstraint('ds_id', 'tablename'),
mysql_engine='InnoDB')