summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/db/migration.py2
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/083_quota_class.py63
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/084_quotas_unlimited.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/085_add_index_to_fixed_ips_by_address.py33
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/086_set_engine_mysql_innodb.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/087_add_uuid_to_bw_usage_cache.py58
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/088_change_instance_id_to_uuid_in_block_device_mapping.py80
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_downgrade.sql97
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_upgrade.sql97
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/089_add_volume_id_mappings.py119
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/090_modify_volume_id_datatype.py237
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_downgrade.sql226
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_upgrade.sql226
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/091_convert_volume_ids_to_uuid.py205
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/092_add_instance_system_metadata.py73
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/093_drop_instance_actions_table.py54
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py54
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/095_change_fk_instance_id_to_uuid.py94
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_downgrade.sql133
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_upgrade.sql132
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/096_recreate_dns_domains.py145
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/097_quota_usages_reservations.py106
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py72
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/099_add_disabled_instance_types.py40
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/100_instance_metadata_uses_uuid.py80
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_downgrade.sql64
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_upgrade.sql64
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/101_security_group_instance_association_uses_uuid.py80
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_downgrade.sql61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_upgrade.sql61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/102_consoles_uses_uuid.py80
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_downgrade.sql72
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_upgrade.sql72
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/103_instance_indexes.py43
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/104_instance_indexes_2.py43
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_downgrade.sql1
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_upgrade.sql1
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/105_instance_info_caches_uses_uuid.py70
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_downgrade.sql50
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_upgrade.sql50
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/106_add_foreign_keys.py67
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_downgrade.sql1
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_upgrade.sql1
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/107_add_instance_id_mappings.py67
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/108_task_log.py62
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/109_drop_dns_domains_project_id_fkey.py63
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_downgrade.sql53
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_upgrade.sql52
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/110_drop_deprecated_auth.py189
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py72
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/112_update_deleted_instance_data.py69
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/113_fixed_ips_uses_uuid.py108
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_downgrade.sql85
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_upgrade.sql85
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_downgrade.sql71
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_upgrade.sql71
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/114_vifs_uses_uuid.py108
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/115_make_user_quotas_key_and_value.py94
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/116_drop_user_quotas_key_and_value.py98
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/117_add_compute_node_stats.py61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/118_add_indexes_to_agent_builds.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/119_add_indexes_to_aggregate_metadata.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/120_add_indexes_to_block_device_mapping.py71
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/121_add_indexes_to_bw_usage_cache.py59
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/122_add_indexes_to_certificates.py59
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/123_add_indexes_to_dns_domains.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/124_add_indexes_to_fixed_ips.py76
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/125_add_indexes_to_floating_ips.py68
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/126_add_indexes_to_instance_faults.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/127_add_indexes_to_instance_type_extra_specs.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/128_add_indexes_to_instances.py96
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/129_add_indexes_to_iscsi_targets.py57
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/130_add_indexes_to_key_pairs.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/131_add_indexes_to_networks.py107
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/132_add_instance_type_projects.py67
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/133_aggregate_delete_fix.py48
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/133_folsom.py (renamed from nova/db/sqlalchemy/migrate_repo/versions/082_essex.py)746
-rw-r--r--nova/tests/test_migrations.py200
78 files changed, 494 insertions, 6223 deletions
diff --git a/nova/db/migration.py b/nova/db/migration.py
index 76b70e14d..5ffa7cdfb 100644
--- a/nova/db/migration.py
+++ b/nova/db/migration.py
@@ -24,7 +24,7 @@ from nova import utils
IMPL = utils.LazyPluggable('db_backend',
sqlalchemy='nova.db.sqlalchemy.migration')
-INIT_VERSION = 81
+INIT_VERSION = 132
def db_sync(version=None):
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/083_quota_class.py b/nova/db/sqlalchemy/migrate_repo/versions/083_quota_class.py
deleted file mode 100644
index d08afd16e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/083_quota_class.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime
-from sqlalchemy import MetaData, Integer, String, Table
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # New table
- quota_classes = Table('quota_classes', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True),
- Column('class_name',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False), index=True),
- Column('resource',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('hard_limit', Integer(), nullable=True),
- )
-
- try:
- quota_classes.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(quota_classes))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- quota_classes = Table('quota_classes', meta, autoload=True)
- try:
- quota_classes.drop()
- except Exception:
- LOG.error(_("quota_classes table not dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/084_quotas_unlimited.py b/nova/db/sqlalchemy/migrate_repo/versions/084_quotas_unlimited.py
deleted file mode 100644
index d9308121d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/084_quotas_unlimited.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 Red Hat, Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import sqlalchemy
-
-
-def upgrade(migrate_engine):
- """Map quotas hard_limit from NULL to -1"""
- _migrate_unlimited(migrate_engine, None, -1)
-
-
-def downgrade(migrate_engine):
- """Map quotas hard_limit from -1 to NULL"""
- _migrate_unlimited(migrate_engine, -1, None)
-
-
-def _migrate_unlimited(migrate_engine, old_limit, new_limit):
- meta = sqlalchemy.MetaData()
- meta.bind = migrate_engine
-
- def _migrate(table_name):
- table = sqlalchemy.Table(table_name, meta, autoload=True)
- table.update().\
- where(table.c.hard_limit == old_limit).\
- values(hard_limit=new_limit).execute()
-
- _migrate('quotas')
- _migrate('quota_classes')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/085_add_index_to_fixed_ips_by_address.py b/nova/db/sqlalchemy/migrate_repo/versions/085_add_index_to_fixed_ips_by_address.py
deleted file mode 100644
index 5e24b42c3..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/085_add_index_to_fixed_ips_by_address.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 IBM
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('fixed_ips', meta, autoload=True)
- index = Index('address', instances.c.address)
- index.create(migrate_engine)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('fixed_ips', meta, autoload=True)
- index = Index('address', instances.c.address)
- index.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/086_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/086_set_engine_mysql_innodb.py
deleted file mode 100644
index da985b956..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/086_set_engine_mysql_innodb.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import MetaData
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
-
- tables = ["agent_builds", "aggregate_hosts", "aggregate_metadata",
- "aggregates", "block_device_mapping", "bw_usage_cache",
- "dns_domains", "instance_faults", "instance_type_extra_specs",
- "provider_fw_rules", "quota_classes", "s3_images",
- "sm_backend_config", "sm_flavors", "sm_volume",
- "virtual_storage_arrays", "volume_metadata",
- "volume_type_extra_specs", "volume_types"]
-
- meta = MetaData()
- meta.bind = migrate_engine
- if migrate_engine.name == "mysql":
- d = migrate_engine.execute("SHOW TABLE STATUS WHERE Engine!='InnoDB';")
- for row in d.fetchall():
- table_name = row[0]
- if table_name in tables:
- migrate_engine.execute("ALTER TABLE %s Engine=InnoDB" %
- table_name)
-
-
-def downgrade(migrate_engine):
- pass
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/087_add_uuid_to_bw_usage_cache.py b/nova/db/sqlalchemy/migrate_repo/versions/087_add_uuid_to_bw_usage_cache.py
deleted file mode 100644
index ce07905c8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/087_add_uuid_to_bw_usage_cache.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, BigInteger
-from sqlalchemy import MetaData, Integer, String, Table
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # add column:
- bw_usage_cache = Table('bw_usage_cache', meta, autoload=True)
- uuid = Column('uuid', String(36))
-
- # clear the cache to get rid of entries with no uuid
- migrate_engine.execute(bw_usage_cache.delete())
-
- bw_usage_cache.create_column(uuid)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # drop column:
- bw_usage_cache = Table('bw_usage_cache', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('mac', String(255)),
- Column('uuid', String(36)),
- Column('start_period', DateTime(timezone=False), nullable=False),
- Column('last_refreshed', DateTime(timezone=False)),
- Column('bw_in', BigInteger()),
- Column('bw_out', BigInteger()),
- extend_existing=True)
-
- bw_usage_cache.drop_column('uuid')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/088_change_instance_id_to_uuid_in_block_device_mapping.py b/nova/db/sqlalchemy/migrate_repo/versions/088_change_instance_id_to_uuid_in_block_device_mapping.py
deleted file mode 100644
index 73d8b6968..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/088_change_instance_id_to_uuid_in_block_device_mapping.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(block_device_mapping)
-
- try:
- block_device_mapping.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == block_device_mapping.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(block_device_mapping.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[block_device_mapping.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- block_device_mapping.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(block_device_mapping)
-
- try:
- block_device_mapping.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == block_device_mapping.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- block_device_mapping.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_downgrade.sql
deleted file mode 100644
index 3699ce9ab..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_downgrade.sql
+++ /dev/null
@@ -1,97 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE block_device_mapping_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info TEXT,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO block_device_mapping_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- NULL,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info,
- instance_uuid
- FROM block_device_mapping;
-
- UPDATE block_device_mapping_backup
- SET instance_id=
- (SELECT id
- FROM instances
- WHERE block_device_mapping_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE block_device_mapping;
-
- CREATE TABLE block_device_mapping (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info TEXT,
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO block_device_mapping
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info
- FROM block_device_mapping_backup;
-
- DROP TABLE block_device_mapping_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_upgrade.sql
deleted file mode 100644
index d75d2ffa2..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/088_sqlite_upgrade.sql
+++ /dev/null
@@ -1,97 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE block_device_mapping_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info TEXT,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO block_device_mapping_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info,
- NULL
- FROM block_device_mapping;
-
- UPDATE block_device_mapping_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE block_device_mapping_backup.instance_id = instances.id
- );
-
- DROP TABLE block_device_mapping;
-
- CREATE TABLE block_device_mapping (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info TEXT,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- INSERT INTO block_device_mapping
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info,
- instance_uuid
- FROM block_device_mapping_backup;
-
- DROP TABLE block_device_mapping_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/089_add_volume_id_mappings.py b/nova/db/sqlalchemy/migrate_repo/versions/089_add_volume_id_mappings.py
deleted file mode 100644
index a4cd06704..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/089_add_volume_id_mappings.py
+++ /dev/null
@@ -1,119 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import MetaData, String, Table
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- """Build mapping tables for our volume uuid migration.
-
- These mapping tables serve two purposes:
- 1. Provide a method for downgrade after UUID conversion
- 2. Provide a uuid to associate with existing volumes and snapshots
- when we do the actual datatype migration from int to uuid
-
- """
- meta = MetaData()
- meta.bind = migrate_engine
-
- volume_id_mappings = Table('volume_id_mappings', meta,
- Column('created_at',
- DateTime(timezone=False)),
- Column('updated_at',
- DateTime(timezone=False)),
- Column('deleted_at',
- DateTime(timezone=False)),
- Column('deleted',
- Boolean(create_constraint=True, name=None)),
- Column('id', Integer(),
- primary_key=True,
- nullable=False,
- autoincrement=True),
- Column('uuid', String(36),
- nullable=False))
- try:
- volume_id_mappings.create()
- except Exception:
- LOG.exception("Exception while creating table 'volume_id_mappings'")
- meta.drop_all(tables=[volume_id_mappings])
- raise
-
- snapshot_id_mappings = Table('snapshot_id_mappings', meta,
- Column('created_at',
- DateTime(timezone=False)),
- Column('updated_at',
- DateTime(timezone=False)),
- Column('deleted_at',
- DateTime(timezone=False)),
- Column('deleted',
- Boolean(create_constraint=True, name=None)),
- Column('id', Integer(),
- primary_key=True,
- nullable=False,
- autoincrement=True),
- Column('uuid', String(36),
- nullable=False))
- try:
- snapshot_id_mappings.create()
- except Exception:
- LOG.exception("Exception while creating table 'snapshot_id_mappings'")
- meta.drop_all(tables=[snapshot_id_mappings])
- raise
-
- if migrate_engine.name == "mysql":
- migrate_engine.execute("ALTER TABLE volume_id_mappings Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE snapshot_id_mappings "
- "Engine=InnoDB")
-
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
- volume_id_mappings = Table('volume_id_mappings', meta, autoload=True)
- snapshot_id_mappings = Table('snapshot_id_mappings', meta, autoload=True)
-
- volume_list = list(volumes.select().execute())
- for v in volume_list:
- old_id = v['id']
- new_id = uuid.uuid4()
- row = volume_id_mappings.insert()
- row.execute({'id': old_id,
- 'uuid': str(new_id)})
-
- snapshot_list = list(snapshots.select().execute())
- for s in snapshot_list:
- old_id = s['id']
- new_id = uuid.uuid4()
- row = snapshot_id_mappings.insert()
- row.execute({'id': old_id,
- 'uuid': str(new_id)})
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- volume_id_mappings = Table('volume_id_mappings', meta, autoload=True)
- volume_id_mappings.drop()
-
- snapshot_id_mappings = Table('snapshot_id_mappings', meta, autoload=True)
- snapshot_id_mappings.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/090_modify_volume_id_datatype.py b/nova/db/sqlalchemy/migrate_repo/versions/090_modify_volume_id_datatype.py
deleted file mode 100644
index 4be63b322..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/090_modify_volume_id_datatype.py
+++ /dev/null
@@ -1,237 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import Integer
-from sqlalchemy import MetaData, String, Table
-
-from migrate import ForeignKeyConstraint
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- """Convert volume and snapshot id columns from int to varchar."""
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
- iscsi_targets = Table('iscsi_targets', meta, autoload=True)
- volume_metadata = Table('volume_metadata', meta, autoload=True)
- sm_volume = Table('sm_volume', meta, autoload=True)
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
-
- try:
- fkeys = list(snapshots.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[snapshots.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(iscsi_targets.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[iscsi_targets.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(volume_metadata.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[volume_metadata.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(sm_volume.c.id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[sm_volume.c.id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(block_device_mapping.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[block_device_mapping.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(block_device_mapping.c.snapshot_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[block_device_mapping.c.snapshot_id],
- refcolumns=[snapshots.c.id],
- name=fkey_name).drop()
-
- except Exception:
- LOG.error(_("Foreign Key constraint couldn't be removed"))
- raise
-
- volumes.c.id.alter(String(36), primary_key=True)
- volumes.c.snapshot_id.alter(String(36))
- volume_metadata.c.volume_id.alter(String(36), nullable=False)
- snapshots.c.id.alter(String(36), primary_key=True)
- snapshots.c.volume_id.alter(String(36))
- sm_volume.c.id.alter(String(36))
- block_device_mapping.c.volume_id.alter(String(36))
- block_device_mapping.c.snapshot_id.alter(String(36))
- iscsi_targets.c.volume_id.alter(String(36), nullable=True)
-
- try:
- fkeys = list(snapshots.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[snapshots.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(iscsi_targets.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[iscsi_targets.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(volume_metadata.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[volume_metadata.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(sm_volume.c.id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[sm_volume.c.id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
- # NOTE(jdg) We're intentionally leaving off FK's on BDM
-
- except Exception:
- LOG.error(_("Foreign Key constraint couldn't be removed"))
- raise
-
-
-def downgrade(migrate_engine):
- """Convert volume and snapshot id columns back to int."""
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
-
- if dialect.startswith('sqlite'):
- return
-
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
- iscsi_targets = Table('iscsi_targets', meta, autoload=True)
- volume_metadata = Table('volume_metadata', meta, autoload=True)
- sm_volume = Table('sm_volume', meta, autoload=True)
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
-
- try:
- fkeys = list(snapshots.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[snapshots.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(iscsi_targets.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[iscsi_targets.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(volume_metadata.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[volume_metadata.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(sm_volume.c.id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[sm_volume.c.id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- except Exception:
- LOG.error(_("Foreign Key constraint couldn't be removed"))
- raise
-
- volumes.c.id.alter(Integer, primary_key=True, autoincrement=True)
- volumes.c.snapshot_id.alter(Integer)
- volume_metadata.c.volume_id.alter(Integer, nullable=False)
- snapshots.c.id.alter(Integer, primary_key=True, autoincrement=True)
- snapshots.c.volume_id.alter(Integer)
- sm_volume.c.id.alter(Integer)
- block_device_mapping.c.volume_id.alter(Integer)
- block_device_mapping.c.snapshot_id.alter(Integer)
- iscsi_targets.c.volume_id.alter(Integer, nullable=True)
-
- try:
- fkeys = list(snapshots.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[snapshots.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(iscsi_targets.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[iscsi_targets.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(volume_metadata.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[volume_metadata.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- fkeys = list(sm_volume.c.id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[sm_volume.c.id],
- refcolumns=[volumes.c.id],
- name=fkey_name).create()
-
- # NOTE(jdg) Put the BDM foreign keys back in place
- fkeys = list(block_device_mapping.c.volume_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[block_device_mapping.c.volume_id],
- refcolumns=[volumes.c.id],
- name=fkey_name).drop()
-
- fkeys = list(block_device_mapping.c.snapshot_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[block_device_mapping.c.snapshot_id],
- refcolumns=[snapshots.c.id],
- name=fkey_name).drop()
-
- except Exception:
- LOG.error(_("Foreign Key constraint couldn't be removed"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_downgrade.sql
deleted file mode 100644
index 7d89da247..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_downgrade.sql
+++ /dev/null
@@ -1,226 +0,0 @@
-BEGIN TRANSACTION;
-
- -- change id and snapshot_id datatypes in volumes table
- CREATE TABLE volumes_backup(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes;
- DROP TABLE volumes;
- ALTER TABLE volumes_backup RENAME TO volumes;
-
- -- change id and volume_id datatypes in snapshots table
- CREATE TABLE snapshots_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- volume_id INTEGER,
- status VARCHAR(255),
- progress VARCHAR(255),
- volume_size INTEGER,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO snapshots_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- user_id,
- project_id,
- volume_id,
- status,
- progress,
- volume_size,
- display_name,
- display_description
- FROM snapshots;
- DROP TABLE snapshots;
- ALTER TABLE snapshots_backup RENAME TO snapshots;
-
- -- change id and volume_id datatypes in iscsi_targets table
- CREATE TABLE iscsi_targets_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- target_num INTEGER,
- host VARCHAR(255),
- volume_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO iscsi_targets_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- target_num,
- host,
- volume_id
- FROM iscsi_targets;
- DROP TABLE iscsi_targets;
- ALTER TABLE iscsi_targets_backup RENAME TO iscsi_targets;
-
- CREATE TABLE volume_metadata_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- key VARCHAR(255),
- value VARCHAR(255),
- volume_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO volume_metadata_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- key,
- value,
- volume_id
- FROM volume_metadata;
- DROP TABLE volume_metadata;
- ALTER TABLE volume_metadata_backup RENAME TO volume_metadata;
-
- -- change volume_id and snapshot_id datatypes in bdm table
- CREATE TABLE block_device_mapping_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_uuid VARCHAR(36) NOT NULL,
- device_name VARCHAR(255),
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info VARCHAR(255),
- FOREIGN KEY(instance_uuid) REFERENCES instances(id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots(id),
- PRIMARY KEY (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO block_device_mapping_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_uuid,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info
- FROM block_device_mapping;
- DROP TABLE block_device_mapping;
- ALTER TABLE block_device_mapping_backup RENAME TO block_device_mapping;
-
- -- change volume_id and sm_volume_table
- CREATE TABLE sm_volume_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- backend_id INTEGER NOT NULL,
- vdi_uuid VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0,1))
- );
- INSERT INTO sm_volume_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- backend_id,
- vdi_uuid
- FROM sm_volume;
- DROP TABLE sm_volume;
- ALTER TABLE sm_volume_backup RENAME TO sm_volume;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_upgrade.sql
deleted file mode 100644
index 53fbc69f6..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/090_sqlite_upgrade.sql
+++ /dev/null
@@ -1,226 +0,0 @@
-BEGIN TRANSACTION;
-
- -- change id and snapshot_id datatypes in volumes table
- CREATE TABLE volumes_backup(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(36),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes;
- DROP TABLE volumes;
- ALTER TABLE volumes_backup RENAME TO volumes;
-
- -- change id and volume_id datatypes in snapshots table
- CREATE TABLE snapshots_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- volume_id VARCHAR(36),
- status VARCHAR(255),
- progress VARCHAR(255),
- volume_size INTEGER,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO snapshots_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- user_id,
- project_id,
- volume_id,
- status,
- progress,
- volume_size,
- display_name,
- display_description
- FROM snapshots;
- DROP TABLE snapshots;
- ALTER TABLE snapshots_backup RENAME TO snapshots;
-
- -- change id and volume_id datatypes in iscsi_targets table
- CREATE TABLE iscsi_targets_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- target_num INTEGER,
- host VARCHAR(255),
- volume_id VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO iscsi_targets_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- target_num,
- host,
- volume_id
- FROM iscsi_targets;
- DROP TABLE iscsi_targets;
- ALTER TABLE iscsi_targets_backup RENAME TO iscsi_targets;
-
- CREATE TABLE volume_metadata_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- key VARCHAR(255),
- value VARCHAR(255),
- volume_id VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO volume_metadata_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- key,
- value,
- volume_id
- FROM volume_metadata;
- DROP TABLE volume_metadata;
- ALTER TABLE volume_metadata_backup RENAME TO volume_metadata;
-
- -- change volume_id and snapshot_id datatypes in bdm table
- CREATE TABLE block_device_mapping_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_uuid VARCHAR(36) NOT NULL,
- device_name VARCHAR(255),
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id VARCHAR(36),
- volume_id VARCHAR(36),
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info VARCHAR(255),
- FOREIGN KEY(instance_uuid) REFERENCES instances(id),
- FOREIGN KEY(volume_id) REFERENCES volumes(id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots(id),
- PRIMARY KEY (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO block_device_mapping_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_uuid,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info
- FROM block_device_mapping;
- DROP TABLE block_device_mapping;
- ALTER TABLE block_device_mapping_backup RENAME TO block_device_mapping;
-
- -- change volume_id and sm_volume_table
- CREATE TABLE sm_volume_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- backend_id INTEGER NOT NULL,
- vdi_uuid VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(id) REFERENCES volumes(id),
- UNIQUE (id),
- CHECK (deleted IN (0,1))
- );
- INSERT INTO sm_volume_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- backend_id,
- vdi_uuid
- FROM sm_volume;
- DROP TABLE sm_volume;
- ALTER TABLE sm_volume_backup RENAME TO sm_volume;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/091_convert_volume_ids_to_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/091_convert_volume_ids_to_uuid.py
deleted file mode 100644
index dadf15d30..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/091_convert_volume_ids_to_uuid.py
+++ /dev/null
@@ -1,205 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from migrate import ForeignKeyConstraint, NotSupportedError
-from sqlalchemy import MetaData, select, Table
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- """Convert volume and snapshot id columns from int to varchar."""
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
- iscsi_targets = Table('iscsi_targets', meta, autoload=True)
- volume_metadata = Table('volume_metadata', meta, autoload=True)
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
- sm_volumes = Table('sm_volume', meta, autoload=True)
-
- volume_mappings = Table('volume_id_mappings', meta, autoload=True)
- snapshot_mappings = Table('snapshot_id_mappings', meta, autoload=True)
-
- fkey_columns = [
- iscsi_targets.c.volume_id,
- volume_metadata.c.volume_id,
- sm_volumes.c.id,
- ]
- for column in fkey_columns:
- fkeys = list(column.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- LOG.info('Dropping foreign key %s' % fkey_name)
- fkey = ForeignKeyConstraint(columns=[column],
- refcolumns=[volumes.c.id],
- name=fkey_name)
- try:
- fkey.drop()
- except NotSupportedError:
- # NOTE(sirp): sqlite doesn't support ALTER TABLE DROP
- # CONSTRAINT and sqlalchemy-migrate doesn't yet have a
- # work-around using temp tables.
- pass
-
- volume_list = list(volumes.select().execute())
- for v in volume_list:
- new_id = select([volume_mappings.c.uuid],
- volume_mappings.c.id == v['id']).execute().fetchone()[0]
-
- volumes.update().\
- where(volumes.c.id == v['id']).\
- values(id=new_id).execute()
-
- sm_volumes.update().\
- where(sm_volumes.c.id == v['id']).\
- values(id=new_id).execute()
-
- snapshots.update().\
- where(snapshots.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- iscsi_targets.update().\
- where(iscsi_targets.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- volume_metadata.update().\
- where(volume_metadata.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- block_device_mapping.update().\
- where(block_device_mapping.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- snapshot_list = list(snapshots.select().execute())
- for s in snapshot_list:
- new_id = select([snapshot_mappings.c.uuid],
- snapshot_mappings.c.id == s['id']).execute().fetchone()[0]
-
- volumes.update().\
- where(volumes.c.snapshot_id == s['id']).\
- values(snapshot_id=new_id).execute()
-
- snapshots.update().\
- where(snapshots.c.id == s['id']).\
- values(id=new_id).execute()
-
- block_device_mapping.update().\
- where(block_device_mapping.c.snapshot_id == s['id']).\
- values(snapshot_id=new_id).execute()
-
- for column in fkey_columns:
- fkeys = list(column.foreign_keys)
- if fkeys:
- fkey = ForeignKeyConstraint(columns=[column],
- refcolumns=[volumes.c.id])
- fkey.create()
- LOG.info('Created foreign key %s' % fkey_name)
-
-
-def downgrade(migrate_engine):
- """Convert volume and snapshot id columns back to int."""
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
- iscsi_targets = Table('iscsi_targets', meta, autoload=True)
- volume_metadata = Table('volume_metadata', meta, autoload=True)
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
- sm_volumes = Table('sm_volume', meta, autoload=True)
-
- volume_mappings = Table('volume_id_mappings', meta, autoload=True)
- snapshot_mappings = Table('snapshot_id_mappings', meta, autoload=True)
-
- fkey_columns = [
- iscsi_targets.c.volume_id,
- volume_metadata.c.volume_id,
- sm_volumes.c.id,
- ]
- for column in fkey_columns:
- fkeys = list(column.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- LOG.info('Dropping foreign key %s' % fkey_name)
- fkey = ForeignKeyConstraint(columns=[column],
- refcolumns=[volumes.c.id],
- name=fkey_name)
- try:
- fkey.drop()
- except NotSupportedError:
- # NOTE(sirp): sqlite doesn't support ALTER TABLE DROP
- # CONSTRAINT and sqlalchemy-migrate doesn't yet have a
- # work-around using temp tables.
- pass
-
- volume_list = list(volumes.select().execute())
- for v in volume_list:
- new_id = select([volume_mappings.c.id],
- volume_mappings.c.uuid == v['id']).execute().fetchone()[0]
-
- volumes.update().\
- where(volumes.c.id == v['id']).\
- values(id=new_id).execute()
-
- sm_volumes.update().\
- where(sm_volumes.c.id == v['id']).\
- values(id=new_id).execute()
-
- snapshots.update().\
- where(snapshots.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- iscsi_targets.update().\
- where(iscsi_targets.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- volume_metadata.update().\
- where(volume_metadata.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- block_device_mapping.update().\
- where(block_device_mapping.c.volume_id == v['id']).\
- values(volume_id=new_id).execute()
-
- snapshot_list = list(snapshots.select().execute())
- for s in snapshot_list:
- new_id = select([snapshot_mappings.c.id],
- snapshot_mappings.c.uuid == s['id']).execute().fetchone()[0]
-
- volumes.update().\
- where(volumes.c.snapshot_id == s['id']).\
- values(snapshot_id=new_id).execute()
-
- snapshots.update().\
- where(snapshots.c.id == s['id']).\
- values(id=new_id).execute()
-
- block_device_mapping.update().\
- where(block_device_mapping.c.snapshot_id == s['id']).\
- values(snapshot_id=new_id).execute()
-
- for column in fkey_columns:
- fkeys = list(column.foreign_keys)
- if fkeys:
- fkey = ForeignKeyConstraint(columns=[column],
- refcolumns=[volumes.c.id])
- fkey.create()
- LOG.info('Created foreign key %s' % fkey_name)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/092_add_instance_system_metadata.py b/nova/db/sqlalchemy/migrate_repo/versions/092_add_instance_system_metadata.py
deleted file mode 100644
index 85856ed6a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/092_add_instance_system_metadata.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack, LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- instance_system_metadata = Table('instance_system_metadata', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('instance_uuid',
- String(36),
- ForeignKey('instances.uuid'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=True,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- Column('value',
- String(length=255, convert_unicode=True,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- mysql_engine='InnoDB')
-
- try:
- instance_system_metadata.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(instance_system_metadata))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- instance_system_metadata = Table(
- 'instance_system_metadata', meta, autoload=True)
- instance_system_metadata.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/093_drop_instance_actions_table.py b/nova/db/sqlalchemy/migrate_repo/versions/093_drop_instance_actions_table.py
deleted file mode 100644
index 0200861b2..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/093_drop_instance_actions_table.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack, LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, ForeignKey
-from sqlalchemy import Integer, MetaData, String, Table, Text
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_actions = Table('instance_actions', meta, autoload=True)
- instance_actions.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True,
- autoload_with=migrate_engine)
-
- instance_actions = Table('instance_actions', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('instance_id',
- Integer(),
- ForeignKey('instances.id')),
- Column('action',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('error',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
- instance_actions.create()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py b/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py
deleted file mode 100644
index 5b1d9b490..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2012 Red Hat, Inc.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import MetaData
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # NOTE(dprince): Need to rename the leftover zones stuff and quota_new
- # stuff from Essex for PostgreSQL.
- if migrate_engine.name == "postgresql":
- sql = """ALTER TABLE zones_id_seq RENAME TO cells_id_seq;
- ALTER TABLE ONLY cells DROP CONSTRAINT zones_pkey;
- ALTER TABLE ONLY cells ADD CONSTRAINT cells_pkey
- PRIMARY KEY (id);
-
- ALTER TABLE quotas_new_id_seq RENAME TO quotas_id_seq;
- ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_new_pkey;
- ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_pkey
- PRIMARY KEY (id);"""
- migrate_engine.execute(sql)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- if migrate_engine.name == "postgresql":
- sql = """ALTER TABLE cells_id_seq RENAME TO zones_id_seq;
- ALTER TABLE ONLY cells DROP CONSTRAINT cells_pkey;
- ALTER TABLE ONLY cells ADD CONSTRAINT zones_pkey
- PRIMARY KEY (id);
-
- ALTER TABLE quotas_id_seq RENAME TO quotas_new_id_seq;
- ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_pkey;
- ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_new_pkey
- PRIMARY KEY (id);"""
- migrate_engine.execute(sql)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/095_change_fk_instance_id_to_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/095_change_fk_instance_id_to_uuid.py
deleted file mode 100644
index 08501177d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/095_change_fk_instance_id_to_uuid.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# Copyright 2012 SolidFire Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, Integer, String, Table
-from sqlalchemy import select, Column
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
- volumes = Table('volumes', meta, autoload=True)
- instance_uuid_column = Column('instance_uuid', String(36))
-
- instance_uuid_column.create(volumes)
- try:
- volumes.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == volumes.c.instance_id)
- ).execute()
- except Exception:
- instance_uuid_column.drop()
-
- fkeys = list(volumes.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fk_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[volumes.c.instance_id],
- refcolumns=[instances.c.id],
- name=fk_name).drop()
-
- except Exception:
- LOG.error(_("foreign key could not be dropped"))
- raise
-
- volumes.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
- volumes = Table('volumes', meta, autoload=True)
- instance_id_column = Column('instance_id', Integer)
-
- instance_id_column.create(volumes)
- try:
- volumes.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == volumes.c.instance_uuid)
- ).execute()
- except Exception:
- instance_id_column.drop()
-
- fkeys = list(volumes.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fk_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[volumes.c.instance_id],
- refcolumns=[instances.c.id],
- name=fk_name).create()
-
- except Exception:
- LOG.error(_("foreign key could not be created"))
- raise
-
- volumes.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_downgrade.sql
deleted file mode 100644
index 7c13455e4..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_downgrade.sql
+++ /dev/null
@@ -1,133 +0,0 @@
-BEGIN TRANSACTION;
- -- change instance_id volumes table
- CREATE TABLE volumes_backup(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(36),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- instance_uuid VARCHAR(36),
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- NULL,
- instance_uuid,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes;
-
- UPDATE volumes_backup
- SET instance_id =
- (SELECT id
- FROM instances
- WHERE volumes_backup.instance_uuid = instances.uuid
- );
- DROP TABLE volumes;
-
- CREATE TABLE volumes(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(36),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY (instance_id) REFERENCES instances (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes_backup;
- DROP TABLE volumes_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_upgrade.sql
deleted file mode 100644
index 130e11030..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/095_sqlite_upgrade.sql
+++ /dev/null
@@ -1,132 +0,0 @@
-BEGIN TRANSACTION;
- -- change instance_id volumes table
- CREATE TABLE volumes_backup(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(36),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- instance_uuid VARCHAR(36),
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- instance_id,
- NULL,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes;
-
- UPDATE volumes_backup
- SET instance_uuid =
- (SELECT uuid
- FROM instances
- WHERE volumes_backup.instance_id = instances.id
- );
- DROP TABLE volumes;
-
- CREATE TABLE volumes(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id VARCHAR(36) NOT NULL,
- ec2_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- snapshot_id VARCHAR(36),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_uuid VARCHAR(36),
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(255),
- provider_auth VARCHAR(255),
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- UNIQUE (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- snapshot_id,
- host,
- size,
- availability_zone,
- instance_uuid,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- volume_type_id
- FROM volumes_backup;
- DROP TABLE volumes_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/096_recreate_dns_domains.py b/nova/db/sqlalchemy/migrate_repo/versions/096_recreate_dns_domains.py
deleted file mode 100644
index 0e51c644f..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/096_recreate_dns_domains.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2012 Red Hat, Inc.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import Boolean, Column, DateTime, ForeignKey
-from sqlalchemy import MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # NOTE(dprince): The old dns_domains table is in the 'latin1'
- # charset and had its primary key length set to 512.
- # This is too long to be a valid pkey in the 'utf8' table charset
- # and is the root cause of errors like:
- #
- # 1) Dumping a database with mysqldump and trying to import it fails
- # because this table is latin1 but fkeys to utf8 tables (projects).
- #
- # 2) Trying to alter the old dns_domains table fails with errors like:
- # mysql> ALTER TABLE dns_domains DROP PRIMARY KEY;
- # ERROR 1025 (HY000): Error on rename of './nova/#sql-6cf_855'....
- #
- # In short this table is just in a bad state. So... lets create a new one
- # with a shorter 'domain' column which is valid for the utf8 charset.
- # https://bugs.launchpad.net/nova/+bug/993663
-
- #rename old table
- dns_domains_old = Table('dns_domains', meta, autoload=True)
- dns_domains_old.rename(name='dns_domains_old')
-
- # NOTE(dprince): manually remove pkey/fkey for postgres
- if migrate_engine.name == "postgresql":
- sql = """ALTER TABLE ONLY dns_domains_old DROP CONSTRAINT
- dns_domains_pkey;
- ALTER TABLE ONLY dns_domains_old DROP CONSTRAINT
- dns_domains_project_id_fkey;"""
- migrate_engine.execute(sql)
-
- #Bind new metadata to avoid issues after the rename
- meta = MetaData()
- meta.bind = migrate_engine
- projects = Table('projects', meta, autoload=True) # Required for fkey
-
- dns_domains_new = Table('dns_domains', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('domain', String(length=255), nullable=False, primary_key=True),
- Column('scope', String(length=255)),
- Column('availability_zone', String(length=255)),
- Column('project_id', String(length=255), ForeignKey('projects.id')),
- mysql_engine='InnoDB',
- mysql_charset='utf8',
- )
- dns_domains_new.create()
-
- dns_domains_old = Table('dns_domains_old', meta, autoload=True)
- record_list = list(dns_domains_old.select().execute())
- for rec in record_list:
- row = dns_domains_new.insert()
- row.execute({'created_at': rec['created_at'],
- 'updated_at': rec['updated_at'],
- 'deleted_at': rec['deleted_at'],
- 'deleted': rec['deleted'],
- 'domain': rec['domain'],
- 'scope': rec['scope'],
- 'availability_zone': rec['availability_zone'],
- 'project_id': rec['project_id'],
- })
-
- dns_domains_old.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- dns_domains_old = Table('dns_domains', meta, autoload=True)
- dns_domains_old.rename(name='dns_domains_old')
-
- # NOTE(dprince): manually remove pkey/fkey for postgres
- if migrate_engine.name == "postgresql":
- sql = """ALTER TABLE ONLY dns_domains_old DROP CONSTRAINT
- dns_domains_pkey;
- ALTER TABLE ONLY dns_domains_old DROP CONSTRAINT
- dns_domains_project_id_fkey;"""
- migrate_engine.execute(sql)
-
- #Bind new metadata to avoid issues after the rename
- meta = MetaData()
- meta.bind = migrate_engine
-
- dns_domains_new = Table('dns_domains', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('domain', String(length=512), primary_key=True, nullable=False),
- Column('scope', String(length=255)),
- Column('availability_zone', String(length=255)),
- Column('project_id', String(length=255)),
- mysql_engine='InnoDB',
- mysql_charset='latin1',
- )
- dns_domains_new.create()
-
- dns_domains_old = Table('dns_domains_old', meta, autoload=True)
- record_list = list(dns_domains_old.select().execute())
- for rec in record_list:
- row = dns_domains_new.insert()
- row.execute({'created_at': rec['created_at'],
- 'updated_at': rec['updated_at'],
- 'deleted_at': rec['deleted_at'],
- 'deleted': rec['deleted'],
- 'domain': rec['domain'],
- 'scope': rec['scope'],
- 'availability_zone': rec['availability_zone'],
- 'project_id': rec['project_id'],
- })
-
- dns_domains_old.drop()
-
- # NOTE(dprince): We can't easily add the MySQL Fkey on the downgrade
- # because projects is 'utf8' where dns_domains is 'latin1'.
- if migrate_engine.name != "mysql":
- projects = Table('projects', meta, autoload=True)
- fkey = ForeignKeyConstraint(columns=[dns_domains_new.c.project_id],
- refcolumns=[projects.c.id])
- fkey.create()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/097_quota_usages_reservations.py b/nova/db/sqlalchemy/migrate_repo/versions/097_quota_usages_reservations.py
deleted file mode 100644
index 82d66938c..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/097_quota_usages_reservations.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime
-from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # New tables
- quota_usages = Table('quota_usages', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True),
- Column('project_id',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- index=True),
- Column('resource',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('in_use', Integer(), nullable=False),
- Column('reserved', Integer(), nullable=False),
- Column('until_refresh', Integer(), nullable=True),
- mysql_engine='InnoDB',
- mysql_charset='utf8',
- )
-
- try:
- quota_usages.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(quota_usages))
- raise
-
- reservations = Table('reservations', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True),
- Column('uuid',
- String(length=36, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False), nullable=False),
- Column('usage_id', Integer(), ForeignKey('quota_usages.id'),
- nullable=False),
- Column('project_id',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- index=True),
- Column('resource',
- String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('delta', Integer(), nullable=False),
- Column('expire', DateTime(timezone=False)),
- mysql_engine='InnoDB',
- mysql_charset='utf8',
- )
-
- try:
- reservations.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(reservations))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- quota_usages = Table('quota_usages', meta, autoload=True)
- try:
- quota_usages.drop()
- except Exception:
- LOG.error(_("quota_usages table not dropped"))
- raise
-
- reservations = Table('reservations', meta, autoload=True)
- try:
- reservations.drop()
- except Exception:
- LOG.error(_("reservations table not dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py b/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py
deleted file mode 100644
index 680b27df7..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright (c) 2012 Canonical Ltd.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import select, Column, Table, MetaData, String, DateTime
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
- attach_datetime = Column('attachtime_datetime', DateTime(timezone=False))
- attach_datetime.create(volumes)
-
- old_attachtime = volumes.c.attach_time
-
- try:
- volumes_list = list(volumes.select().execute())
- for v in volumes_list:
- attach_time = select([volumes.c.attach_time],
- volumes.c.id == v['id']).execute().fetchone()[0]
- volumes.update().\
- where(volumes.c.id == v['id']).\
- values(attachtime_datetime=attach_time).execute()
- except Exception:
- attach_datetime.drop()
- raise
-
- old_attachtime.alter(name='attach_time_old')
- attach_datetime.alter(name='attach_time')
- old_attachtime.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
- attach_string = Column('attachtime_string', String(255))
- attach_string.create(volumes)
-
- old_attachtime = volumes.c.attach_time
-
- try:
- volumes_list = list(volumes.select().execute())
- for v in volumes_list:
- attach_time = select([volumes.c.attach_time],
- volumes.c.id == v['id']).execute().fetchone()[0]
- volumes.update().\
- where(volumes.c.id == v['id']).\
- values(attachtime_string=attach_time).execute()
- except Exception:
- attach_string.drop()
- raise
-
- old_attachtime.alter(name='attach_time_old')
- attach_string.alter(name='attach_time')
- old_attachtime.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/099_add_disabled_instance_types.py b/nova/db/sqlalchemy/migrate_repo/versions/099_add_disabled_instance_types.py
deleted file mode 100644
index 549426608..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/099_add_disabled_instance_types.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, MetaData, Table
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- disabled = Column('disabled', Boolean)
-
- instance_types.create_column(disabled)
- instance_types.update().values(disabled=False).execute()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- disabled = Column('disabled', Boolean)
-
- instance_types.drop_column(disabled)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/100_instance_metadata_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/100_instance_metadata_uses_uuid.py
deleted file mode 100644
index e5c2a275d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/100_instance_metadata_uses_uuid.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_metadata = Table('instance_metadata', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(instance_metadata)
-
- try:
- instance_metadata.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == instance_metadata.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(instance_metadata.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[instance_metadata.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- instance_metadata.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_metadata = Table('instance_metadata', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(instance_metadata)
-
- try:
- instance_metadata.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == instance_metadata.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- instance_metadata.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_downgrade.sql
deleted file mode 100644
index 97b628c6e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_downgrade.sql
+++ /dev/null
@@ -1,64 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE instance_metadata_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- key VARCHAR(255) NOT NULL,
- value VARCHAR(255) NOT NULL,
- PRIMARY KEY (id)
- );
-
- INSERT INTO instance_metadata_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- NULL,
- instance_uuid,
- key,
- value
- FROM instance_metadata;
-
- UPDATE instance_metadata_backup
- SET instance_id=
- (SELECT id
- FROM instances
- WHERE instance_metadata_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE instance_metadata;
-
- CREATE TABLE instance_metadata (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- key VARCHAR(255) NOT NULL,
- value VARCHAR(255) NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE INDEX instance_metadata_instance_id_idx ON instance_metadata(instance_id);
-
- INSERT INTO instance_metadata
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- key,
- value
- FROM instance_metadata_backup;
-
- DROP TABLE instance_metadata_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_upgrade.sql
deleted file mode 100644
index 0d1e1ca8b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/100_sqlite_upgrade.sql
+++ /dev/null
@@ -1,64 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE instance_metadata_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- key VARCHAR(255) NOT NULL,
- value VARCHAR(255) NOT NULL,
- PRIMARY KEY (id)
- );
-
- INSERT INTO instance_metadata_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- NULL,
- key,
- value
- FROM instance_metadata;
-
- UPDATE instance_metadata_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE instance_metadata_backup.instance_id = instances.id
- );
-
- DROP TABLE instance_metadata;
-
- CREATE TABLE instance_metadata (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_uuid VARCHAR(36) NOT NULL,
- key VARCHAR(255) NOT NULL,
- value VARCHAR(255) NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- CREATE INDEX instance_metadata_instance_uuid_idx ON instance_metadata(instance_uuid);
-
- INSERT INTO instance_metadata
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_uuid,
- key,
- value
- FROM instance_metadata_backup;
-
- DROP TABLE instance_metadata_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/101_security_group_instance_association_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/101_security_group_instance_association_uses_uuid.py
deleted file mode 100644
index 26b53bb7e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/101_security_group_instance_association_uses_uuid.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- sgia = Table('security_group_instance_association', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(sgia)
-
- try:
- sgia.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == sgia.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(sgia.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[sgia.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- sgia.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- sgia = Table('security_group_instance_association', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(sgia)
-
- try:
- sgia.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == sgia.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- sgia.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_downgrade.sql
deleted file mode 100644
index 08aaa241c..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_downgrade.sql
+++ /dev/null
@@ -1,61 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE security_group_instance_association_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- security_group_id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO security_group_instance_association_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- security_group_id,
- NULL,
- instance_uuid
- FROM security_group_instance_association;
-
- UPDATE security_group_instance_association_backup
- SET instance_id=
- (SELECT id
- FROM instances
- WHERE security_group_instance_association_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE security_group_instance_association;
-
- CREATE TABLE security_group_instance_association (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- security_group_id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE INDEX security_group_instance_association_security_group_id_idx ON security_group_instance_association(security_group_id);
- CREATE INDEX security_group_instance_association_instance_id_idx ON security_group_instance_association(instance_id);
-
- INSERT INTO security_group_instance_association
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- security_group_id,
- instance_id
- FROM security_group_instance_association_backup;
-
- DROP TABLE security_group_instance_association_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_upgrade.sql
deleted file mode 100644
index d66c5ce37..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/101_sqlite_upgrade.sql
+++ /dev/null
@@ -1,61 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE security_group_instance_association_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- security_group_id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO security_group_instance_association_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- security_group_id,
- instance_id,
- NULL
- FROM security_group_instance_association;
-
- UPDATE security_group_instance_association_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE security_group_instance_association_backup.instance_id = instances.id
- );
-
- DROP TABLE security_group_instance_association;
-
- CREATE TABLE security_group_instance_association (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- security_group_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- CREATE INDEX security_group_instance_association_security_group_id_idx ON security_group_instance_association(security_group_id);
- CREATE INDEX security_group_instance_association_instance_uuid_idx ON security_group_instance_association(instance_uuid);
-
- INSERT INTO security_group_instance_association
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- security_group_id,
- instance_uuid
- FROM security_group_instance_association_backup;
-
- DROP TABLE security_group_instance_association_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/102_consoles_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/102_consoles_uses_uuid.py
deleted file mode 100644
index 1cfa523c6..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/102_consoles_uses_uuid.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- consoles = Table('consoles', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(consoles)
-
- try:
- consoles.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == consoles.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(consoles.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[consoles.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- consoles.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- consoles = Table('consoles', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(consoles)
-
- try:
- consoles.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == consoles.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- consoles.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_downgrade.sql
deleted file mode 100644
index 50f260549..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_downgrade.sql
+++ /dev/null
@@ -1,72 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE consoles_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_name VARCHAR(255),
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- password VARCHAR(255),
- port INTEGER,
- pool_id INTEGER,
- PRIMARY KEY (id)
- );
-
- INSERT INTO consoles_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_name,
- NULL,
- instance_uuid,
- password,
- port,
- pool_id
- FROM consoles;
-
- UPDATE consoles_backup
- SET instance_uuid=
- (SELECT id
- FROM instances
- WHERE consoles_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE consoles;
-
- CREATE TABLE consoles (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_name VARCHAR(255),
- instance_id INTEGER NOT NULL,
- password VARCHAR(255),
- port INTEGER,
- pool_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE INDEX consoles_pool_id ON consoles(pool_id);
-
- INSERT INTO consoles
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_name,
- instance_id,
- password,
- port,
- pool_id
- FROM consoles_backup;
-
- DROP TABLE consoles_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_upgrade.sql
deleted file mode 100644
index ef48162bc..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/102_sqlite_upgrade.sql
+++ /dev/null
@@ -1,72 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE consoles_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_name VARCHAR(255),
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- password VARCHAR(255),
- port INTEGER,
- pool_id INTEGER,
- PRIMARY KEY (id)
- );
-
- INSERT INTO consoles_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_name,
- instance_id,
- NULL,
- password,
- port,
- pool_id
- FROM consoles;
-
- UPDATE consoles_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE consoles_backup.instance_id = instances.id
- );
-
- DROP TABLE consoles;
-
- CREATE TABLE consoles (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_name VARCHAR(255),
- instance_uuid VARCHAR(36),
- password VARCHAR(255),
- port INTEGER,
- pool_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- CREATE INDEX consoles_pool_id ON consoles(pool_id);
-
- INSERT INTO consoles
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_name,
- instance_uuid,
- password,
- port,
- pool_id
- FROM consoles_backup;
-
- DROP TABLE consoles_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/103_instance_indexes.py b/nova/db/sqlalchemy/migrate_repo/versions/103_instance_indexes.py
deleted file mode 100644
index 0eeac2587..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/103_instance_indexes.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- for table in ['block_device_mapping',
- 'consoles',
- 'volumes']:
- t = Table(table, meta, autoload=True)
- i = Index('%s_instance_uuid_idx' % table, t.c.instance_uuid)
- i.create(migrate_engine)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- for table in ['block_device_mapping',
- 'consoles',
- 'volumes']:
- t = Table(table, meta, autoload=True)
- i = Index('%s_instance_uuid_idx' % table, t.c.instance_uuid)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/104_instance_indexes_2.py b/nova/db/sqlalchemy/migrate_repo/versions/104_instance_indexes_2.py
deleted file mode 100644
index 4bf6b0484..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/104_instance_indexes_2.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # NOTE(mikal): these weren't done in 103 because sqlite already has the
- # index.
- for table in ['instance_metadata',
- 'security_group_instance_association']:
- t = Table(table, meta, autoload=True)
- i = Index('%s_instance_uuid_idx' % table, t.c.instance_uuid)
- i.create(migrate_engine)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- for table in ['instance_metadata',
- 'security_group_instance_association']:
- t = Table(table, meta, autoload=True)
- i = Index('%s_instance_uuid_idx' % table, t.c.instance_uuid)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_downgrade.sql
deleted file mode 100644
index 8d115abb8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_downgrade.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT 'noop'; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_upgrade.sql
deleted file mode 100644
index 8d115abb8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/104_sqlite_upgrade.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT 'noop'; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/105_instance_info_caches_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/105_instance_info_caches_uses_uuid.py
deleted file mode 100644
index c4c13e539..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/105_instance_info_caches_uses_uuid.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import MetaData, Table
-from migrate import ForeignKeyConstraint
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
-
- # We need to remove the foreign key constraint or the column rename will
- # fail
- fkeys = list(instance_info_caches.c.instance_id.foreign_keys)
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[instance_info_caches.c.instance_id],
- refcolumns=[instances.c.uuid],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- instance_info_caches.c.instance_id.alter(name='instance_uuid')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
-
- # We need to remove the foreign key constraint or the column rename will
- # fail
- fkeys = list(instance_info_caches.c.instance_uuid.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[instance_info_caches.c.instance_uuid],
- refcolumns=[instances.c.uuid],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- instance_info_caches.c.instance_uuid.alter(name='instance_id')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_downgrade.sql
deleted file mode 100644
index 563b1245a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_downgrade.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE instance_info_caches_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- network_info TEXT,
- instance_id VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO instance_info_caches_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- network_info,
- instance_uuid as instance_id
- FROM instance_info_caches;
-
- DROP TABLE instance_info_caches;
-
- CREATE TABLE instance_info_caches (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- network_info TEXT,
- instance_id VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- CREATE INDEX instance_info_caches_instance_id_idx ON instance_info_caches(instance_id);
-
- INSERT INTO instance_info_caches
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- network_info,
- instance_id
- FROM instance_info_caches_backup;
-
- DROP TABLE instance_info_caches_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_upgrade.sql
deleted file mode 100644
index 4e675749e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/105_sqlite_upgrade.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE instance_info_caches_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- network_info TEXT,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO instance_info_caches_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- network_info,
- instance_id as instance_uuid
- FROM instance_info_caches;
-
- DROP TABLE instance_info_caches;
-
- CREATE TABLE instance_info_caches (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- network_info TEXT,
- instance_uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- CREATE INDEX instance_info_caches_instance_uuid_idx ON instance_info_caches(instance_uuid);
-
- INSERT INTO instance_info_caches
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- network_info,
- instance_uuid
- FROM instance_info_caches_backup;
-
- DROP TABLE instance_info_caches_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/106_add_foreign_keys.py b/nova/db/sqlalchemy/migrate_repo/versions/106_add_foreign_keys.py
deleted file mode 100644
index 2c483007c..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/106_add_foreign_keys.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import MetaData, Table
-from migrate import ForeignKeyConstraint
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- for table in ['block_device_mapping',
- 'consoles',
- 'instance_info_caches',
- 'instance_metadata',
- 'security_group_instance_association']:
- t = Table(table, meta, autoload=True)
-
- try:
- ForeignKeyConstraint(
- columns=[t.c.instance_uuid],
- refcolumns=[instances.c.uuid]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be created"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- for table in ['block_device_mapping',
- 'consoles',
- 'instance_info_caches',
- 'instance_metadata',
- 'security_group_instance_association']:
- t = Table(table, meta, autoload=True)
-
- try:
- ForeignKeyConstraint(
- columns=[t.c.instance_uuid],
- refcolumns=[instances.c.uuid]).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_downgrade.sql
deleted file mode 100644
index 8d115abb8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_downgrade.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT 'noop'; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_upgrade.sql
deleted file mode 100644
index 8d115abb8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/106_sqlite_upgrade.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT 'noop'; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/107_add_instance_id_mappings.py b/nova/db/sqlalchemy/migrate_repo/versions/107_add_instance_id_mappings.py
deleted file mode 100644
index 250906c62..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/107_add_instance_id_mappings.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2012 SINA Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from nova.openstack.common import log as logging
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import MetaData, String, Table
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # create new table
- instance_id_mappings = Table('instance_id_mappings', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted',
- Boolean(create_constraint=True, name=None)),
- Column('id', Integer(),
- primary_key=True,
- nullable=False,
- autoincrement=True),
- Column('uuid', String(36), index=True, nullable=False))
- try:
- instance_id_mappings.create()
- except Exception:
- LOG.exception("Exception while creating table 'instance_id_mappings'")
- meta.drop_all(tables=[instance_id_mappings])
- raise
-
- if migrate_engine.name == "mysql":
- migrate_engine.execute("ALTER TABLE instance_id_mappings "
- "Engine=InnoDB")
-
- instances = Table('instances', meta, autoload=True)
- instance_id_mappings = Table('instance_id_mappings', meta, autoload=True)
-
- instance_list = list(instances.select().execute())
- for instance in instance_list:
- instance_id = instance['id']
- uuid = instance['uuid']
- row = instance_id_mappings.insert()
- row.execute({'id': instance_id, 'uuid': uuid})
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_id_mappings = Table('instance_id_mappings', meta, autoload=True)
- instance_id_mappings.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/108_task_log.py b/nova/db/sqlalchemy/migrate_repo/versions/108_task_log.py
deleted file mode 100644
index d8593bd77..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/108_task_log.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2012 SINA Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # create new table
- task_log = Table('task_log', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted',
- Boolean(create_constraint=True, name=None)),
- Column('id', Integer(),
- primary_key=True,
- nullable=False,
- autoincrement=True),
- Column('task_name', String(255), nullable=False),
- Column('state', String(255), nullable=False),
- Column('host', String(255), index=True, nullable=False),
- Column('period_beginning', String(255),
- index=True, nullable=False),
- Column('period_ending', String(255), index=True, nullable=False),
- Column('message', String(255), nullable=False),
- Column('task_items', Integer()),
- Column('errors', Integer()),
- )
- try:
- task_log.create()
- except Exception:
- meta.drop_all(tables=[task_log])
- raise
-
- if migrate_engine.name == "mysql":
- migrate_engine.execute("ALTER TABLE task_log "
- "Engine=InnoDB")
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- task_log = Table('task_log', meta, autoload=True)
- task_log.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/109_drop_dns_domains_project_id_fkey.py b/nova/db/sqlalchemy/migrate_repo/versions/109_drop_dns_domains_project_id_fkey.py
deleted file mode 100644
index a2b0792d3..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/109_drop_dns_domains_project_id_fkey.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, Table
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- dns_domains = Table('dns_domains', meta, autoload=True)
- projects = Table('projects', meta, autoload=True)
-
- fkeys = list(dns_domains.c.project_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[dns_domains.c.project_id],
- refcolumns=[projects.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- dns_domains = Table('dns_domains', meta, autoload=True)
- projects = Table('projects', meta, autoload=True)
-
- kwargs = {
- 'columns': [dns_domains.c.project_id],
- 'refcolumns': [projects.c.id],
- }
-
- if migrate_engine.name == 'mysql':
- # For MySQL we name our fkeys explicitly so they match Essex
- kwargs['name'] = 'dns_domains_ibfk_1'
-
- ForeignKeyConstraint(**kwargs).create()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_downgrade.sql
deleted file mode 100644
index ffb4d132e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_downgrade.sql
+++ /dev/null
@@ -1,53 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE dns_domains_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- domain VARCHAR(512) NOT NULL,
- scope VARCHAR(255),
- availability_zone VARCHAR(255),
- project_id VARCHAR(255),
- PRIMARY KEY (domain)
- );
-
- INSERT INTO dns_domains_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- domain,
- scope,
- availability_zone,
- project_id
- FROM dns_domains;
-
- DROP TABLE dns_domains;
-
- CREATE TABLE dns_domains (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- domain VARCHAR(512) NOT NULL,
- scope VARCHAR(255),
- availability_zone VARCHAR(255),
- project_id VARCHAR(255),
- PRIMARY KEY (domain),
- FOREIGN KEY (project_id) REFERENCES projects (id)
- );
-
- INSERT INTO dns_domains
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- domain,
- scope,
- availability_zone,
- project_id
- FROM dns_domains_backup;
-
- DROP TABLE dns_domains_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_upgrade.sql
deleted file mode 100644
index eeb481658..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/109_sqlite_upgrade.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE dns_domains_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- domain VARCHAR(512) NOT NULL,
- scope VARCHAR(255),
- availability_zone VARCHAR(255),
- project_id VARCHAR(255),
- PRIMARY KEY (domain)
- );
-
- INSERT INTO dns_domains_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- domain,
- scope,
- availability_zone,
- project_id
- FROM dns_domains;
-
- DROP TABLE dns_domains;
-
- CREATE TABLE dns_domains (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- domain VARCHAR(512) NOT NULL,
- scope VARCHAR(255),
- availability_zone VARCHAR(255),
- project_id VARCHAR(255),
- PRIMARY KEY (domain)
- );
-
- INSERT INTO dns_domains
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- domain,
- scope,
- availability_zone,
- project_id
- FROM dns_domains_backup;
-
- DROP TABLE dns_domains_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/110_drop_deprecated_auth.py b/nova/db/sqlalchemy/migrate_repo/versions/110_drop_deprecated_auth.py
deleted file mode 100644
index 734a3729f..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/110_drop_deprecated_auth.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import (Boolean, Column, DateTime, ForeignKey,
- Index, MetaData, String, Table)
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- tables = (
- "user_project_role_association",
- "user_project_association",
- "user_role_association",
- "projects",
- "users",
- "auth_tokens",
- )
- for table_name in tables:
- Table(table_name, meta, autoload=True).drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- auth_tokens = Table('auth_tokens', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('token_hash', String(length=255), primary_key=True,
- nullable=False),
- Column('user_id', String(length=255)),
- Column('server_management_url', String(length=255)),
- Column('storage_url', String(length=255)),
- Column('cdn_management_url', String(length=255)),
- mysql_engine='InnoDB',
- )
-
- projects = Table('projects', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('id', String(length=255), primary_key=True, nullable=False),
- Column('name', String(length=255)),
- Column('description', String(length=255)),
- Column('project_manager', String(length=255), ForeignKey('users.id')),
- mysql_engine='InnoDB',
- )
-
- user_project_association = Table('user_project_association', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('user_id', String(length=255), primary_key=True,
- nullable=False),
- Column('project_id', String(length=255), primary_key=True,
- nullable=False),
- mysql_engine='InnoDB',
- )
-
- user_project_role_association = \
- Table('user_project_role_association', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('user_id', String(length=255), primary_key=True,
- nullable=False),
- Column('project_id', String(length=255), primary_key=True,
- nullable=False),
- Column('role', String(length=255), primary_key=True, nullable=False),
- mysql_engine='InnoDB',
- )
-
- user_role_association = Table('user_role_association', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('user_id', String(length=255), ForeignKey('users.id'),
- primary_key=True, nullable=False),
- Column('role', String(length=255), primary_key=True, nullable=False),
- mysql_engine='InnoDB',
- )
-
- users = Table('users', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('id', String(length=255), primary_key=True, nullable=False),
- Column('name', String(length=255)),
- Column('access_key', String(length=255)),
- Column('secret_key', String(length=255)),
- Column('is_admin', Boolean),
- mysql_engine='InnoDB',
- )
-
- tables = [users, projects, user_project_association,
- auth_tokens, user_project_role_association,
- user_role_association]
-
- for table in tables:
- try:
- table.create()
- except Exception:
- LOG.exception('Exception while creating table.')
- raise
-
- if migrate_engine.name == 'mysql':
- index = Index('project_id', user_project_association.c.project_id)
- index.create(migrate_engine)
-
- fkeys = [
- [
- [user_project_role_association.c.user_id,
- user_project_role_association.c.project_id],
- [user_project_association.c.user_id,
- user_project_association.c.project_id],
- 'user_project_role_association_ibfk_1',
- ],
- [
- [user_project_association.c.user_id],
- [users.c.id],
- 'user_project_association_ibfk_1',
- ],
- [
- [user_project_association.c.project_id],
- [projects.c.id],
- 'user_project_association_ibfk_2',
- ],
- ]
-
- for fkey_pair in fkeys:
- if migrate_engine.name == 'mysql':
- # For MySQL we name our fkeys explicitly so they match Essex
- fkey = ForeignKeyConstraint(columns=fkey_pair[0],
- refcolumns=fkey_pair[1],
- name=fkey_pair[2])
- fkey.create()
- elif migrate_engine.name == 'postgresql':
- fkey = ForeignKeyConstraint(columns=fkey_pair[0],
- refcolumns=fkey_pair[1])
- fkey.create()
-
- # Hopefully this entire loop to set the charset can go away during
- # the "E" release compaction. See the notes on the dns_domains
- # table above for why this is required vs. setting mysql_charset inline.
- if migrate_engine.name == "mysql":
- tables = [
- # tables that are FK parents, must be converted early
- "projects",
- "user_project_association",
- "users",
- # those that are children and others later
- "auth_tokens",
- "user_project_role_association",
- "user_role_association",
- ]
- sql = "SET foreign_key_checks = 0;"
- for table in tables:
- sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
- sql += "SET foreign_key_checks = 1;"
- sql += "ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" \
- % migrate_engine.url.database
- migrate_engine.execute(sql)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py b/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py
deleted file mode 100644
index df4a83843..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import String, Column, MetaData, Table, delete, select
-from migrate.changeset import UniqueConstraint
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- dialect = migrate_engine.url.get_dialect().name
-
- aggregates = Table('aggregates', meta, autoload=True)
- aggregate_metadata = Table('aggregate_metadata', meta, autoload=True)
- record_list = list(aggregates.select().execute())
- for rec in record_list:
- row = aggregate_metadata.insert()
- row.execute({'created_at': rec['created_at'],
- 'updated_at': rec['updated_at'],
- 'deleted_at': rec['deleted_at'],
- 'deleted': rec['deleted'],
- 'key': 'operational_state',
- 'value': rec['operational_state'],
- 'aggregate_id': rec['id'],
- })
- aggregates.drop_column('operational_state')
-
- aggregate_hosts = Table('aggregate_hosts', meta, autoload=True)
- if dialect.startswith('sqlite'):
- aggregate_hosts.c.host.alter(unique=False)
- elif dialect.startswith('postgres'):
- ucon = UniqueConstraint('host',
- name='aggregate_hosts_host_key',
- table=aggregate_hosts)
- ucon.drop()
- else:
- col = aggregate_hosts.c.host
- UniqueConstraint(col, name='host').drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- aggregates = Table('aggregates', meta, autoload=True)
- aggregate_metadata = Table('aggregate_metadata', meta, autoload=True)
- operational_state = Column('operational_state', String(255))
- aggregates.create_column(operational_state)
- aggregates.update().values(operational_state=select(
- [aggregate_metadata.c.value]).where(aggregates.c.id ==
- aggregate_metadata.c.aggregate_id and aggregate_metadata.c.key ==
- 'operational_state')).execute()
- delete(aggregate_metadata, aggregate_metadata.c.key == 'operational_state')
- aggregates.c.operational_state.alter(nullable=False)
- aggregate_hosts = Table('aggregate_hosts', meta, autoload=True)
- aggregate_hosts.c.host.alter(unique=True)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/112_update_deleted_instance_data.py b/nova/db/sqlalchemy/migrate_repo/versions/112_update_deleted_instance_data.py
deleted file mode 100644
index 27ad13e91..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/112_update_deleted_instance_data.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import datetime
-from sqlalchemy import MetaData, Table
-from sqlalchemy import and_, between
-
-
-TABLES = ('instance_metadata',
- 'instance_system_metadata',
- 'block_device_mapping')
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- instance_list = list(instances.select().
- where(instances.c.deleted == True).execute())
- for table_name in TABLES:
- table = Table(table_name, meta, autoload=True)
-
- for instance in instance_list:
- if not instance['deleted_at']:
- continue
- table.update(
- (and_(table.c.deleted == True,
- table.c.instance_uuid == instance['uuid'],
- between(table.c.deleted_at,
- instance['deleted_at'] - datetime.timedelta(seconds=2),
- instance['deleted_at'] + datetime.timedelta(seconds=2)))
- ),
- {table.c.deleted: False,
- table.c.deleted_at: None}
- ).execute()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- instance_list = list(instances.select().
- where(instances.c.deleted == True).execute())
- for table_name in TABLES:
- table = Table(table_name, meta, autoload=True)
- for instance in instance_list:
- table.update(
- (and_(table.c.deleted == False,
- table.c.instance_uuid == instance['uuid'])
- ),
- {table.c.deleted: True,
- table.c.deleted_at: instance['deleted_at']}
- ).execute()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/113_fixed_ips_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/113_fixed_ips_uses_uuid.py
deleted file mode 100644
index d51bbb912..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/113_fixed_ips_uses_uuid.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(fixed_ips)
-
- try:
- fixed_ips.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == fixed_ips.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(fixed_ips.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[fixed_ips.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- fixed_ips.c.instance_id.drop()
-
- try:
- ForeignKeyConstraint(
- columns=[fixed_ips.c.instance_uuid],
- refcolumns=[instances.c.uuid]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be created"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(fixed_ips)
-
- fkeys = list(fixed_ips.c.instance_uuid.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[fixed_ips.c.instance_uuid],
- refcolumns=[instances.c.uuid],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- try:
- fixed_ips.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == fixed_ips.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- fixed_ips.c.instance_uuid.drop()
-
- try:
- ForeignKeyConstraint(
- columns=[fixed_ips.c.instance_id],
- refcolumns=[instances.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be created"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_downgrade.sql
deleted file mode 100644
index 0a7a7bed9..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_downgrade.sql
+++ /dev/null
@@ -1,85 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE fixed_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- virtual_interface_id INTEGER,
- host VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- NULL,
- instance_uuid,
- allocated,
- leased,
- reserved,
- virtual_interface_id,
- host
- FROM fixed_ips;
-
- UPDATE fixed_ips_backup
- SET instance_id=
- (SELECT id
- FROM instances
- WHERE fixed_ips_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- virtual_interface_id INTEGER,
- host VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE INDEX fixed_ips_id ON fixed_ips(id);
- CREATE INDEX address ON fixed_ips(address);
-
- INSERT INTO fixed_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- virtual_interface_id,
- host
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_upgrade.sql
deleted file mode 100644
index 417b5bfe3..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/113_sqlite_upgrade.sql
+++ /dev/null
@@ -1,85 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE fixed_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- instance_uuid VARCHAR(36),
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- virtual_interface_id INTEGER,
- host VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- NULL,
- allocated,
- leased,
- reserved,
- virtual_interface_id,
- host
- FROM fixed_ips;
-
- UPDATE fixed_ips_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE fixed_ips_backup.instance_id = instances.id
- );
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_uuid VARCHAR(36),
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- virtual_interface_id INTEGER,
- host VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- CREATE INDEX fixed_ips_id ON fixed_ips(id);
- CREATE INDEX address ON fixed_ips(address);
-
- INSERT INTO fixed_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_uuid,
- allocated,
- leased,
- reserved,
- virtual_interface_id,
- host
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_downgrade.sql
deleted file mode 100644
index bb210025a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_downgrade.sql
+++ /dev/null
@@ -1,71 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- instance_uuid VARCHAR(36),
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- NULL,
- instance_uuid,
- uuid
- FROM virtual_interfaces;
-
- UPDATE virtual_interfaces_backup
- SET instance_id=
- (SELECT id
- FROM instances
- WHERE virtual_interfaces_backup.instance_uuid = instances.uuid
- );
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id VARCHAR(36) NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE INDEX virtual_interfaces_instance_id ON
- virtual_interfaces(instance_id);
- CREATE INDEX virtual_interfaces_network_id ON
- virtual_interfaces(network_id);
-
- INSERT INTO virtual_interfaces
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT; \ No newline at end of file
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_upgrade.sql
deleted file mode 100644
index 5ee98d5c1..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/114_sqlite_upgrade.sql
+++ /dev/null
@@ -1,71 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- instance_uuid VARCHAR(36),
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- NULL,
- uuid
- FROM virtual_interfaces;
-
- UPDATE virtual_interfaces_backup
- SET instance_uuid=
- (SELECT uuid
- FROM instances
- WHERE virtual_interfaces_backup.instance_id = instances.id
- );
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_uuid VARCHAR(36) NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_uuid) REFERENCES instances (uuid)
- );
-
- CREATE INDEX virtual_interfaces_instance_uuid ON
- virtual_interfaces(instance_uuid);
- CREATE INDEX virtual_interfaces_network_id ON
- virtual_interfaces(network_id);
-
- INSERT INTO virtual_interfaces
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_uuid,
- uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/114_vifs_uses_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/114_vifs_uses_uuid.py
deleted file mode 100644
index 8f7ad1a15..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/114_vifs_uses_uuid.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2012 Michael Still and Canonical Inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from migrate import ForeignKeyConstraint
-from sqlalchemy import MetaData, String, Table
-from sqlalchemy import select, Column, ForeignKey, Integer
-
-from nova.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(virtual_interfaces)
-
- try:
- virtual_interfaces.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == virtual_interfaces.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- fkeys = list(virtual_interfaces.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[virtual_interfaces.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- virtual_interfaces.c.instance_id.drop()
-
- try:
- ForeignKeyConstraint(
- columns=[virtual_interfaces.c.instance_uuid],
- refcolumns=[instances.c.uuid]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be created"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(virtual_interfaces)
-
- fkeys = list(virtual_interfaces.c.instance_uuid.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(
- columns=[virtual_interfaces.c.instance_uuid],
- refcolumns=[instances.c.uuid],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- try:
- virtual_interfaces.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == virtual_interfaces.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- virtual_interfaces.c.instance_uuid.drop()
-
- try:
- ForeignKeyConstraint(
- columns=[virtual_interfaces.c.instance_id],
- refcolumns=[instances.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be created"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/115_make_user_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/115_make_user_quotas_key_and_value.py
deleted file mode 100644
index 447307952..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/115_make_user_quotas_key_and_value.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from nova.openstack.common import log as logging
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import MetaData, String, Table
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Add 'user_id' column to quota_usages table.
- quota_usages = Table('quota_usages', meta, autoload=True)
- user_id = Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False))
- quota_usages.create_column(user_id)
-
- # Add 'user_id' column to reservations table.
- reservations = Table('reservations', meta, autoload=True)
- user_id = Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False))
- reservations.create_column(user_id)
-
- # New table.
- user_quotas = Table('user_quotas', meta,
- Column('id', Integer(), primary_key=True),
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(), default=False),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('resource',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=False),
- Column('hard_limit', Integer(), nullable=True),
- mysql_engine='InnoDB',
- mysql_charset='utf8',
- )
-
- try:
- user_quotas.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(user_quotas))
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- quota_usages = Table('quota_usages', meta, autoload=True)
- quota_usages.drop_column('user_id')
-
- reservations = Table('reservations', meta, autoload=True)
- reservations.drop_column('user_id')
-
- user_quotas = Table('user_quotas', meta, autoload=True)
- try:
- user_quotas.drop()
- except Exception:
- LOG.error(_("user_quotas table not dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/116_drop_user_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/116_drop_user_quotas_key_and_value.py
deleted file mode 100644
index ccf9d66b8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/116_drop_user_quotas_key_and_value.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from nova.openstack.common import log as logging
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import MetaData, String, Table
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Reverse the previous migration
- meta = MetaData()
- meta.bind = migrate_engine
-
- reservations = Table('reservations', meta, autoload=True)
- d = reservations.delete(reservations.c.deleted == True)
- d.execute()
- reservations.drop_column('user_id')
-
- quota_usages = Table('quota_usages', meta, autoload=True)
- d = quota_usages.delete(quota_usages.c.user_id != None)
- d.execute()
- quota_usages.drop_column('user_id')
-
- user_quotas = Table('user_quotas', meta, autoload=True)
- try:
- user_quotas.drop()
- except Exception:
- LOG.error(_("user_quotas table not dropped"))
- raise
-
-
-def downgrade(migrate_engine):
- # Undo the reversal of the previous migration
- # (data is not preserved)
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Add 'user_id' column to quota_usages table.
- quota_usages = Table('quota_usages', meta, autoload=True)
- user_id = Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False))
- quota_usages.create_column(user_id)
-
- # Add 'user_id' column to reservations table.
- reservations = Table('reservations', meta, autoload=True)
- user_id = Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False))
- reservations.create_column(user_id)
-
- # New table.
- user_quotas = Table('user_quotas', meta,
- Column('id', Integer(), primary_key=True),
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(), default=False),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('resource',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=False),
- Column('hard_limit', Integer(), nullable=True),
- mysql_engine='InnoDB',
- mysql_charset='utf8',
- )
-
- try:
- user_quotas.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(user_quotas))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/117_add_compute_node_stats.py b/nova/db/sqlalchemy/migrate_repo/versions/117_add_compute_node_stats.py
deleted file mode 100644
index 5b0e19660..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/117_add_compute_node_stats.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright (c) 2012 OpenStack, LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, Integer
-from sqlalchemy import Index, MetaData, String, Table
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- compute_nodes = Table('compute_nodes', meta, autoload=True)
-
- # create new table
- compute_node_stats = Table('compute_node_stats', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True, nullable=False,
- autoincrement=True),
- Column('compute_node_id', Integer, index=True, nullable=False),
- Column('key', String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False), nullable=False),
- Column('value', String(length=255, convert_unicode=True,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- mysql_engine='InnoDB')
- try:
- compute_node_stats.create()
- except Exception:
- LOG.exception("Exception while creating table 'compute_node_stats'")
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- compute_nodes = Table('compute_nodes', meta, autoload=True)
-
- compute_node_stats = Table('compute_node_stats', meta, autoload=True)
- compute_node_stats.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/118_add_indexes_to_agent_builds.py b/nova/db/sqlalchemy/migrate_repo/versions/118_add_indexes_to_agent_builds.py
deleted file mode 100644
index 23f7d3cdb..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/118_add_indexes_to_agent_builds.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on agent_build_get_by_triple
- # from: nova/db/sqlalchemy/api.py
- t = Table('agent_builds', meta, autoload=True)
- i = Index('agent_builds_hypervisor_os_arch_idx',
- t.c.hypervisor, t.c.os, t.c.architecture)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('agent_builds', meta, autoload=True)
- i = Index('agent_builds_hypervisor_os_arch_idx',
- t.c.hypervisor, t.c.os, t.c.architecture)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/119_add_indexes_to_aggregate_metadata.py b/nova/db/sqlalchemy/migrate_repo/versions/119_add_indexes_to_aggregate_metadata.py
deleted file mode 100644
index 0e819a59d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/119_add_indexes_to_aggregate_metadata.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on aggregate_metadata_get_item
- # from: nova/db/sqlalchemy/api.py
- t = Table('aggregate_metadata', meta, autoload=True)
- i = Index('aggregate_metadata_key_idx', t.c.key)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('aggregate_metadata', meta, autoload=True)
- i = Index('aggregate_metadata_key_idx', t.c.key)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/120_add_indexes_to_block_device_mapping.py b/nova/db/sqlalchemy/migrate_repo/versions/120_add_indexes_to_block_device_mapping.py
deleted file mode 100644
index 432fd91a0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/120_add_indexes_to_block_device_mapping.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('block_device_mapping', meta, autoload=True)
-
- # Based on block_device_mapping_update_or_create
- # from: nova/db/sqlalchemy/api.py
- i = Index('block_device_mapping_instance_uuid_device_name_idx',
- t.c.instance_uuid, t.c.device_name)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on block_device_mapping_update_or_create
- # from: nova/db/sqlalchemy/api.py
- i = Index(
- 'block_device_mapping_instance_uuid_virtual_name_device_name_idx',
- t.c.instance_uuid, t.c.virtual_name, t.c.device_name)
- i.create(migrate_engine)
-
- # Based on block_device_mapping_destroy_by_instance_and_volume
- # from: nova/db/sqlalchemy/api.py
- i = Index('block_device_mapping_instance_uuid_volume_id_idx',
- t.c.instance_uuid, t.c.volume_id)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('block_device_mapping', meta, autoload=True)
-
- i = Index('block_device_mapping_instance_uuid_device_name_idx',
- t.c.instance_uuid, t.c.device_name)
- i.drop(migrate_engine)
-
- i = Index(
- 'block_device_mapping_instance_uuid_virtual_name_device_name_idx',
- t.c.instance_uuid, t.c.virtual_name, t.c.device_name)
- i.drop(migrate_engine)
-
- i = Index('block_device_mapping_instance_uuid_volume_id_idx',
- t.c.instance_uuid, t.c.volume_id)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/121_add_indexes_to_bw_usage_cache.py b/nova/db/sqlalchemy/migrate_repo/versions/121_add_indexes_to_bw_usage_cache.py
deleted file mode 100644
index 1345e5396..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/121_add_indexes_to_bw_usage_cache.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError, OperationalError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on bw_usage_get_by_uuids
- # from: nova/db/sqlalchemy/api.py
- t = Table('bw_usage_cache', meta, autoload=True)
- i = Index('bw_usage_cache_uuid_start_period_idx',
- t.c.uuid, t.c.start_period)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('bw_usage_cache', meta, autoload=True)
- i = Index('bw_usage_cache_uuid_start_period_idx',
- t.c.uuid, t.c.start_period)
- if migrate_engine.url.get_dialect().name.startswith('sqlite'):
- try:
- i.drop(migrate_engine)
- except OperationalError:
- # Sqlite is very broken for any kind of table modification.
- # adding columns creates a new table, then copies the data,
- # and looses the indexes.
- # Thus later migrations that add columns will cause the
- # earlier migration's downgrade unittests to fail on
- # dropping indexes.
- # Honestly testing migrations on sqlite is not really a very
- # valid test (because of above facts), but that is for
- # another day. (mdragon)
- pass
- else:
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/122_add_indexes_to_certificates.py b/nova/db/sqlalchemy/migrate_repo/versions/122_add_indexes_to_certificates.py
deleted file mode 100644
index 1201ce6be..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/122_add_indexes_to_certificates.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('certificates', meta, autoload=True)
-
- # Based on certificate_get_all_by_project
- # from: nova/db/sqlalchemy/api.py
- i = Index('certificates_project_id_deleted_idx',
- t.c.project_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on certificate_get_all_by_user
- # from: nova/db/sqlalchemy/api.py
- i = Index('certificates_user_id_deleted_idx',
- t.c.user_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('certificates', meta, autoload=True)
-
- i = Index('certificates_project_id_deleted_idx',
- t.c.project_id, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('certificates_user_id_deleted_idx',
- t.c.user_id, t.c.deleted)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/123_add_indexes_to_dns_domains.py b/nova/db/sqlalchemy/migrate_repo/versions/123_add_indexes_to_dns_domains.py
deleted file mode 100644
index 6bc0aed91..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/123_add_indexes_to_dns_domains.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on _dnsdomain_get
- # from: nova/db/sqlalchemy/api.py
- t = Table('dns_domains', meta, autoload=True)
- i = Index('dns_domains_domain_deleted_idx',
- t.c.domain, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('dns_domains', meta, autoload=True)
- i = Index('dns_domains_domain_deleted_idx',
- t.c.domain, t.c.deleted)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/124_add_indexes_to_fixed_ips.py b/nova/db/sqlalchemy/migrate_repo/versions/124_add_indexes_to_fixed_ips.py
deleted file mode 100644
index 0ae4a4d51..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/124_add_indexes_to_fixed_ips.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('fixed_ips', meta, autoload=True)
-
- # Based on network_get_all_by_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_host_idx', t.c.host)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on fixed_ip_get_by_network_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_network_id_host_deleted_idx',
- t.c.network_id, t.c.host, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on fixed_ip_associate
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_address_reserved_network_id_deleted_idx',
- t.c.address, t.c.reserved, t.c.network_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('fixed_ips', meta, autoload=True)
-
- # Based on network_get_all_by_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_host_idx', t.c.host)
- i.drop(migrate_engine)
-
- # Based on fixed_ip_get_by_network_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_network_id_host_deleted_idx',
- t.c.network_id, t.c.host, t.c.deleted)
- i.drop(migrate_engine)
-
- # Based on fixed_ip_associate
- # from: nova/db/sqlalchemy/api.py
- i = Index('fixed_ips_address_reserved_network_id_deleted_idx',
- t.c.address, t.c.reserved, t.c.network_id, t.c.deleted)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/125_add_indexes_to_floating_ips.py b/nova/db/sqlalchemy/migrate_repo/versions/125_add_indexes_to_floating_ips.py
deleted file mode 100644
index b953b28b9..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/125_add_indexes_to_floating_ips.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('floating_ips', meta, autoload=True)
-
- # Based on floating_ip_get_all_by_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('floating_ips_host_idx', t.c.host)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on floating_ip_get_all_by_project
- # from: nova/db/sqlalchemy/api.py
- i = Index('floating_ips_project_id_idx', t.c.project_id)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on floating_ip_allocate_address
- # from: nova/db/sqlalchemy/api.py
- i = Index('floating_ips_pool_deleted_fixed_ip_id_project_id_idx',
- t.c.pool, t.c.deleted, t.c.fixed_ip_id, t.c.project_id)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('floating_ips', meta, autoload=True)
-
- i = Index('floating_ips_host_idx', t.c.host)
- i.drop(migrate_engine)
-
- i = Index('floating_ips_project_id_idx', t.c.project_id)
- i.drop(migrate_engine)
-
- i = Index('floating_ips_pool_deleted_fixed_ip_id_project_id_idx',
- t.c.pool, t.c.deleted, t.c.fixed_ip_id, t.c.project_id)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/126_add_indexes_to_instance_faults.py b/nova/db/sqlalchemy/migrate_repo/versions/126_add_indexes_to_instance_faults.py
deleted file mode 100644
index 3ed8277a6..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/126_add_indexes_to_instance_faults.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on instance_fault_get_by_instance_uuids
- # from: nova/db/sqlalchemy/api.py
- t = Table('instance_faults', meta, autoload=True)
- i = Index('instance_faults_instance_uuid_deleted_created_at_idx',
- t.c.instance_uuid, t.c.deleted, t.c.created_at)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('instance_faults', meta, autoload=True)
- i = Index('instance_faults_instance_uuid_deleted_created_at_idx',
- t.c.instance_uuid, t.c.deleted, t.c.created_at)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/127_add_indexes_to_instance_type_extra_specs.py b/nova/db/sqlalchemy/migrate_repo/versions/127_add_indexes_to_instance_type_extra_specs.py
deleted file mode 100644
index 80ef0f983..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/127_add_indexes_to_instance_type_extra_specs.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on instance_type_extra_specs_get_item
- # from: nova/db/sqlalchemy/api.py
- t = Table('instance_type_extra_specs', meta, autoload=True)
- i = Index('instance_type_extra_specs_instance_type_id_key_idx',
- t.c.instance_type_id, t.c.key)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('instance_type_extra_specs', meta, autoload=True)
- i = Index('instance_type_extra_specs_instance_type_id_key_idx',
- t.c.instance_type_id, t.c.key)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/128_add_indexes_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/128_add_indexes_to_instances.py
deleted file mode 100644
index a429a7685..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/128_add_indexes_to_instances.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('instances', meta, autoload=True)
-
- # Based on service_get_all_compute_sorted
- # from: nova/db/sqlalchemy/api.py
- i = Index('instances_host_deleted_idx',
- t.c.host, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on instance_get_all_by_reservation
- # from: nova/db/sqlalchemy/api.py
- i = Index('instances_reservation_id_idx', t.c.reservation_id)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on instance_get_active_by_window
- # from: nova/db/sqlalchemy/api.py
- i = Index('instances_terminated_at_launched_at_idx',
- t.c.terminated_at, t.c.launched_at)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on security_group_in_use
- # from: nova/db/sqlalchemy/api.py
- i = Index('instances_uuid_deleted_idx',
- t.c.uuid, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on instance_get_all_hung_in_rebooting
- # from: nova/db/sqlalchemy/api.py
- i = Index('instances_task_state_updated_at_idx',
- t.c.task_state, t.c.updated_at)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('instances', meta, autoload=True)
-
- i = Index('instances_host_deleted_idx',
- t.c.host, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('instances_reservation_id_idx', t.c.reservation_id)
- i.drop(migrate_engine)
-
- i = Index('instances_terminated_at_launched_at_idx',
- t.c.terminated_at, t.c.launched_at)
- i.drop(migrate_engine)
-
- i = Index('instances_uuid_deleted_idx',
- t.c.uuid, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('instances_task_state_updated_at_idx',
- t.c.task_state, t.c.updated_at)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/129_add_indexes_to_iscsi_targets.py b/nova/db/sqlalchemy/migrate_repo/versions/129_add_indexes_to_iscsi_targets.py
deleted file mode 100644
index e904742ae..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/129_add_indexes_to_iscsi_targets.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('iscsi_targets', meta, autoload=True)
-
- # Based on iscsi_target_count_by_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('iscsi_targets_host_idx', t.c.host)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on volume_allocate_iscsi_target
- # from: nova/db/sqlalchemy/api.py
- i = Index('iscsi_targets_host_volume_id_deleted_idx',
- t.c.host, t.c.volume_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('iscsi_targets', meta, autoload=True)
-
- i = Index('iscsi_targets_host_idx', t.c.host)
- i.drop(migrate_engine)
-
- i = Index('iscsi_targets_host_volume_id_deleted_idx',
- t.c.host, t.c.volume_id, t.c.deleted)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/130_add_indexes_to_key_pairs.py b/nova/db/sqlalchemy/migrate_repo/versions/130_add_indexes_to_key_pairs.py
deleted file mode 100644
index 82517e53a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/130_add_indexes_to_key_pairs.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # Based on key_pair_get
- # from: nova/db/sqlalchemy/api.py
- t = Table('key_pairs', meta, autoload=True)
- i = Index('key_pair_user_id_name_idx',
- t.c.user_id, t.c.name)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('key_pairs', meta, autoload=True)
- i = Index('key_pair_user_id_name_idx',
- t.c.user_id, t.c.name)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/131_add_indexes_to_networks.py b/nova/db/sqlalchemy/migrate_repo/versions/131_add_indexes_to_networks.py
deleted file mode 100644
index 11a9dde86..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/131_add_indexes_to_networks.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('networks', meta, autoload=True)
-
- # Based on network_get_by_bridge
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_bridge_deleted_idx',
- t.c.bridge, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on network_get_all_by_host
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_host_idx', t.c.host)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on network_query
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_project_id_deleted_idx',
- t.c.project_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on network_get_all_by_uuids
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_uuid_project_id_deleted_idx',
- t.c.uuid, t.c.project_id, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on network_create_safe
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_vlan_deleted_idx',
- t.c.vlan, t.c.deleted)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
- # Based on network_get_by_cidr
- # from: nova/db/sqlalchemy/api.py
- i = Index('networks_cidr_v6_idx', t.c.cidr_v6)
- try:
- i.create(migrate_engine)
- except IntegrityError:
- pass
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- t = Table('networks', meta, autoload=True)
-
- i = Index('networks_bridge_deleted_idx',
- t.c.bridge, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('networks_host_idx', t.c.host)
- i.drop(migrate_engine)
-
- i = Index('networks_project_id_deleted_idx',
- t.c.project_id, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('networks_uuid_project_id_deleted_idx',
- t.c.uuid, t.c.project_id, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('networks_vlan_deleted_idx',
- t.c.vlan, t.c.deleted)
- i.drop(migrate_engine)
-
- i = Index('networks_cidr_v6_idx', t.c.cidr_v6)
- i.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/132_add_instance_type_projects.py b/nova/db/sqlalchemy/migrate_repo/versions/132_add_instance_type_projects.py
deleted file mode 100644
index 312ebbfc1..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/132_add_instance_type_projects.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import Boolean, Column, DateTime, String, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- is_public = Column('is_public', Boolean)
-
- instance_types.create_column(is_public)
- instance_types.update().values(is_public=True).execute()
-
- # New table.
- instance_type_projects = Table('instance_type_projects', meta,
- Column('created_at', DateTime(timezone=False)),
- Column('updated_at', DateTime(timezone=False)),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(), default=False),
- Column('id', Integer, primary_key=True, nullable=False),
- Column('instance_type_id',
- Integer,
- ForeignKey('instance_types.id'),
- nullable=False),
- Column('project_id', String(length=255)),
- mysql_engine='InnoDB',
- mysql_charset='utf8'
- )
-
- try:
- instance_type_projects.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(instance_type_projects))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- is_public = Column('is_public', Boolean)
-
- instance_types.drop_column(is_public)
-
- instance_type_projects = Table(
- 'instance_type_projects', meta, autoload=True)
- instance_type_projects.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/133_aggregate_delete_fix.py b/nova/db/sqlalchemy/migrate_repo/versions/133_aggregate_delete_fix.py
deleted file mode 100644
index b6cf56d47..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/133_aggregate_delete_fix.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from sqlalchemy import String, Column, MetaData, Table
-from migrate.changeset import UniqueConstraint
-
-from nova.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- dialect = migrate_engine.url.get_dialect().name
-
- aggregates = Table('aggregates', meta, autoload=True)
- if dialect.startswith('sqlite'):
- aggregates.c.name.alter(unique=False)
- elif dialect.startswith('postgres'):
- ucon = UniqueConstraint('name',
- name='aggregates_name_key',
- table=aggregates)
- ucon.drop()
-
- else:
- col2 = aggregates.c.name
- UniqueConstraint(col2, name='name').drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- aggregates = Table('aggregates', meta, autoload=True)
- aggregates.c.name.alter(unique=True)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py b/nova/db/sqlalchemy/migrate_repo/versions/133_folsom.py
index ce795b071..44eac3695 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/133_folsom.py
@@ -14,11 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from migrate.changeset import UniqueConstraint
from migrate import ForeignKeyConstraint
from sqlalchemy import Boolean, BigInteger, Column, DateTime, Float, ForeignKey
from sqlalchemy import Index, Integer, MetaData, String, Table, Text
+from sqlalchemy import dialects
-from nova import config
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@@ -27,6 +28,14 @@ LOG = logging.getLogger(__name__)
# Note on the autoincrement flag: this is defaulted for primary key columns
# of integral type, so is no longer set explicitly in such cases.
+# NOTE(dprince): This wrapper allows us to easily match the Folsom MySQL
+# Schema. In Folsom we created tables as latin1 and converted them to utf8
+# later. This conversion causes some of the Text columns on MySQL to get
+# created as mediumtext instead of just text.
+def MediumText():
+ return Text().with_variant(dialects.mysql.MEDIUMTEXT(), 'mysql')
+
+
def _populate_instance_types(instance_types_table):
default_inst_types = {
'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1),
@@ -45,10 +54,12 @@ def _populate_instance_types(instance_types_table):
'ephemeral_gb': values["eph_gb"],
'rxtx_factor': 1,
'swap': 0,
- 'flavorid': values["flavid"]})
+ 'flavorid': values["flavid"],
+ 'disabled': False,
+ 'is_public': True})
except Exception:
LOG.info(repr(instance_types_table))
- LOG.exception('Exception while seeding instance_types table')
+ LOG.exception(_('Exception while seeding instance_types table'))
raise
@@ -69,7 +80,7 @@ def upgrade(migrate_engine):
Column('url', String(length=255)),
Column('md5hash', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
aggregate_hosts = Table('aggregate_hosts', meta,
@@ -78,11 +89,11 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('host', String(length=255), unique=True),
+ Column('host', String(length=255)),
Column('aggregate_id', Integer, ForeignKey('aggregates.id'),
nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
aggregate_metadata = Table('aggregate_metadata', meta,
@@ -96,7 +107,7 @@ def upgrade(migrate_engine):
Column('key', String(length=255), nullable=False),
Column('value', String(length=255), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
aggregates = Table('aggregates', meta,
@@ -105,26 +116,10 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('name', String(length=255), unique=True),
- Column('operational_state', String(length=255), nullable=False),
+ Column('name', String(length=255)),
Column('availability_zone', String(length=255), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
- )
-
- auth_tokens = Table('auth_tokens', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('token_hash', String(length=255), primary_key=True,
- nullable=False),
- Column('user_id', String(length=255)),
- Column('server_management_url', String(length=255)),
- Column('storage_url', String(length=255)),
- Column('cdn_management_url', String(length=255)),
- mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
block_device_mapping = Table('block_device_mapping', meta,
@@ -133,20 +128,17 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('instance_id', Integer, ForeignKey('instances.id'),
- nullable=False),
Column('device_name', String(length=255), nullable=False),
Column('delete_on_termination', Boolean),
Column('virtual_name', String(length=255)),
- Column('snapshot_id', Integer, ForeignKey('snapshots.id'),
- nullable=True),
- Column('volume_id', Integer(), ForeignKey('volumes.id'),
- nullable=True),
+ Column('snapshot_id', String(length=36), nullable=True),
+ Column('volume_id', String(length=36), nullable=True),
Column('volume_size', Integer),
Column('no_device', Boolean),
- Column('connection_info', Text),
+ Column('connection_info', MediumText()),
+ Column('instance_uuid', String(length=36)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
bw_usage_cache = Table('bw_usage_cache', meta,
@@ -160,8 +152,9 @@ def upgrade(migrate_engine):
Column('bw_in', BigInteger),
Column('bw_out', BigInteger),
Column('mac', String(length=255)),
+ Column('uuid', String(length=36)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
cells = Table('cells', meta,
@@ -194,7 +187,20 @@ def upgrade(migrate_engine):
Column('project_id', String(length=255)),
Column('file_name', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
+ )
+
+ compute_node_stats = Table('compute_node_stats', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('compute_node_id', Integer, nullable=False),
+ Column('key', String(length=255), nullable=False),
+ Column('value', String(length=255)),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
)
compute_nodes = Table('compute_nodes', meta,
@@ -210,9 +216,9 @@ def upgrade(migrate_engine):
Column('vcpus_used', Integer, nullable=False),
Column('memory_mb_used', Integer, nullable=False),
Column('local_gb_used', Integer, nullable=False),
- Column('hypervisor_type', Text, nullable=False),
+ Column('hypervisor_type', MediumText(), nullable=False),
Column('hypervisor_version', Integer, nullable=False),
- Column('cpu_info', Text, nullable=False),
+ Column('cpu_info', MediumText(), nullable=False),
Column('disk_available_least', Integer),
Column('free_ram_mb', Integer),
Column('free_disk_gb', Integer),
@@ -220,7 +226,7 @@ def upgrade(migrate_engine):
Column('running_vms', Integer),
Column('hypervisor_hostname', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
console_pools = Table('console_pools', meta,
@@ -237,7 +243,7 @@ def upgrade(migrate_engine):
Column('host', String(length=255)),
Column('compute_host', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
consoles = Table('consoles', meta,
@@ -247,31 +253,25 @@ def upgrade(migrate_engine):
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
Column('instance_name', String(length=255)),
- Column('instance_id', Integer),
Column('password', String(length=255)),
Column('port', Integer),
Column('pool_id', Integer, ForeignKey('console_pools.id')),
+ Column('instance_uuid', String(length=36)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- # NOTE(dprince): Trying to create a fresh utf8 dns_domains tables
- # with a domain primary key length of 512 fails w/
- # 'Specified key was too long; max key length is 767 bytes'.
- # See: https://bugs.launchpad.net/nova/+bug/993663
- # If we fix this during Folsom we can set mysql_charset=utf8 inline...
- # and remove the unsightly loop that does it below during "E" compaction.
dns_domains = Table('dns_domains', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('domain', String(length=512), primary_key=True, nullable=False),
+ Column('domain', String(length=255), primary_key=True, nullable=False),
Column('scope', String(length=255)),
Column('availability_zone', String(length=255)),
- Column('project_id', String(length=255), ForeignKey('projects.id')),
+ Column('project_id', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
fixed_ips = Table('fixed_ips', meta,
@@ -282,14 +282,14 @@ def upgrade(migrate_engine):
Column('id', Integer, primary_key=True, nullable=False),
Column('address', String(length=255)),
Column('network_id', Integer),
- Column('instance_id', Integer),
Column('allocated', Boolean),
Column('leased', Boolean),
Column('reserved', Boolean),
Column('virtual_interface_id', Integer),
Column('host', String(length=255)),
+ Column('instance_uuid', String(length=36)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
floating_ips = Table('floating_ips', meta,
@@ -306,34 +306,32 @@ def upgrade(migrate_engine):
Column('pool', String(length=255)),
Column('interface', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- instance_actions = Table('instance_actions', meta,
+ instance_faults = Table('instance_faults', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('action', String(length=255)),
- Column('error', Text),
Column('instance_uuid', String(length=36)),
+ Column('code', Integer, nullable=False),
+ Column('message', String(length=255)),
+ Column('details', MediumText()),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- instance_faults = Table('instance_faults', meta,
+ instance_id_mappings = Table('instance_id_mappings', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('instance_uuid', String(length=36)),
- Column('code', Integer, nullable=False),
- Column('message', String(length=255)),
- Column('details', Text),
+ Column('uuid', String(36), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
instance_info_caches = Table('instance_info_caches', meta,
@@ -342,10 +340,10 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('network_info', Text),
- Column('instance_id', String(36), nullable=False, unique=True),
+ Column('network_info', MediumText()),
+ Column('instance_uuid', String(length=36), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
instance_metadata = Table('instance_metadata', meta,
@@ -354,12 +352,24 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('instance_id', Integer, ForeignKey('instances.id'),
- nullable=False),
Column('key', String(length=255)),
Column('value', String(length=255)),
+ Column('instance_uuid', String(length=36), nullable=True),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
+ )
+
+ instance_system_metadata = Table('instance_system_metadata', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('instance_uuid', String(length=36), nullable=False),
+ Column('key', String(length=255), nullable=False),
+ Column('value', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
instance_type_extra_specs = Table('instance_type_extra_specs', meta,
@@ -373,7 +383,19 @@ def upgrade(migrate_engine):
Column('key', String(length=255)),
Column('value', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
+ )
+
+ instance_type_projects = Table('instance_type_projects', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('instance_type_id', Integer, nullable=False),
+ Column('project_id', String(length=255)),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
)
instance_types = Table('instance_types', meta,
@@ -391,8 +413,10 @@ def upgrade(migrate_engine):
Column('rxtx_factor', Float),
Column('root_gb', Integer),
Column('ephemeral_gb', Integer),
+ Column('disabled', Boolean),
+ Column('is_public', Boolean),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
instances = Table('instances', meta,
@@ -410,14 +434,14 @@ def upgrade(migrate_engine):
Column('server_name', String(length=255)),
Column('launch_index', Integer),
Column('key_name', String(length=255)),
- Column('key_data', Text),
+ Column('key_data', MediumText()),
Column('power_state', Integer),
Column('vm_state', String(length=255)),
Column('memory_mb', Integer),
Column('vcpus', Integer),
Column('hostname', String(length=255)),
Column('host', String(length=255)),
- Column('user_data', Text),
+ Column('user_data', MediumText()),
Column('reservation_id', String(length=255)),
Column('scheduled_at', DateTime),
Column('launched_at', DateTime),
@@ -427,7 +451,7 @@ def upgrade(migrate_engine):
Column('availability_zone', String(length=255)),
Column('locked', Boolean),
Column('os_type', String(length=255)),
- Column('launched_on', Text),
+ Column('launched_on', MediumText()),
Column('instance_type_id', Integer),
Column('vm_mode', String(length=255)),
Column('uuid', String(length=36)),
@@ -447,7 +471,7 @@ def upgrade(migrate_engine):
Column('ephemeral_gb', Integer),
Column('cell_name', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
iscsi_targets = Table('iscsi_targets', meta,
@@ -458,10 +482,9 @@ def upgrade(migrate_engine):
Column('id', Integer, primary_key=True, nullable=False),
Column('target_num', Integer),
Column('host', String(length=255)),
- Column('volume_id', Integer, ForeignKey('volumes.id'),
- nullable=True),
+ Column('volume_id', String(length=36), nullable=True),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
key_pairs = Table('key_pairs', meta,
@@ -473,9 +496,9 @@ def upgrade(migrate_engine):
Column('name', String(length=255)),
Column('user_id', String(length=255)),
Column('fingerprint', String(length=255)),
- Column('public_key', Text),
+ Column('public_key', MediumText()),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
migrations = Table('migrations', meta,
@@ -492,7 +515,7 @@ def upgrade(migrate_engine):
Column('old_instance_type_id', Integer),
Column('new_instance_type_id', Integer),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
networks = Table('networks', meta,
@@ -526,34 +549,49 @@ def upgrade(migrate_engine):
Column('priority', Integer),
Column('rxtx_base', Integer),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- projects = Table('projects', meta,
+ provider_fw_rules = Table('provider_fw_rules', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('id', String(length=255), primary_key=True, nullable=False),
- Column('name', String(length=255)),
- Column('description', String(length=255)),
- Column('project_manager', String(length=255), ForeignKey('users.id')),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('protocol', String(length=5)),
+ Column('from_port', Integer),
+ Column('to_port', Integer),
+ Column('cidr', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- provider_fw_rules = Table('provider_fw_rules', meta,
+ quota_classes = Table('quota_classes', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('protocol', String(length=5)),
- Column('from_port', Integer),
- Column('to_port', Integer),
- Column('cidr', String(length=255)),
+ Column('class_name', String(length=255)),
+ Column('resource', String(length=255)),
+ Column('hard_limit', Integer),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
+ )
+
+ quota_usages = Table('quota_usages', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('project_id', String(length=255)),
+ Column('resource', String(length=255)),
+ Column('in_use', Integer, nullable=False),
+ Column('reserved', Integer, nullable=False),
+ Column('until_refresh', Integer),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
)
quotas = Table('quotas', meta,
@@ -566,7 +604,23 @@ def upgrade(migrate_engine):
Column('resource', String(length=255), nullable=False),
Column('hard_limit', Integer),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
+ )
+
+ reservations = Table('reservations', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('uuid', String(length=36), nullable=False),
+ Column('usage_id', Integer, nullable=False),
+ Column('project_id', String(length=255)),
+ Column('resource', String(length=255)),
+ Column('delta', Integer, nullable=False),
+ Column('expire', DateTime),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
)
s3_images = Table('s3_images', meta,
@@ -577,7 +631,7 @@ def upgrade(migrate_engine):
Column('id', Integer, primary_key=True, nullable=False),
Column('uuid', String(length=36), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
security_group_instance_association = \
@@ -588,9 +642,9 @@ def upgrade(migrate_engine):
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
Column('security_group_id', Integer, ForeignKey('security_groups.id')),
- Column('instance_id', Integer, ForeignKey('instances.id')),
+ Column('instance_uuid', String(length=36)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
security_group_rules = Table('security_group_rules', meta,
@@ -606,7 +660,7 @@ def upgrade(migrate_engine):
Column('cidr', String(length=255)),
Column('group_id', Integer, ForeignKey('security_groups.id')),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
security_groups = Table('security_groups', meta,
@@ -620,7 +674,7 @@ def upgrade(migrate_engine):
Column('user_id', String(length=255)),
Column('project_id', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
services = Table('services', meta,
@@ -636,19 +690,7 @@ def upgrade(migrate_engine):
Column('disabled', Boolean),
Column('availability_zone', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
- )
-
- sm_flavors = Table('sm_flavors', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('id', Integer, primary_key=True, nullable=False),
- Column('label', String(length=255)),
- Column('description', String(length=255)),
- mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
sm_backend_config = Table('sm_backend_config', meta,
@@ -663,94 +705,80 @@ def upgrade(migrate_engine):
Column('sr_type', String(length=255)),
Column('config_params', String(length=2047)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
- )
-
- sm_volume = Table('sm_volume', meta,
- Column('created_at', DateTime),
- Column('updated_at', DateTime),
- Column('deleted_at', DateTime),
- Column('deleted', Boolean),
- Column('id', Integer(), ForeignKey('volumes.id'), primary_key=True,
- nullable=False, autoincrement=False),
- Column('backend_id', Integer, ForeignKey('sm_backend_config.id'),
- nullable=False),
- Column('vdi_uuid', String(length=255)),
- mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- snapshots = Table('snapshots', meta,
+ sm_flavors = Table('sm_flavors', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('volume_id', Integer, nullable=False),
- Column('user_id', String(length=255)),
- Column('project_id', String(length=255)),
- Column('status', String(length=255)),
- Column('progress', String(length=255)),
- Column('volume_size', Integer),
- Column('scheduled_at', DateTime),
- Column('display_name', String(length=255)),
- Column('display_description', String(length=255)),
+ Column('label', String(length=255)),
+ Column('description', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- user_project_association = Table('user_project_association', meta,
+ sm_volume = Table('sm_volume', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('user_id', String(length=255), primary_key=True,
- nullable=False),
- Column('project_id', String(length=255), primary_key=True,
- nullable=False),
+ Column('id', String(length=36), primary_key=True,
+ nullable=False, autoincrement=False),
+ Column('backend_id', Integer, nullable=False),
+ Column('vdi_uuid', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- user_project_role_association = \
- Table('user_project_role_association', meta,
+ snapshot_id_mappings = Table('snapshot_id_mappings', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('user_id', String(length=255), primary_key=True,
- nullable=False),
- Column('project_id', String(length=255), primary_key=True,
- nullable=False),
- Column('role', String(length=255), primary_key=True, nullable=False),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('uuid', String(length=36), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- user_role_association = Table('user_role_association', meta,
+ snapshots = Table('snapshots', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('user_id', String(length=255), ForeignKey('users.id'),
- primary_key=True, nullable=False),
- Column('role', String(length=255), primary_key=True, nullable=False),
+ Column('id', String(length=36), primary_key=True, nullable=False),
+ Column('volume_id', String(length=36), nullable=False),
+ Column('user_id', String(length=255)),
+ Column('project_id', String(length=255)),
+ Column('status', String(length=255)),
+ Column('progress', String(length=255)),
+ Column('volume_size', Integer),
+ Column('scheduled_at', DateTime),
+ Column('display_name', String(length=255)),
+ Column('display_description', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- users = Table('users', meta,
+ task_log = Table('task_log', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
- Column('id', String(length=255), primary_key=True, nullable=False),
- Column('name', String(length=255)),
- Column('access_key', String(length=255)),
- Column('secret_key', String(length=255)),
- Column('is_admin', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('task_name', String(length=255), nullable=False),
+ Column('state', String(length=255), nullable=False),
+ Column('host', String(length=255), nullable=False),
+ Column('period_beginning', String(length=255), nullable=False),
+ Column('period_ending', String(length=255), nullable=False),
+ Column('message', String(length=255), nullable=False),
+ Column('task_items', Integer),
+ Column('errors', Integer),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
virtual_interfaces = Table('virtual_interfaces', meta,
@@ -761,10 +789,10 @@ def upgrade(migrate_engine):
Column('id', Integer, primary_key=True, nullable=False),
Column('address', String(length=255), unique=True),
Column('network_id', Integer),
- Column('instance_id', Integer, nullable=False),
Column('uuid', String(length=36)),
+ Column('instance_uuid', String(length=36), nullable=True),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
virtual_storage_arrays = Table('virtual_storage_arrays', meta,
@@ -783,18 +811,18 @@ def upgrade(migrate_engine):
Column('vol_count', Integer, nullable=False),
Column('status', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- volume_types = Table('volume_types', meta,
+ volume_id_mappings = Table('volume_id_mappings', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('name', String(length=255)),
+ Column('uuid', String(length=36), nullable=False),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
volume_metadata = Table('volume_metadata', meta,
@@ -803,12 +831,11 @@ def upgrade(migrate_engine):
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
- Column('volume_id', Integer, ForeignKey('volumes.id'),
- nullable=False),
+ Column('volume_id', String(length=36), nullable=False),
Column('key', String(length=255)),
Column('value', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
volume_type_extra_specs = Table('volume_type_extra_specs', meta,
@@ -822,24 +849,33 @@ def upgrade(migrate_engine):
Column('key', String(length=255)),
Column('value', String(length=255)),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
- volumes = Table('volumes', meta,
+ volume_types = Table('volume_types', meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('deleted', Boolean),
Column('id', Integer, primary_key=True, nullable=False),
+ Column('name', String(length=255)),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
+ )
+
+ volumes = Table('volumes', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', String(length=36), primary_key=True, nullable=False),
Column('ec2_id', String(length=255)),
Column('user_id', String(length=255)),
Column('project_id', String(length=255)),
Column('host', String(length=255)),
Column('size', Integer),
Column('availability_zone', String(length=255)),
- Column('instance_id', Integer, ForeignKey('instances.id')),
Column('mountpoint', String(length=255)),
- Column('attach_time', String(length=255)),
Column('status', String(length=255)),
Column('attach_status', String(length=255)),
Column('scheduled_at', DateTime),
@@ -849,10 +885,12 @@ def upgrade(migrate_engine):
Column('display_description', String(length=255)),
Column('provider_location', String(length=256)),
Column('provider_auth', String(length=256)),
- Column('snapshot_id', Integer),
+ Column('snapshot_id', String(length=36)),
Column('volume_type_id', Integer),
+ Column('instance_uuid', String(length=36)),
+ Column('attach_time', DateTime),
mysql_engine='InnoDB',
- #mysql_charset='utf8'
+ mysql_charset='utf8'
)
instances.create()
@@ -861,21 +899,24 @@ def upgrade(migrate_engine):
# create all tables
tables = [aggregates, console_pools, instance_types,
- users, projects, security_groups, sm_flavors, sm_backend_config,
- snapshots, user_project_association, volume_types,
+ security_groups, sm_flavors, sm_backend_config,
+ snapshots, volume_types,
volumes,
# those that are children and others later
agent_builds, aggregate_hosts, aggregate_metadata,
- auth_tokens, block_device_mapping, bw_usage_cache, cells,
- certificates, compute_nodes, consoles, dns_domains, fixed_ips,
- floating_ips, instance_actions, instance_faults,
- instance_info_caches, instance_metadata,
- instance_type_extra_specs, iscsi_targets, key_pairs,
- migrations, networks, provider_fw_rules,
- quotas, s3_images, security_group_instance_association,
+ block_device_mapping, bw_usage_cache, cells,
+ certificates, compute_node_stats, compute_nodes, consoles,
+ dns_domains, fixed_ips, floating_ips,
+ instance_faults, instance_id_mappings, instance_info_caches,
+ instance_metadata, instance_system_metadata,
+ instance_type_extra_specs, instance_type_projects,
+ iscsi_targets, key_pairs, migrations, networks,
+ provider_fw_rules, quota_classes, quota_usages, quotas,
+ reservations, s3_images, security_group_instance_association,
security_group_rules, services, sm_volume,
- user_project_role_association, user_role_association,
- virtual_interfaces, virtual_storage_arrays, volume_metadata,
+ snapshot_id_mappings, task_log,
+ virtual_interfaces,
+ virtual_storage_arrays, volume_id_mappings, volume_metadata,
volume_type_extra_specs]
for table in tables:
@@ -883,103 +924,302 @@ def upgrade(migrate_engine):
table.create()
except Exception:
LOG.info(repr(table))
- LOG.exception('Exception while creating table.')
+ LOG.exception(_('Exception while creating table.'))
raise
- # MySQL specific Indexes from Essex
- # NOTE(dprince): I think some of these can be removed in Folsom
indexes = [
+ # agent_builds
+ Index('agent_builds_hypervisor_os_arch_idx',
+ agent_builds.c.hypervisor,
+ agent_builds.c.os,
+ agent_builds.c.architecture),
+
+ # aggregate_metadata
+ Index('aggregate_metadata_key_idx', aggregate_metadata.c.key),
+
+ # block_device_mapping
+ Index('block_device_mapping_instance_uuid_idx',
+ block_device_mapping.c.instance_uuid),
+
+ Index('block_device_mapping_instance_uuid_device_name_idx',
+ block_device_mapping.c.instance_uuid,
+ block_device_mapping.c.device_name),
+ Index(
+ 'block_device_mapping_instance_uuid_virtual_name_device_name_idx',
+ block_device_mapping.c.instance_uuid,
+ block_device_mapping.c.virtual_name,
+ block_device_mapping.c.device_name),
+
+ Index('block_device_mapping_instance_uuid_volume_id_idx',
+ block_device_mapping.c.instance_uuid,
+ block_device_mapping.c.volume_id),
+
+ # bw_usage_cache
+ Index('bw_usage_cache_uuid_start_period_idx',
+ bw_usage_cache.c.uuid, bw_usage_cache.c.start_period),
+
+ # certificates
+ Index('certificates_project_id_deleted_idx',
+ certificates.c.project_id, certificates.c.deleted),
+
+ Index('certificates_user_id_deleted_idx',
+ certificates.c.user_id, certificates.c.deleted),
+
+ # compute_node_stats
+ Index('ix_compute_node_stats_compute_node_id',
+ compute_node_stats.c.compute_node_id),
+
+ # consoles
+ Index('consoles_instance_uuid_idx', consoles.c.instance_uuid),
+
+ # dns_domains
+ Index('dns_domains_domain_deleted_idx',
+ dns_domains.c.domain, dns_domains.c.deleted),
+
+ # fixed_ips
+ Index('fixed_ips_host_idx', fixed_ips.c.host),
+ Index('fixed_ips_network_id_host_deleted_idx',
+ fixed_ips.c.network_id, fixed_ips.c.host, fixed_ips.c.deleted),
+ Index('fixed_ips_address_reserved_network_id_deleted_idx',
+ fixed_ips.c.address, fixed_ips.c.reserved,
+ fixed_ips.c.network_id, fixed_ips.c.deleted),
+
+ # floating_ips
+ Index('floating_ips_host_idx', floating_ips.c.host),
+
+ Index('floating_ips_project_id_idx', floating_ips.c.project_id),
+
+ Index('floating_ips_pool_deleted_fixed_ip_id_project_id_idx',
+ floating_ips.c.pool, floating_ips.c.deleted,
+ floating_ips.c.fixed_ip_id, floating_ips.c.project_id),
+
+ # instance_faults
+ Index('instance_faults_instance_uuid_deleted_created_at_idx',
+ instance_faults.c.instance_uuid, instance_faults.c.deleted,
+ instance_faults.c.created_at),
+
+ # instance_type_extra_specs
+ Index('instance_type_extra_specs_instance_type_id_key_idx',
+ instance_type_extra_specs.c.instance_type_id,
+ instance_type_extra_specs.c.key),
+
+ # instance_id_mappings
+ Index('ix_instance_id_mappings_uuid', instance_id_mappings.c.uuid),
+
+ # instance_metadata
+ Index('instance_metadata_instance_uuid_idx',
+ instance_metadata.c.instance_uuid),
+
+ # instances
+ Index('instances_host_deleted_idx',
+ instances.c.host, instances.c.deleted),
+
+ Index('instances_reservation_id_idx', instances.c.reservation_id),
+
+ Index('instances_terminated_at_launched_at_idx',
+ instances.c.terminated_at, instances.c.launched_at),
+
+ Index('instances_uuid_deleted_idx',
+ instances.c.uuid, instances.c.deleted),
+
+ Index('instances_task_state_updated_at_idx',
+ instances.c.task_state, instances.c.updated_at),
+
+
+ # iscsi_targets
+ Index('iscsi_targets_host_idx', iscsi_targets.c.host),
+
+ Index('iscsi_targets_host_volume_id_deleted_idx',
+ iscsi_targets.c.host, iscsi_targets.c.volume_id,
+ iscsi_targets.c.deleted),
+
+ # key_pairs
+ Index('key_pair_user_id_name_idx',
+ key_pairs.c.user_id, key_pairs.c.name),
+
+ # networks
+ Index('networks_bridge_deleted_idx',
+ networks.c.bridge, networks.c.deleted),
+
+ Index('networks_host_idx', networks.c.host),
+
+ Index('networks_project_id_deleted_idx',
+ networks.c.project_id, networks.c.deleted),
+
+ Index('networks_uuid_project_id_deleted_idx',
+ networks.c.uuid, networks.c.project_id, networks.c.deleted),
+
+ Index('networks_vlan_deleted_idx',
+ networks.c.vlan, networks.c.deleted),
+
+ Index('networks_cidr_v6_idx', networks.c.cidr_v6),
+
+ # reservations
+ Index('ix_reservations_project_id', reservations.c.project_id),
+
+ # security_group_instance_association
+ Index('security_group_instance_association_instance_uuid_idx',
+ security_group_instance_association.c.instance_uuid),
+
+ # quota_classes
+ Index('ix_quota_classes_class_name', quota_classes.c.class_name),
+
+ # quota_usages
+ Index('ix_quota_usages_project_id', quota_usages.c.project_id),
+
+
+ # volumes
+ Index('volumes_instance_uuid_idx', volumes.c.instance_uuid),
+
+ # task_log
+ Index('ix_task_log_period_beginning', task_log.c.period_beginning),
+ Index('ix_task_log_host', task_log.c.host),
+ Index('ix_task_log_period_ending', task_log.c.period_ending),
+
+ ]
+
+ mysql_indexes = [
+ # TODO(dprince): review these for removal. Some of these indexes
+ # were automatically created by SQLAlchemy migrate and *may* no longer
+ # be in use
+ Index('instance_type_id', instance_type_projects.c.instance_type_id),
+ Index('project_id', dns_domains.c.project_id),
+ Index('fixed_ip_id', floating_ips.c.fixed_ip_id),
+ Index('backend_id', sm_volume.c.backend_id),
+ Index('network_id', virtual_interfaces.c.network_id),
Index('network_id', fixed_ips.c.network_id),
- Index('instance_id', fixed_ips.c.instance_id),
Index('fixed_ips_virtual_interface_id_fkey',
fixed_ips.c.virtual_interface_id),
- Index('fixed_ip_id', floating_ips.c.fixed_ip_id),
- Index('project_id', user_project_association.c.project_id),
- Index('network_id', virtual_interfaces.c.network_id),
- Index('instance_id', virtual_interfaces.c.instance_id),
+ Index('address', fixed_ips.c.address),
+ Index('fixed_ips_instance_uuid_fkey', fixed_ips.c.instance_uuid),
+ Index('instance_uuid', instance_system_metadata.c.instance_uuid),
+ Index('iscsi_targets_volume_id_fkey', iscsi_targets.c.volume_id),
+ Index('snapshot_id', block_device_mapping.c.snapshot_id),
+ Index('usage_id', reservations.c.usage_id),
+ Index('virtual_interfaces_instance_uuid_fkey',
+ virtual_interfaces.c.instance_uuid),
+ Index('volume_id', block_device_mapping.c.volume_id),
+ Index('volume_metadata_volume_id_fkey', volume_metadata.c.volume_id),
]
+ # MySQL specific indexes
if migrate_engine.name == 'mysql':
+ for index in mysql_indexes:
+ index.create(migrate_engine)
+
+ # PostgreSQL specific indexes
+ if migrate_engine.name == 'postgresql':
+ Index('address', fixed_ips.c.address).create()
+
+ # Common indexes
+ if migrate_engine.name == 'mysql' or migrate_engine.name == 'postgresql':
for index in indexes:
index.create(migrate_engine)
fkeys = [
- [[user_project_role_association.c.user_id,
- user_project_role_association.c.project_id],
- [user_project_association.c.user_id,
- user_project_association.c.project_id],
- 'user_project_role_association_ibfk_1'],
- [[user_project_association.c.user_id],
- [users.c.id], 'user_project_association_ibfk_1'],
- [[user_project_association.c.project_id], [projects.c.id],
- 'user_project_association_ibfk_2'],
- [[instance_info_caches.c.instance_id], [instances.c.uuid],
- 'instance_info_caches_ibfk_1'],
+
+ [[fixed_ips.c.instance_uuid],
+ [instances.c.uuid],
+ 'fixed_ips_instance_uuid_fkey'],
+ [[block_device_mapping.c.instance_uuid],
+ [instances.c.uuid],
+ 'block_device_mapping_instance_uuid_fkey'],
+ [[consoles.c.instance_uuid],
+ [instances.c.uuid],
+ 'consoles_instance_uuid_fkey'],
+ [[instance_info_caches.c.instance_uuid],
+ [instances.c.uuid],
+ 'instance_info_caches_instance_uuid_fkey'],
+ [[instance_metadata.c.instance_uuid],
+ [instances.c.uuid],
+ 'instance_metadata_instance_uuid_fkey'],
+ [[instance_system_metadata.c.instance_uuid],
+ [instances.c.uuid],
+ 'instance_system_metadata_ibfk_1'],
+ [[instance_type_projects.c.instance_type_id],
+ [instance_types.c.id],
+ 'instance_type_projects_ibfk_1'],
+ [[iscsi_targets.c.volume_id],
+ [volumes.c.id],
+ 'iscsi_targets_volume_id_fkey'],
+ [[reservations.c.usage_id],
+ [quota_usages.c.id],
+ 'reservations_ibfk_1'],
+ [[security_group_instance_association.c.instance_uuid],
+ [instances.c.uuid],
+ 'security_group_instance_association_instance_uuid_fkey'],
+ [[sm_volume.c.backend_id],
+ [sm_backend_config.c.id],
+ 'sm_volume_ibfk_2'],
+ [[sm_volume.c.id],
+ [volumes.c.id],
+ 'sm_volume_id_fkey'],
+ [[virtual_interfaces.c.instance_uuid],
+ [instances.c.uuid],
+ 'virtual_interfaces_instance_uuid_fkey'],
+ [[volume_metadata.c.volume_id],
+ [volumes.c.id],
+ 'volume_metadata_volume_id_fkey'],
+
]
for fkey_pair in fkeys:
if migrate_engine.name == 'mysql':
- # For MySQL we name our fkeys explicitly so they match Essex
+ # For MySQL we name our fkeys explicitly so they match Folsom
fkey = ForeignKeyConstraint(columns=fkey_pair[0],
refcolumns=fkey_pair[1],
name=fkey_pair[2])
fkey.create()
elif migrate_engine.name == 'postgresql':
+ # PostgreSQL names things like it wants (correct and compatible!)
fkey = ForeignKeyConstraint(columns=fkey_pair[0],
refcolumns=fkey_pair[1])
fkey.create()
- # Hopefully this entire loop to set the charset can go away during
- # the "E" release compaction. See the notes on the dns_domains
- # table above for why this is required vs. setting mysql_charset inline.
if migrate_engine.name == "mysql":
- tables = [
- # tables that are FK parents, must be converted early
- "aggregates", "console_pools", "instance_types", "instances",
- "projects", "security_groups", "sm_backend_config", "sm_flavors",
- "snapshots", "user_project_association", "users", "volume_types",
- "volumes",
- # those that are children and others later
- "agent_builds", "aggregate_hosts", "aggregate_metadata",
- "auth_tokens", "block_device_mapping", "bw_usage_cache",
- "certificates", "compute_nodes", "consoles", "fixed_ips",
- "floating_ips", "instance_actions", "instance_faults",
- "instance_info_caches", "instance_metadata",
- "instance_type_extra_specs", "iscsi_targets", "key_pairs",
- "migrate_version", "migrations", "networks", "provider_fw_rules",
- "quotas", "s3_images", "security_group_instance_association",
- "security_group_rules", "services", "sm_volume",
- "user_project_role_association", "user_role_association",
- "virtual_interfaces", "virtual_storage_arrays", "volume_metadata",
- "volume_type_extra_specs"]
- sql = "SET foreign_key_checks = 0;"
- for table in tables:
- sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
- sql += "SET foreign_key_checks = 1;"
- sql += "ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" \
- % migrate_engine.url.database
+ # In Folsom we explicitly converted migrate_version to UTF8.
+ sql = "ALTER TABLE migrate_version CONVERT TO CHARACTER SET utf8;"
+ # Set default DB charset to UTF8.
+ sql += "ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" % \
+ migrate_engine.url.database
migrate_engine.execute(sql)
+ # TODO(dprince): due to the upgrade scripts in Folsom the unique key
+ # on instance_uuid is named 'instance_id'. Rename it in Grizzly?
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name='instance_id').create()
+
if migrate_engine.name == "postgresql":
- # NOTE(dprince): Need to rename the leftover zones stuff.
- # https://bugs.launchpad.net/nova/+bug/993667
- sql = "ALTER TABLE cells_id_seq RENAME TO zones_id_seq;"
- sql += "ALTER TABLE ONLY cells DROP CONSTRAINT cells_pkey;"
- sql += "ALTER TABLE ONLY cells ADD CONSTRAINT zones_pkey" \
- " PRIMARY KEY (id);"
-
- # NOTE(dprince): Need to rename the leftover quota_new stuff.
- # https://bugs.launchpad.net/nova/+bug/993669
- sql += "ALTER TABLE quotas_id_seq RENAME TO quotas_new_id_seq;"
- sql += "ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_pkey;"
- sql += "ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_new_pkey" \
- " PRIMARY KEY (id);"
+ # TODO(dprince): Drop this in Grizzly. Snapshots were converted
+ # to UUIDs in Folsom so we no longer require this autocreated
+ # sequence.
+ sql = """CREATE SEQUENCE snapshots_id_seq START WITH 1 INCREMENT BY 1
+ NO MINVALUE NO MAXVALUE CACHE 1;
+ ALTER SEQUENCE snapshots_id_seq OWNED BY snapshots.id;
+ SELECT pg_catalog.setval('snapshots_id_seq', 1, false);
+ ALTER TABLE ONLY snapshots ALTER COLUMN id SET DEFAULT
+ nextval('snapshots_id_seq'::regclass);"""
+
+ # TODO(dprince): Drop this in Grizzly. Volumes were converted
+ # to UUIDs in Folsom so we no longer require this autocreated
+ # sequence.
+ sql += """CREATE SEQUENCE volumes_id_seq START WITH 1 INCREMENT BY 1
+ NO MINVALUE NO MAXVALUE CACHE 1;
+ ALTER SEQUENCE volumes_id_seq OWNED BY volumes.id;
+ SELECT pg_catalog.setval('volumes_id_seq', 1, false);
+ ALTER TABLE ONLY volumes ALTER COLUMN id SET DEFAULT
+ nextval('volumes_id_seq'::regclass);"""
migrate_engine.execute(sql)
+ # TODO(dprince): due to the upgrade scripts in Folsom the unique key
+ # on instance_uuid is named '.._instance_id_..'. Rename it in Grizzly?
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name='instance_info_caches_instance_id_key').create()
+
# populate initial instance types
_populate_instance_types(instance_types)
def downgrade(migrate_engine):
- raise Exception('Downgrade from Essex is unsupported.')
+ LOG.exception(_('Downgrade from Folsom is unsupported.'))
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 5ec91ca14..d82ae7585 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -304,203 +304,3 @@ class TestMigrations(test.TestCase):
self.assertEqual(version,
migration_api.db_version(engine,
TestMigrations.REPOSITORY))
-
- def test_migration_98(self):
- """Test that migration 98 runs
-
- This test exists to prove bug 1047633 has been fixed
- """
- for key, engine in self.engines.items():
- migration_api.version_control(engine, TestMigrations.REPOSITORY,
- migration.INIT_VERSION)
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 97)
-
- # Set up a single volume, values don't matter
- metadata = sqlalchemy.schema.MetaData()
- metadata.bind = engine
- volumes = sqlalchemy.Table('volumes', metadata, autoload=True)
- vol_id = '9db3c2e5-8cac-4e94-9e6c-b5f750736727'
- volumes.insert().values(id=vol_id).execute()
-
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 98)
- migration_api.downgrade(engine, TestMigrations.REPOSITORY, 97)
-
- def test_migration_91(self):
- """Test that migration 91 works correctly.
-
- This test prevents regression of bugs 1052244 and 1052220.
- """
- for key, engine in self.engines.items():
- migration_api.version_control(engine, TestMigrations.REPOSITORY,
- migration.INIT_VERSION)
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 90)
-
- vol1_id = '10'
- vol1_uuid = '9db3c2e5-8cac-4e94-9e6c-b5f750736727'
-
- vol2_id = '11'
- vol2_uuid = 'fb17fb5a-ca3d-4bba-8903-fc776ea81d78'
-
- snap_id = '7'
- snap_uuid = 'a87e5108-8a2b-4c89-be96-0e8760db2c6a'
-
- inst_id = '0ec45d38-aefd-4c42-a209-361e848240b7'
-
- metadata = sqlalchemy.schema.MetaData()
- metadata.bind = engine
-
- instances = sqlalchemy.Table('instances', metadata, autoload=True)
- volumes = sqlalchemy.Table('volumes', metadata, autoload=True)
- sm_flavors = sqlalchemy.Table(
- 'sm_flavors', metadata, autoload=True)
- sm_backend_config = sqlalchemy.Table(
- 'sm_backend_config', metadata, autoload=True)
- sm_volume = sqlalchemy.Table(
- 'sm_volume', metadata, autoload=True)
- volume_mappings = sqlalchemy.Table(
- 'volume_id_mappings', metadata, autoload=True)
- iscsi_targets = sqlalchemy.Table(
- 'iscsi_targets', metadata, autoload=True)
- volume_metadata = sqlalchemy.Table(
- 'volume_metadata', metadata, autoload=True)
- snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True)
- snapshot_mappings = sqlalchemy.Table(
- 'snapshot_id_mappings', metadata, autoload=True)
- block_device_mapping = sqlalchemy.Table(
- 'block_device_mapping', metadata, autoload=True)
-
- volumes.insert().values(id=vol1_id).execute()
- volume_mappings.insert() \
- .values(id=vol1_id, uuid=vol1_uuid).execute()
- snapshots.insert().values(id=snap_id, volume_id=vol1_id).execute()
- snapshot_mappings.insert() \
- .values(id=snap_id, uuid=snap_uuid).execute()
- volumes.insert().values(id=vol2_id, snapshot_id=snap_id).execute()
- volume_mappings.insert() \
- .values(id=vol2_id, uuid=vol2_uuid).execute()
- sm_flavors.insert().values(id=7).execute()
- sm_backend_config.insert().values(id=7, flavor_id=7).execute()
- sm_volume.insert().values(id=vol1_id, backend_id=7).execute()
- volume_metadata.insert().values(id=7, volume_id=vol1_id).execute()
- iscsi_targets.insert().values(id=7, volume_id=vol1_id).execute()
- instances.insert().values(id=7, uuid=inst_id).execute()
- block_device_mapping.insert()\
- .values(id=7, volume_id=vol1_id, instance_uuid=inst_id) \
- .execute()
-
- vols = volumes.select().execute().fetchall()
- self.assertEqual(set([vol.id for vol in vols]),
- set([vol1_id, vol2_id]))
- self.assertEqual(snap_id, vols[1].snapshot_id)
-
- query = volume_metadata.select(volume_metadata.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- query = iscsi_targets.select(iscsi_targets.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- query = block_device_mapping.select(block_device_mapping.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall()
- self.assertEqual(set([snap.id for snap in snaps]),
- set([snap_id]))
-
- sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall()
- self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]),
- set([vol1_id]))
-
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 91)
-
- vols = volumes.select().execute().fetchall()
- self.assertEqual(set([vol.id for vol in vols]),
- set([vol1_uuid, vol2_uuid]))
- self.assertEqual(snap_uuid, vols[1].snapshot_id)
-
- query = volume_metadata.select(volume_metadata.c.id == 7)
- self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id)
-
- query = iscsi_targets.select(iscsi_targets.c.id == 7)
- self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id)
-
- query = block_device_mapping.select(block_device_mapping.c.id == 7)
- self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id)
-
- snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall()
- self.assertEqual(set([snap.id for snap in snaps]),
- set([snap_uuid]))
-
- sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall()
- self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]),
- set([vol1_uuid]))
-
- migration_api.downgrade(engine, TestMigrations.REPOSITORY, 90)
-
- vols = volumes.select().execute().fetchall()
- self.assertEqual(set([vol.id for vol in vols]),
- set([vol1_id, vol2_id]))
- self.assertEqual(snap_id, vols[1].snapshot_id)
-
- query = volume_metadata.select(volume_metadata.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- query = iscsi_targets.select(iscsi_targets.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- query = block_device_mapping.select(block_device_mapping.c.id == 7)
- self.assertEqual(vol1_id, query.execute().fetchone().volume_id)
-
- snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall()
- self.assertEqual(set([snap.id for snap in snaps]),
- set([snap_id]))
-
- sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall()
- self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]),
- set([vol1_id]))
-
- def test_migration_111(self):
- for key, engine in self.engines.items():
- migration_api.version_control(engine, TestMigrations.REPOSITORY,
- migration.INIT_VERSION)
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 110)
-
- metadata = sqlalchemy.schema.MetaData()
- metadata.bind = engine
- aggregate_hosts = sqlalchemy.Table('aggregate_hosts', metadata,
- autoload=True)
- host = 'host'
- aggregate_hosts.insert().values(id=1,
- aggregate_id=1, host=host).execute()
-
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 111)
- agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first()
- self.assertEqual(host, agg.host)
- aggregate_hosts.insert().values(id=2,
- aggregate_id=2, host=host).execute()
-
- migration_api.downgrade(engine, TestMigrations.REPOSITORY, 111)
- agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first()
- self.assertEqual(host, agg.host)
-
- def test_migration_133(self):
- for key, engine in self.engines.items():
- migration_api.version_control(engine, TestMigrations.REPOSITORY,
- migration.INIT_VERSION)
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 132)
-
- # Set up a single volume, values don't matter
- metadata = sqlalchemy.schema.MetaData()
- metadata.bind = engine
- aggregates = sqlalchemy.Table('aggregates', metadata,
- autoload=True)
- name = 'name'
- aggregates.insert().values(id=1, availability_zone='nova',
- aggregate_name=1, name=name).execute()
-
- migration_api.upgrade(engine, TestMigrations.REPOSITORY, 133)
- aggregates.insert().values(id=2, availability_zone='nova',
- aggregate_name=2, name=name).execute()
-
- migration_api.downgrade(engine, TestMigrations.REPOSITORY, 132)
- agg = sqlalchemy.select([aggregates.c.name]).execute().first()
- self.assertEqual(name, agg.name)