]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
More SQLite patches.
authorThomas Goirand <thomas@goirand.fr>
Mon, 7 Apr 2014 06:21:02 +0000 (14:21 +0800)
committerThomas Goirand <thomas@goirand.fr>
Mon, 7 Apr 2014 06:23:47 +0000 (14:23 +0800)
Change-Id: I4ce294fbdf39f5f4b70258d54dd0e2e6a0732c4a

debian/changelog
debian/patches/fixes-more-migration-issues-with-sqlite.patch [new file with mode: 0644]
debian/patches/series

index 5dcc7ae20e7db1736b93ba24216fb2b90828c3a2..edf7ce7b6b9a5c2768f2f1025d5037ebe623a9c2 100644 (file)
@@ -1,3 +1,9 @@
+neutron (2014.1~rc1-2) experimental; urgency=low
+
+  * More SQLite migration fixes for Icehouse.
+
+ -- Thomas Goirand <zigo@debian.org>  Mon, 07 Apr 2014 14:23:29 +0800
+
 neutron (2014.1~rc1-1) experimental; urgency=medium
 
   [ gustavo panizzo ]
diff --git a/debian/patches/fixes-more-migration-issues-with-sqlite.patch b/debian/patches/fixes-more-migration-issues-with-sqlite.patch
new file mode 100644 (file)
index 0000000..2554ea2
--- /dev/null
@@ -0,0 +1,237 @@
+Description: More SQLite fixes
+ Upstream doesn't support SQLite well enough, when it's really not hard to do
+ so correctly, so I've added a couples of corrections.
+ .
+ Note that despite my repetitive attemps to send the patches upstream, it
+ hasn't been received well enough to be accepted, on the pretext that "we do
+ not have a clear policy". Well, take your time to decide, in the mean while,
+ Debian will embbed this patch! :)
+Author: Thomas Goirand <zigo@debian.org>
+Forwarded: no
+Last-Update: 2014-04-07
+
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/35c7c198ddea_lbaas_healthmon_del_status.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/35c7c198ddea_lbaas_healthmon_del_status.py
+@@ -43,8 +43,48 @@ from neutron.db import migration
+ def upgrade(active_plugins=None, options=None):
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.drop_column('healthmonitors', 'status')
+-    op.drop_column('healthmonitors', 'status_description')
++    bind = op.get_bind()
++    engine = bind.engine
++    if engine.name == 'sqlite':
++        op.execute("CREATE TEMPORARY TABLE healthmonitors_backup ( "
++                   "tenant_id VARCHAR(255),  "
++                   "id VARCHAR(36) NOT NULL, "
++                   "type VARCHAR(5) NOT NULL, "
++                   "delay INTEGER NOT NULL, "
++                   "timeout INTEGER NOT NULL, "
++                   "max_retries INTEGER NOT NULL, "
++                   "http_method VARCHAR(16), "
++                   "url_path VARCHAR(255), "
++                   "expected_codes VARCHAR(64), "
++                   "admin_state_up BOOLEAN NOT NULL, "
++                   "PRIMARY KEY (id), "
++                   "CONSTRAINT healthmontiors_type CHECK (type IN ('PING', 'TCP', 'HTTP', 'HTTPS')), "
++                   "CHECK (admin_state_up IN (0, 1)));")
++        op.execute("INSERT INTO healthmonitors_backup SELECT "
++                   "tenant_id,id,type,delay,timeout,max_retries,http_method,url_path,expected_codes,admin_state_up "
++                   "FROM healthmonitors;")
++        op.execute("DROP TABLE healthmonitors;");
++        op.execute("CREATE TEMPORARY TABLE healthmonitors ( "
++                   "tenant_id VARCHAR(255),  "
++                   "id VARCHAR(36) NOT NULL, "
++                   "type VARCHAR(5) NOT NULL, "
++                   "delay INTEGER NOT NULL, "
++                   "timeout INTEGER NOT NULL, "
++                   "max_retries INTEGER NOT NULL, "
++                   "http_method VARCHAR(16), "
++                   "url_path VARCHAR(255), "
++                   "expected_codes VARCHAR(64), "
++                   "admin_state_up BOOLEAN NOT NULL, "
++                   "PRIMARY KEY (id), "
++                   "CONSTRAINT healthmontiors_type CHECK (type IN ('PING', 'TCP', 'HTTP', 'HTTPS')), "
++                   "CHECK (admin_state_up IN (0, 1)));")
++        op.execute("INSERT INTO healthmonitors SELECT "
++                   "tenant_id,id,type,delay,timeout,max_retries,http_method,url_path,expected_codes,admin_state_up "
++                   "FROM healthmonitors_backup;")
++        op.execute("DROP TABLE healthmonitors_backup;");
++    else:
++        op.drop_column('healthmonitors', 'status')
++        op.drop_column('healthmonitors', 'status_description')
+ def downgrade(active_plugins=None, options=None):
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py
+@@ -44,17 +44,58 @@ def upgrade(active_plugins=None, options
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.add_column('ml2_port_bindings',
+-                  sa.Column('vif_details', sa.String(length=4095),
+-                            nullable=False, server_default=''))
+-    migr_context = context.get_context()
+-    with context.begin_transaction():
++    bind = op.get_bind()
++    engine = bind.engine
++    if engine.name == 'sqlite':
++        op.execute("CREATE TEMPORARY TABLE ml2_port_bindings_backup ( "
++                   "port_id VARCHAR(36) NOT NULL, "
++                   "host VARCHAR(255) NOT NULL, "
++                   "vif_type VARCHAR(64) NOT NULL, "
++                   "cap_port_filter BOOLEAN NOT NULL, "
++                   "driver VARCHAR(64), "
++                   "segment VARCHAR(36), "
++                   "vnic_type VARCHAR(64) DEFAULT 'normal' NOT NULL, "
++                   "vif_details VARCHAR(4095) DEFAULT '' NOT NULL, "
++                   "PRIMARY KEY (port_id), "
++                   "FOREIGN KEY(port_id) REFERENCES ports (id) ON DELETE CASCADE, "
++                   "FOREIGN KEY(segment) REFERENCES ml2_network_segments (id) ON DELETE SET NULL, "
++                   "CHECK (cap_port_filter IN (0, 1)));")
++        op.execute("INSERT INTO ml2_port_bindings_backup "
++                   "(port_id,host,vif_type,cap_port_filter,driver,segment,vnic_type) "
++                   "SELECT port_id,host,vif_type,cap_port_filter,driver,segment,vnic_type "
++                   "FROM ml2_port_bindings;")
+         for value in ('true', 'false'):
+-            migr_context.execute(
+-                "UPDATE ml2_port_bindings SET"
+-                " vif_details = '{\"port_filter\": %(value)s}'"
+-                " WHERE cap_port_filter = %(value)s" % {'value': value})
+-    op.drop_column('ml2_port_bindings', 'cap_port_filter')
++            op.execute("UPDATE ml2_port_bindings_backup SET"
++                       " vif_details = '{\"port_filter\": %(value)s}'"
++                       " WHERE cap_port_filter = '%(value)s'" % {'value': value})
++        op.execute("DROP TABLE ml2_port_bindings")
++        op.execute("CREATE TABLE ml2_port_bindings ( "
++                   "port_id VARCHAR(36) NOT NULL, "
++                   "host VARCHAR(255) NOT NULL, "
++                   "vif_type VARCHAR(64) NOT NULL, "
++                   "driver VARCHAR(64), "
++                   "segment VARCHAR(36), "
++                   "vnic_type VARCHAR(64) DEFAULT 'normal' NOT NULL, "
++                   "vif_details VARCHAR(4095) DEFAULT '' NOT NULL, "
++                   "PRIMARY KEY (port_id), "
++                   "FOREIGN KEY(port_id) REFERENCES ports (id) ON DELETE CASCADE, "
++                   "FOREIGN KEY(segment) REFERENCES ml2_network_segments (id) ON DELETE SET NULL);")
++        op.execute("INSERT INTO ml2_port_bindings "
++                   "SELECT port_id,host,vif_type,driver,segment,vnic_type,vif_details "
++                   "FROM ml2_port_bindings_backup;")
++        op.execute("DROP TABLE ml2_port_bindings_backup")
++    else:
++        op.add_column('ml2_port_bindings',
++                      sa.Column('vif_details', sa.String(length=4095),
++                                nullable=False, server_default=''))
++        migr_context = context.get_context()
++        with context.begin_transaction():
++            for value in ('true', 'false'):
++                migr_context.execute(
++                    "UPDATE ml2_port_bindings SET"
++                    " vif_details = '{\"port_filter\": %(value)s}'"
++                    " WHERE cap_port_filter = %(value)s" % {'value': value})
++        op.drop_column('ml2_port_bindings', 'cap_port_filter')
+ def downgrade(active_plugins=None, options=None):
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/11c6e18605c8_pool_monitor_status_.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/11c6e18605c8_pool_monitor_status_.py
+@@ -43,9 +43,15 @@ def upgrade(active_plugins=None, options
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.add_column('poolmonitorassociations', sa.Column('status',
+-                                                       sa.String(16),
+-                                                       nullable=False))
++    bind = op.get_bind()
++    engine = bind.engine
++    if engine.name == 'sqlite':
++        op.add_column('poolmonitorassociations', sa.Column('status',
++                                                           sa.String(16)))
++    else:
++        op.add_column('poolmonitorassociations', sa.Column('status',
++                                                           sa.String(16),
++                                                           nullable=False))
+     op.add_column('poolmonitorassociations', sa.Column('status_description',
+                                                        sa.String(255)))
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py
+@@ -47,11 +47,17 @@ def upgrade(active_plugins=None, options
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.create_unique_constraint(
+-        name=CONSTRAINT_NAME,
+-        source=TABLE_NAME,
+-        local_cols=['pool_id', 'address', 'protocol_port']
+-    )
++    bind = op.get_bind()
++    engine = bind.engine
++    if engine.name == 'sqlite':
++        op.execute("CREATE UNIQUE INDEX uniq_member0pool_id0address0port "
++                   "on members (pool_id,address,protocol_port);")
++    else:
++        op.create_unique_constraint(
++            name=CONSTRAINT_NAME,
++            source=TABLE_NAME,
++            local_cols=['pool_id', 'address', 'protocol_port']
++        )
+ def downgrade(active_plugins=None, options=None):
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py
+@@ -43,14 +43,19 @@ def upgrade(active_plugins=None, options
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.alter_column('poolstatisticss', 'bytes_in',
+-                    type_=sa.BigInteger(), existing_type=sa.Integer())
+-    op.alter_column('poolstatisticss', 'bytes_out',
+-                    type_=sa.BigInteger(), existing_type=sa.Integer())
+-    op.alter_column('poolstatisticss', 'active_connections',
+-                    type_=sa.BigInteger(), existing_type=sa.Integer())
+-    op.alter_column('poolstatisticss', 'total_connections',
+-                    type_=sa.BigInteger(), existing_type=sa.Integer())
++    bind = op.get_bind()
++    engine = bind.engine
++    # There's no such thing as "BIGINT" in SQLite, just INTEGER,
++    # so we have nothing to do for SQLite.
++    if engine.name != 'sqlite':
++        op.alter_column('poolstatisticss', 'bytes_in',
++                        type_=sa.BigInteger(), existing_type=sa.Integer())
++        op.alter_column('poolstatisticss', 'bytes_out',
++                        type_=sa.BigInteger(), existing_type=sa.Integer())
++        op.alter_column('poolstatisticss', 'active_connections',
++                        type_=sa.BigInteger(), existing_type=sa.Integer())
++        op.alter_column('poolstatisticss', 'total_connections',
++                        type_=sa.BigInteger(), existing_type=sa.Integer())
+ def downgrade(active_plugins=None, options=None):
+--- neutron-2014.1~rc1.orig/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py
++++ neutron-2014.1~rc1/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py
+@@ -55,11 +55,17 @@ def upgrade(active_plugins=None, options
+     if not migration.should_run(active_plugins, migration_for_plugins):
+         return
+-    op.create_unique_constraint(
+-        name=UC_NAME,
+-        source=TABLE_NAME,
+-        local_cols=['agent_type', 'host']
+-    )
++    bind = op.get_bind()
++    engine = bind.engine
++    if engine.name == 'sqlite':
++        op.execute("CREATE UNIQUE INDEX uniq_agents0agent_type0host "
++                   "on agents (agent_type,host);")
++    else:
++        op.create_unique_constraint(
++            name=UC_NAME,
++            source=TABLE_NAME,
++            local_cols=['agent_type', 'host']
++        )
+ def downgrade(active_plugins=None, options=None):
index 25b97dfe6b92bb75be0fba09dee0df6356263425..54984b066a52dfcb3aa4ddad3e91c082c5af7e7c 100644 (file)
@@ -1,2 +1,3 @@
 fix-alembic-migration-with-sqlite3.patch
 better-config-default.patch
+fixes-more-migration-issues-with-sqlite.patch