Browse Source

Do not create constraints for boolean fields

On mysql 8, Boolean fields create constraints which later
make it impossible to alter the name of the column.
See: https://github.com/sqlalchemy/alembic/issues/699

Per upstream alembic recommendation, do not create constraints
explicitly.
https://github.com/sqlalchemy/alembic/issues/699#issuecomment-760983057

story: 2008488
task: 41537

Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
(cherry picked from commit bcf771bc6f165f8c364637b1055c6545d78c17bb)

Fix database migrations

The pattern of adding a column and then reading a table with it
no longer works in SQLAlchemy 1.3.20. This has been reported
upstream [1].

[1] https://github.com/sqlalchemy/sqlalchemy/issues/5669

squashed with: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b
(cherry picked from commit f5cf6b958c)

Change-Id: I51659c6e179d7e4e2cfc5be46348fac483d76e3b
(cherry picked from commit 210984fa26)

Conflicts:
magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py

Change-Id: Iba6f68822e4c7219f21ab2da252802dc7c3ca933
changes/10/781510/1
Feilong Wang 6 months ago
committed by Corey Bryant
parent
commit
850b94aa6f
12 changed files with 33 additions and 15 deletions
  1. +6
    -2
      magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py
  2. +6
    -2
      magnum/db/sqlalchemy/alembic/versions/27ad304554e2_adding_magnum_service_functionality.py
  3. +3
    -1
      magnum/db/sqlalchemy/alembic/versions/2ae93c9c6191_add_public_column_to_baymodel_table.py
  4. +1
    -1
      magnum/db/sqlalchemy/alembic/versions/461d798132c7_change_cluster_to_support_nodegroups.py
  5. +1
    -1
      magnum/db/sqlalchemy/alembic/versions/47380964133d_add_network_subnet_fip_to_cluster.py
  6. +1
    -1
      magnum/db/sqlalchemy/alembic/versions/4e263f236334_add_registry_enabled.py
  7. +1
    -1
      magnum/db/sqlalchemy/alembic/versions/5ad410481b88_rename_insecure.py
  8. +3
    -1
      magnum/db/sqlalchemy/alembic/versions/68ce16dfd341_add_master_lb_enabled_column_to_baymodel_table.py
  9. +4
    -2
      magnum/db/sqlalchemy/alembic/versions/87e62e3c7abc_add_hidden_to_cluster_template.py
  10. +3
    -1
      magnum/db/sqlalchemy/alembic/versions/95096e2334ee_add_master_lb_enabled_to_cluster.py
  11. +3
    -1
      magnum/db/sqlalchemy/alembic/versions/ac92cbae311c_add_nodegoup_table.py
  12. +1
    -1
      magnum/db/sqlalchemy/alembic/versions/b1f612248cab_add_floating_ip_enabled_column_to_.py

+ 6
- 2
magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py View File

@ -26,10 +26,14 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
insecure_column = sa.Column('insecure', sa.Boolean(), default=False)
insecure_column = sa.Column('insecure',
sa.Boolean(create_constraint=False),
default=False)
op.add_column('baymodel', insecure_column)
baymodel = sa.sql.table('baymodel',
sa.Column('insecure', sa.Boolean(), default=False))
sa.Column('insecure',
sa.Boolean(create_constraint=False),
default=False))
op.execute(
baymodel.update().values({'insecure': True})
)

+ 6
- 2
magnum/db/sqlalchemy/alembic/versions/27ad304554e2_adding_magnum_service_functionality.py View File

@ -35,14 +35,18 @@ def upgrade():
sa.Column('report_count', sa.Integer(), nullable=False),
sa.Column('host', sa.String(length=255), nullable=True),
sa.Column('binary', sa.String(length=255), nullable=True),
sa.Column('disabled', sa.Boolean(), nullable=True),
sa.Column('disabled',
sa.Boolean(create_constraint=False),
nullable=True),
sa.Column('disabled_reason', sa.String(length=255), nullable=True),
# 'last_seen_up' has different purpose than 'updated_at'.
# 'updated_at' refers to any modification of the entry, which can
# be administrative too, whereas 'last_seen_up' is more related to
# magnum_service. Modeled after nova/servicegroup
sa.Column('last_seen_up', sa.DateTime(), nullable=True),
sa.Column('forced_down', sa.Boolean(), nullable=True),
sa.Column('forced_down',
sa.Boolean(create_constraint=False),
nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('host', 'binary',
name='uniq_magnum_service0host0binary')


+ 3
- 1
magnum/db/sqlalchemy/alembic/versions/2ae93c9c6191_add_public_column_to_baymodel_table.py View File

@ -29,4 +29,6 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.add_column('baymodel', sa.Column('public', sa.Boolean(), default=False))
op.add_column('baymodel', sa.Column('public',
sa.Boolean(create_constraint=False),
default=False))

+ 1
- 1
magnum/db/sqlalchemy/alembic/versions/461d798132c7_change_cluster_to_support_nodegroups.py View File

@ -60,7 +60,7 @@ def upgrade():
sa.Column('max_node_count', sa.Integer, nullable=True),
sa.Column('min_node_count', sa.Integer, nullable=True),
sa.Column('role', String(length=255), nullable=True),
sa.Column('is_default', sa.Boolean())
sa.Column('is_default', sa.Boolean(create_constraint=False))
)
connection = op.get_bind()


+ 1
- 1
magnum/db/sqlalchemy/alembic/versions/47380964133d_add_network_subnet_fip_to_cluster.py View File

@ -36,5 +36,5 @@ def upgrade():
String(255, mysql_ndb_type=TINYTEXT),
nullable=True))
op.add_column('cluster', sa.Column('floating_ip_enabled',
sa.Boolean(),
sa.Boolean(create_constraint=False),
default=False))

+ 1
- 1
magnum/db/sqlalchemy/alembic/versions/4e263f236334_add_registry_enabled.py View File

@ -27,4 +27,4 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.add_column('baymodel', sa.Column('registry_enabled',
sa.Boolean(), default=False))
sa.Boolean(create_constraint=False), default=False))

+ 1
- 1
magnum/db/sqlalchemy/alembic/versions/5ad410481b88_rename_insecure.py View File

@ -28,4 +28,4 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.alter_column('baymodel', 'insecure',
new_column_name='tls_disabled',
existing_type=sa.Boolean())
existing_type=sa.Boolean(create_constraint=False))

+ 3
- 1
magnum/db/sqlalchemy/alembic/versions/68ce16dfd341_add_master_lb_enabled_column_to_baymodel_table.py View File

@ -27,4 +27,6 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.add_column('baymodel',
sa.Column('master_lb_enabled', sa.Boolean(), default=False))
sa.Column('master_lb_enabled',
sa.Boolean(create_constraint=False),
default=False))

+ 4
- 2
magnum/db/sqlalchemy/alembic/versions/87e62e3c7abc_add_hidden_to_cluster_template.py View File

@ -26,5 +26,7 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.add_column('cluster_template', sa.Column('hidden', sa.Boolean(),
default=False))
op.add_column('cluster_template',
sa.Column('hidden',
sa.Boolean(create_constraint=False),
default=False))

+ 3
- 1
magnum/db/sqlalchemy/alembic/versions/95096e2334ee_add_master_lb_enabled_to_cluster.py View File

@ -28,7 +28,9 @@ down_revision = 'c04e925e65c2'
def upgrade():
op.add_column('cluster',
sa.Column('master_lb_enabled', sa.Boolean(), default=False))
sa.Column('master_lb_enabled',
sa.Boolean(create_constraint=False),
default=False))
# Populate existing cluster with the cluster template_id
connection = op.get_bind()
connection.execute(


+ 3
- 1
magnum/db/sqlalchemy/alembic/versions/ac92cbae311c_add_nodegoup_table.py View File

@ -53,7 +53,9 @@ def upgrade():
sa.Column('max_node_count', sa.Integer(), nullable=True),
sa.Column('min_node_count', sa.Integer(), nullable=True),
sa.Column('role', String(length=255), nullable=True),
sa.Column('is_default', sa.Boolean(), default=False),
sa.Column('is_default',
sa.Boolean(create_constraint=False),
default=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('uuid', name='uniq_nodegroup0uuid'),
sa.UniqueConstraint('cluster_id', 'name',


+ 1
- 1
magnum/db/sqlalchemy/alembic/versions/b1f612248cab_add_floating_ip_enabled_column_to_.py View File

@ -28,5 +28,5 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
op.add_column('baymodel',
sa.Column('floating_ip_enabled',
sa.Boolean(),
sa.Boolean(create_constraint=False),
default=True))

Loading…
Cancel
Save