Add charset and engine parameters to alembic create tables
This patch enforces utf8 and InnoDB when creating tables in mariadb/mysql. Closes-Bug: #2043701 Change-Id: I7afb533bd2d19dfaa900e3b946dc1e3563cc5198
This commit is contained in:
parent
4e185d4e26
commit
1f045ee64a
@ -60,7 +60,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('port', sa.Integer, nullable=False),
|
sa.Column('port', sa.Integer, nullable=False),
|
||||||
sa.Column('zone_id', UUID, nullable=False),
|
sa.Column('zone_id', UUID, nullable=False),
|
||||||
sa.UniqueConstraint('host', 'port', 'zone_id', name='unique_masters'),
|
sa.UniqueConstraint('host', 'port', 'zone_id', name='unique_masters'),
|
||||||
sa.ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'))
|
sa.ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
zone_attr_sql = sa.text(
|
zone_attr_sql = sa.text(
|
||||||
'SELECT id, version, created_at, updated_at, value, zone_id FROM '
|
'SELECT id, version, created_at, updated_at, value, zone_id FROM '
|
||||||
|
@ -56,4 +56,7 @@ def upgrade() -> None:
|
|||||||
sa.Column('status', sa.Enum(name='service_statuses_enum',
|
sa.Column('status', sa.Enum(name='service_statuses_enum',
|
||||||
*SERVICE_STATES), nullable=False),
|
*SERVICE_STATES), nullable=False),
|
||||||
sa.Column('stats', sa.Text, nullable=False),
|
sa.Column('stats', sa.Text, nullable=False),
|
||||||
sa.Column('capabilities', sa.Text, nullable=False))
|
sa.Column('capabilities', sa.Text, nullable=False),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
@ -45,4 +45,6 @@ def upgrade() -> None:
|
|||||||
sa.UniqueConstraint('zone_id', 'project_id', 'target_project_id',
|
sa.UniqueConstraint('zone_id', 'project_id', 'target_project_id',
|
||||||
name='unique_shared_zone'),
|
name='unique_shared_zone'),
|
||||||
sa.ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'),
|
sa.ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
)
|
)
|
||||||
|
@ -73,7 +73,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('provisioner', sa.Enum(name='pool_provisioner',
|
sa.Column('provisioner', sa.Enum(name='pool_provisioner',
|
||||||
*POOL_PROVISIONERS),
|
*POOL_PROVISIONERS),
|
||||||
nullable=False, server_default='UNMANAGED'),
|
nullable=False, server_default='UNMANAGED'),
|
||||||
sa.UniqueConstraint('name', name='unique_pool_name'))
|
sa.UniqueConstraint('name', name='unique_pool_name'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.bulk_insert(
|
op.bulk_insert(
|
||||||
pools_table,
|
pools_table,
|
||||||
@ -90,7 +93,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('pool_id', UUID, nullable=False),
|
sa.Column('pool_id', UUID, nullable=False),
|
||||||
sa.Column('priority', sa.Integer, nullable=False),
|
sa.Column('priority', sa.Integer, nullable=False),
|
||||||
sa.Column('hostname', sa.String(255), nullable=False),
|
sa.Column('hostname', sa.String(255), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'))
|
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pool_attributes', metadata,
|
'pool_attributes', metadata,
|
||||||
@ -103,7 +109,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('pool_id', UUID, nullable=False),
|
sa.Column('pool_id', UUID, nullable=False),
|
||||||
sa.UniqueConstraint('pool_id', 'key', 'value',
|
sa.UniqueConstraint('pool_id', 'key', 'value',
|
||||||
name='unique_pool_attribute'),
|
name='unique_pool_attribute'),
|
||||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'))
|
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'domains', metadata,
|
'domains', metadata,
|
||||||
@ -145,7 +154,10 @@ def upgrade() -> None:
|
|||||||
sa.Index('zone_deleted', 'deleted'),
|
sa.Index('zone_deleted', 'deleted'),
|
||||||
sa.Index('zone_tenant_deleted', 'tenant_id', 'deleted'),
|
sa.Index('zone_tenant_deleted', 'tenant_id', 'deleted'),
|
||||||
sa.Index('reverse_name_deleted', 'reverse_name', 'deleted'),
|
sa.Index('reverse_name_deleted', 'reverse_name', 'deleted'),
|
||||||
sa.Index('zone_created_at', 'created_at'))
|
sa.Index('zone_created_at', 'created_at'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'domain_attributes', metadata,
|
'domain_attributes', metadata,
|
||||||
@ -159,7 +171,10 @@ def upgrade() -> None:
|
|||||||
sa.UniqueConstraint('key', 'value', 'domain_id',
|
sa.UniqueConstraint('key', 'value', 'domain_id',
|
||||||
name='unique_attributes'),
|
name='unique_attributes'),
|
||||||
sa.ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
sa.ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
||||||
ondelete='CASCADE'))
|
ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'recordsets', metadata,
|
'recordsets', metadata,
|
||||||
sa.Column('id', UUID, primary_key=True),
|
sa.Column('id', UUID, primary_key=True),
|
||||||
@ -183,7 +198,10 @@ def upgrade() -> None:
|
|||||||
sa.Index('rrset_type_domainid', 'type', 'domain_id'),
|
sa.Index('rrset_type_domainid', 'type', 'domain_id'),
|
||||||
sa.Index('recordset_type_name', 'type', 'name'),
|
sa.Index('recordset_type_name', 'type', 'name'),
|
||||||
sa.Index('reverse_name_dom_id', 'reverse_name', 'domain_id'),
|
sa.Index('reverse_name_dom_id', 'reverse_name', 'domain_id'),
|
||||||
sa.Index('recordset_created_at', 'created_at'))
|
sa.Index('recordset_created_at', 'created_at'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'records', metadata,
|
'records', metadata,
|
||||||
@ -232,7 +250,10 @@ def upgrade() -> None:
|
|||||||
sa.Index('records_tenant', 'tenant_id'),
|
sa.Index('records_tenant', 'tenant_id'),
|
||||||
sa.Index('record_created_at', 'created_at'),
|
sa.Index('record_created_at', 'created_at'),
|
||||||
sa.Index('update_status_index', 'status', 'domain_id', 'tenant_id',
|
sa.Index('update_status_index', 'status', 'domain_id', 'tenant_id',
|
||||||
'created_at', 'serial'))
|
'created_at', 'serial'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'quotas', metadata,
|
'quotas', metadata,
|
||||||
@ -245,7 +266,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('tenant_id', sa.String(36), nullable=False),
|
sa.Column('tenant_id', sa.String(36), nullable=False),
|
||||||
sa.Column('resource', sa.String(32), nullable=False),
|
sa.Column('resource', sa.String(32), nullable=False),
|
||||||
sa.Column('hard_limit', sa.Integer, nullable=False),
|
sa.Column('hard_limit', sa.Integer, nullable=False),
|
||||||
sa.UniqueConstraint('tenant_id', 'resource', name='unique_quota'))
|
sa.UniqueConstraint('tenant_id', 'resource', name='unique_quota'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'tsigkeys', metadata,
|
'tsigkeys', metadata,
|
||||||
@ -261,7 +285,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('scope', sa.Enum(name='tsig_scopes', *TSIG_SCOPES),
|
sa.Column('scope', sa.Enum(name='tsig_scopes', *TSIG_SCOPES),
|
||||||
nullable=False, server_default='POOL'),
|
nullable=False, server_default='POOL'),
|
||||||
sa.Column('resource_id', UUID, nullable=False),
|
sa.Column('resource_id', UUID, nullable=False),
|
||||||
sa.UniqueConstraint('name', name='unique_tsigkey_name'))
|
sa.UniqueConstraint('name', name='unique_tsigkey_name'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'tlds', metadata,
|
'tlds', metadata,
|
||||||
@ -273,7 +300,10 @@ def upgrade() -> None:
|
|||||||
onupdate=lambda: timeutils.utcnow()),
|
onupdate=lambda: timeutils.utcnow()),
|
||||||
sa.Column('name', sa.String(255), nullable=False),
|
sa.Column('name', sa.String(255), nullable=False),
|
||||||
sa.Column('description', sa.Unicode(160), nullable=True),
|
sa.Column('description', sa.Unicode(160), nullable=True),
|
||||||
sa.UniqueConstraint('name', name='unique_tld_name'))
|
sa.UniqueConstraint('name', name='unique_tld_name'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'zone_transfer_requests', metadata,
|
'zone_transfer_requests', metadata,
|
||||||
@ -292,7 +322,10 @@ def upgrade() -> None:
|
|||||||
*TASK_STATUSES),
|
*TASK_STATUSES),
|
||||||
nullable=False, server_default='ACTIVE', default='ACTIVE'),
|
nullable=False, server_default='ACTIVE', default='ACTIVE'),
|
||||||
sa.ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
sa.ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
||||||
ondelete='CASCADE'))
|
ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'zone_transfer_accepts', metadata,
|
'zone_transfer_accepts', metadata,
|
||||||
@ -311,7 +344,10 @@ def upgrade() -> None:
|
|||||||
ondelete='CASCADE'),
|
ondelete='CASCADE'),
|
||||||
sa.ForeignKeyConstraint(['zone_transfer_request_id'],
|
sa.ForeignKeyConstraint(['zone_transfer_request_id'],
|
||||||
['zone_transfer_requests.id'],
|
['zone_transfer_requests.id'],
|
||||||
ondelete='CASCADE'))
|
ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'zone_tasks', metadata,
|
'zone_tasks', metadata,
|
||||||
@ -327,7 +363,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('status', sa.Enum(name='zone_tasks_resource_statuses',
|
sa.Column('status', sa.Enum(name='zone_tasks_resource_statuses',
|
||||||
*TASK_STATUSES),
|
*TASK_STATUSES),
|
||||||
nullable=False, server_default='ACTIVE', default='ACTIVE'),
|
nullable=False, server_default='ACTIVE', default='ACTIVE'),
|
||||||
sa.Column('location', sa.String(160), nullable=True))
|
sa.Column('location', sa.String(160), nullable=True),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'blacklists', metadata,
|
'blacklists', metadata,
|
||||||
@ -337,4 +376,7 @@ def upgrade() -> None:
|
|||||||
sa.Column('created_at', sa.DateTime),
|
sa.Column('created_at', sa.DateTime),
|
||||||
sa.Column('pattern', sa.String(255), nullable=False),
|
sa.Column('pattern', sa.String(255), nullable=False),
|
||||||
sa.Column('description', sa.Unicode(160), nullable=True),
|
sa.Column('description', sa.Unicode(160), nullable=True),
|
||||||
sa.UniqueConstraint('pattern', name='pattern'))
|
sa.UniqueConstraint('pattern', name='pattern'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
@ -57,7 +57,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('port', sa.Integer, nullable=False),
|
sa.Column('port', sa.Integer, nullable=False),
|
||||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||||
sa.UniqueConstraint('pool_id', 'host', 'port',
|
sa.UniqueConstraint('pool_id', 'host', 'port',
|
||||||
name='unique_pool_host_port'))
|
name='unique_pool_host_port'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pool_targets', metadata,
|
'pool_targets', metadata,
|
||||||
@ -71,7 +74,10 @@ def upgrade() -> None:
|
|||||||
sa.Column('type', sa.String(50), nullable=False),
|
sa.Column('type', sa.String(50), nullable=False),
|
||||||
sa.Column('tsigkey_id', UUID, nullable=True),
|
sa.Column('tsigkey_id', UUID, nullable=True),
|
||||||
sa.Column('description', sa.Unicode(160), nullable=True),
|
sa.Column('description', sa.Unicode(160), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'))
|
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pool_target_masters', metadata,
|
'pool_target_masters', metadata,
|
||||||
@ -87,7 +93,10 @@ def upgrade() -> None:
|
|||||||
sa.ForeignKeyConstraint(['pool_target_id'], ['pool_targets.id'],
|
sa.ForeignKeyConstraint(['pool_target_id'], ['pool_targets.id'],
|
||||||
ondelete='CASCADE'),
|
ondelete='CASCADE'),
|
||||||
sa.UniqueConstraint('pool_target_id', 'host', 'port',
|
sa.UniqueConstraint('pool_target_id', 'host', 'port',
|
||||||
name='unique_pool_target_host_port'))
|
name='unique_pool_target_host_port'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pool_target_options', metadata,
|
'pool_target_options', metadata,
|
||||||
@ -103,7 +112,10 @@ def upgrade() -> None:
|
|||||||
sa.ForeignKeyConstraint(['pool_target_id'], ['pool_targets.id'],
|
sa.ForeignKeyConstraint(['pool_target_id'], ['pool_targets.id'],
|
||||||
ondelete='CASCADE'),
|
ondelete='CASCADE'),
|
||||||
sa.UniqueConstraint('pool_target_id', 'key',
|
sa.UniqueConstraint('pool_target_id', 'key',
|
||||||
name='unique_pool_target_key'))
|
name='unique_pool_target_key'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pool_also_notifies', metadata,
|
'pool_also_notifies', metadata,
|
||||||
@ -118,4 +130,7 @@ def upgrade() -> None:
|
|||||||
sa.Column('port', sa.Integer, nullable=False),
|
sa.Column('port', sa.Integer, nullable=False),
|
||||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'], ondelete='CASCADE'),
|
||||||
sa.UniqueConstraint('pool_id', 'host', 'port',
|
sa.UniqueConstraint('pool_id', 'host', 'port',
|
||||||
name='unique_pool_also_notifies_pool0host0port'))
|
name='unique_pool_also_notifies_pool0host0port'),
|
||||||
|
mysql_engine='InnoDB',
|
||||||
|
mysql_charset='utf8',
|
||||||
|
)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Database tables are now explicitly created with charset=utf8. This resolves
|
||||||
|
an issue running ``designate-manage database sync`` when the designate
|
||||||
|
database was not created with the default charset set to utf8.
|
Loading…
Reference in New Issue
Block a user