From ee021608540f57a1cfc7aed19fcc98d37a7db4ef Mon Sep 17 00:00:00 2001
From: Yulia Portnova <yportnova>
Date: Mon, 2 Sep 2013 15:05:13 +0300
Subject: [PATCH] Modified migrations

---
 ...{001_cinder_init.py => 001_manila_init.py} | 118 +------------
 ...hare_tables.py => 003_add_share_tables.py} |   0
 .../versions/003_glance_metadata.py           |  78 ---------
 ...ble.py => 004_add_share_snapshot_table.py} |   0
 .../versions/004_volume_type_to_uuid.py       | 155 ------------------
 .../versions/005_add_source_volume_column.py  |  41 -----
 .../versions/005_sqlite_downgrade.sql         | 124 --------------
 .../006_snapshots_add_provider_location.py    |  36 ----
 .../versions/007_add_volume_snapshot_fk.py    |  41 -----
 .../versions/007_sqlite_downgrade.sql         |  32 ----
 .../migrate_repo/versions/008_add_backup.py   |  95 -----------
 .../009_add_snapshot_metadata_table.py        |  60 -------
 12 files changed, 2 insertions(+), 778 deletions(-)
 rename manila/db/sqlalchemy/migrate_repo/versions/{001_cinder_init.py => 001_manila_init.py} (55%)
 rename manila/db/sqlalchemy/migrate_repo/versions/{010_add_share_tables.py => 003_add_share_tables.py} (100%)
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py
 rename manila/db/sqlalchemy/migrate_repo/versions/{011_add_share_snapshot_table.py => 004_add_share_snapshot_table.py} (100%)
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/006_snapshots_add_provider_location.py
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/007_add_volume_snapshot_fk.py
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
 delete mode 100644 manila/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py

diff --git a/manila/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py b/manila/db/sqlalchemy/migrate_repo/versions/001_manila_init.py
similarity index 55%
rename from manila/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py
rename to manila/db/sqlalchemy/migrate_repo/versions/001_manila_init.py
index e40c0e95f4..dace97f38b 100644
--- a/manila/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py
+++ b/manila/db/sqlalchemy/migrate_repo/versions/001_manila_init.py
@@ -105,94 +105,6 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB'
     )
 
-    snapshots = Table(
-        'snapshots', 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('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'
-    )
-
-    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'
-    )
-
-    volume_metadata = Table(
-        'volume_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('volume_id', String(length=36), ForeignKey('volumes.id'),
-               nullable=False),
-        Column('key', String(length=255)),
-        Column('value', String(length=255)),
-        mysql_engine='InnoDB'
-    )
-
-    volume_type_extra_specs = Table(
-        'volume_type_extra_specs', 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_type_id', Integer, ForeignKey('volume_types.id'),
-               nullable=False),
-        Column('key', String(length=255)),
-        Column('value', String(length=255)),
-        mysql_engine='InnoDB'
-    )
-
-    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_uuid', String(length=36)),
-        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),
-        Column('launched_at', DateTime),
-        Column('terminated_at', DateTime),
-        Column('display_name', String(length=255)),
-        Column('display_description', String(length=255)),
-        Column('provider_location', String(length=256)),
-        Column('provider_auth', String(length=256)),
-        Column('snapshot_id', String(length=36)),
-        Column('volume_type_id', Integer),
-        mysql_engine='InnoDB'
-    )
-
     quotas = Table(
         'quotas', meta,
         Column('id', Integer, primary_key=True, nullable=False),
@@ -206,34 +118,14 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB'
     )
 
-    iscsi_targets = Table(
-        'iscsi_targets', 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('target_num', Integer),
-        Column('host', String(length=255)),
-        Column('volume_id', String(length=36), ForeignKey('volumes.id'),
-               nullable=True),
-        mysql_engine='InnoDB'
-    )
-
     # create all tables
     # Take care on create order for those with FK dependencies
     tables = [sm_flavors,
               sm_backend_config,
-              snapshots,
-              volume_types,
-              volumes,
-              iscsi_targets,
               migrations,
               quotas,
               services,
-              sm_volume,
-              volume_metadata,
-              volume_type_extra_specs]
+              sm_volume]
 
     for table in tables:
         try:
@@ -246,17 +138,11 @@ def upgrade(migrate_engine):
     if migrate_engine.name == "mysql":
         tables = ["sm_flavors",
                   "sm_backend_config",
-                  "snapshots",
-                  "volume_types",
-                  "volumes",
-                  "iscsi_targets",
                   "migrate_version",
                   "migrations",
                   "quotas",
                   "services",
-                  "sm_volume",
-                  "volume_metadata",
-                  "volume_type_extra_specs"]
+                  "sm_volume"]
 
         sql = "SET foreign_key_checks = 0;"
         for table in tables:
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/010_add_share_tables.py b/manila/db/sqlalchemy/migrate_repo/versions/003_add_share_tables.py
similarity index 100%
rename from manila/db/sqlalchemy/migrate_repo/versions/010_add_share_tables.py
rename to manila/db/sqlalchemy/migrate_repo/versions/003_add_share_tables.py
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py b/manila/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py
deleted file mode 100644
index 83fac2c410..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py
+++ /dev/null
@@ -1,78 +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 Column, DateTime, Text, Boolean
-from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-
-from manila.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    # Just for the ForeignKey and column creation to succeed, these are not the
-    # actual definitions of tables .
-    #
-    volumes = Table('volumes',
-                    meta,
-                    Column('id', Integer(),
-                           primary_key=True, nullable=False),
-                    mysql_engine='InnoDB')
-    snapshots = Table('snapshots',
-                      meta,
-                      Column('id', Integer(),
-                             primary_key=True, nullable=False),
-                      mysql_engine='InnoDB')
-    # Create new table
-    volume_glance_metadata = Table(
-        'volume_glance_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('volume_id', String(length=36), ForeignKey('volumes.id')),
-        Column('snapshot_id', String(length=36),
-               ForeignKey('snapshots.id')),
-        Column('key', String(255)),
-        Column('value', Text),
-        mysql_engine='InnoDB'
-    )
-
-    try:
-        volume_glance_metadata.create()
-    except Exception:
-        LOG.exception(_("Exception while creating table "
-                        "'volume_glance_metedata'"))
-        meta.drop_all(tables=[volume_glance_metadata])
-        raise
-
-
-def downgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    volume_glance_metadata = Table('volume_glance_metadata',
-                                   meta, autoload=True)
-    try:
-        volume_glance_metadata.drop()
-    except Exception:
-        LOG.error(_("volume_glance_metadata table not dropped"))
-        raise
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/011_add_share_snapshot_table.py b/manila/db/sqlalchemy/migrate_repo/versions/004_add_share_snapshot_table.py
similarity index 100%
rename from manila/db/sqlalchemy/migrate_repo/versions/011_add_share_snapshot_table.py
rename to manila/db/sqlalchemy/migrate_repo/versions/004_add_share_snapshot_table.py
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py b/manila/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py
deleted file mode 100644
index ca145ac58b..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-#    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 manila.openstack.common import log as logging
-from migrate import ForeignKeyConstraint
-from sqlalchemy import Integer, MetaData, String, Table
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
-    """Convert volume_type_id to UUID."""
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    volumes = Table('volumes', meta, autoload=True)
-    volume_types = Table('volume_types', meta, autoload=True)
-    extra_specs = Table('volume_type_extra_specs', meta, autoload=True)
-
-    fkey_remove_list = [volumes.c.volume_type_id,
-                        volume_types.c.id,
-                        extra_specs.c.volume_type_id]
-
-    for column in fkey_remove_list:
-        fkeys = list(column.foreign_keys)
-        if fkeys:
-            fkey_name = fkeys[0].constraint.name
-            fkey = ForeignKeyConstraint(columns=[column],
-                                        refcolumns=[volume_types.c.id],
-                                        name=fkey_name)
-
-            try:
-                fkey.drop()
-            except Exception:
-                if migrate_engine.url.get_dialect().name.startswith('sqlite'):
-                    pass
-                else:
-                    raise
-
-    volumes.c.volume_type_id.alter(String(36))
-    volume_types.c.id.alter(String(36))
-    extra_specs.c.volume_type_id.alter(String(36))
-
-    vtype_list = list(volume_types.select().execute())
-    for t in vtype_list:
-        new_id = str(uuid.uuid4())
-
-        volumes.update().\
-            where(volumes.c.volume_type_id == t['id']).\
-            values(volume_type_id=new_id).execute()
-
-        extra_specs.update().\
-            where(extra_specs.c.volume_type_id == t['id']).\
-            values(volume_type_id=new_id).execute()
-
-        volume_types.update().\
-            where(volume_types.c.id == t['id']).\
-            values(id=new_id).execute()
-
-    for column in fkey_remove_list:
-        fkeys = list(column.foreign_keys)
-        if fkeys:
-            fkey_name = fkeys[0].constraint.name
-            fkey = ForeignKeyConstraint(columns=[column],
-                                        refcolumns=[volume_types.c.id],
-                                        name=fkey_name)
-            try:
-                fkey.create()
-                LOG.info('Created foreign key %s' % fkey_name)
-            except Exception:
-                if migrate_engine.url.get_dialect().name.startswith('sqlite'):
-                    pass
-                else:
-                    raise
-
-
-def downgrade(migrate_engine):
-    """Convert volume_type from UUID back to int."""
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    volumes = Table('volumes', meta, autoload=True)
-    volume_types = Table('volume_types', meta, autoload=True)
-    extra_specs = Table('volume_type_extra_specs', meta, autoload=True)
-
-    fkey_remove_list = [volumes.c.volume_type_id,
-                        volume_types.c.id,
-                        extra_specs.c.volume_type_id]
-
-    for column in fkey_remove_list:
-        fkeys = list(column.foreign_keys)
-        if fkeys:
-            fkey_name = fkeys[0].constraint.name
-            fkey = ForeignKeyConstraint(columns=[column],
-                                        refcolumns=[volume_types.c.id],
-                                        name=fkey_name)
-
-            try:
-                fkey.drop()
-            except Exception:
-                if migrate_engine.url.get_dialect().name.startswith('sqlite'):
-                    pass
-                else:
-                    raise
-
-    vtype_list = list(volume_types.select().execute())
-    new_id = 1
-
-    for t in vtype_list:
-        volumes.update().\
-            where(volumes.c.volume_type_id == t['id']).\
-            values(volume_type_id=new_id).execute()
-
-        extra_specs.update().\
-            where(extra_specs.c.volume_type_id == t['id']).\
-            values(volume_type_id=new_id).execute()
-
-        volume_types.update().\
-            where(volume_types.c.id == t['id']).\
-            values(id=new_id).execute()
-
-        new_id += 1
-
-    volumes.c.volume_type_id.alter(Integer)
-    volume_types.c.id.alter(Integer)
-    extra_specs.c.volume_type_id.alter(Integer)
-
-    for column in fkey_remove_list:
-        fkeys = list(column.foreign_keys)
-        if fkeys:
-            fkey_name = fkeys[0].constraint.name
-            fkey = ForeignKeyConstraint(columns=[column],
-                                        refcolumns=[volume_types.c.id],
-                                        name=fkey_name)
-            try:
-                fkey.create()
-                LOG.info('Created foreign key %s' % fkey_name)
-            except Exception:
-                if migrate_engine.url.get_dialect().name.startswith('sqlite'):
-                    pass
-                else:
-                    raise
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py b/manila/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py
deleted file mode 100644
index 8894ec4842..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-#    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 manila.openstack.common import log as logging
-from sqlalchemy import Column
-from sqlalchemy import MetaData, String, Table
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
-    """Add source volume id column to volumes."""
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    volumes = Table('volumes', meta, autoload=True)
-    source_volid = Column('source_volid', String(36))
-    volumes.create_column(source_volid)
-    volumes.update().values(source_volid=None).execute()
-
-
-def downgrade(migrate_engine):
-    """Remove source volume id column to volumes."""
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    volumes = Table('volumes', meta, autoload=True)
-    source_volid = Column('source_volid', String(36))
-    volumes.drop_column(source_volid)
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql b/manila/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql
deleted file mode 100644
index c34f31752f..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql
+++ /dev/null
@@ -1,124 +0,0 @@
-BEGIN TRANSACTION;
-
-CREATE TEMPORARY TABLE volumes_backup (
-    created_at DATETIME,
-    updated_at DATETIME,
-    deleted_at DATETIME,
-    deleted BOOLEAN,
-    id VARCHAR(36) NOT NULL,
-    ec2_id VARCHAR(255),
-    user_id VARCHAR(255),
-    project_id VARCHAR(255),
-    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(256),
-    provider_auth VARCHAR(256),
-    snapshot_id VARCHAR(36),
-    volume_type_id VARCHAR(36),
-    source_volid VARCHAR(36),
-    PRIMARY KEY (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,
-          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,
-          snapshot_id,
-          volume_type_id,
-          source_volid
-      FROM volumes;
-
-DROP TABLE volumes;
-
-CREATE TABLE volumes (
-    created_at DATETIME,
-    updated_at DATETIME,
-    deleted_at DATETIME,
-    deleted BOOLEAN,
-    id VARCHAR(36) NOT NULL,
-    ec2_id VARCHAR(255),
-    user_id VARCHAR(255),
-    project_id VARCHAR(255),
-    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(256),
-    provider_auth VARCHAR(256),
-    snapshot_id VARCHAR(36),
-    volume_type_id VARCHAR(36),
-    PRIMARY KEY (id),
-    CHECK (deleted IN (0, 1))
-);
-
-INSERT INTO volumes
-    SELECT created_at,
-          updated_at,
-          deleted_at,
-          deleted,
-          id,
-          ec2_id,
-          user_id,
-          project_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,
-          snapshot_id,
-          volume_type_id
-    FROM volumes_backup;
-
-DROP TABLE volumes_backup;
-COMMIT;
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/006_snapshots_add_provider_location.py b/manila/db/sqlalchemy/migrate_repo/versions/006_snapshots_add_provider_location.py
deleted file mode 100644
index ddd86d3228..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/006_snapshots_add_provider_location.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-#    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 Column
-from sqlalchemy import MetaData, String, Table
-
-
-def upgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    snapshots = Table('snapshots', meta, autoload=True)
-    provider_location = Column('provider_location', String(255))
-    snapshots.create_column(provider_location)
-    snapshots.update().values(provider_location=None).execute()
-
-
-def downgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    snapshots = Table('snapshots', meta, autoload=True)
-    provider_location = snapshots.columns.provider_location
-    snapshots.drop_column(provider_location)
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/007_add_volume_snapshot_fk.py b/manila/db/sqlalchemy/migrate_repo/versions/007_add_volume_snapshot_fk.py
deleted file mode 100644
index 90cd67cd3b..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/007_add_volume_snapshot_fk.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-#    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.changeset.constraint import ForeignKeyConstraint
-
-
-def upgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    snapshots = Table('snapshots', meta, autoload=True)
-    volumes = Table('volumes', meta, autoload=True)
-
-    ForeignKeyConstraint(
-        columns=[snapshots.c.volume_id],
-        refcolumns=[volumes.c.id]).create()
-
-
-def downgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    snapshots = Table('snapshots', meta, autoload=True)
-    volumes = Table('volumes', meta, autoload=True)
-
-    ForeignKeyConstraint(
-        columns=[snapshots.c.volume_id],
-        refcolumns=[volumes.c.id]).drop()
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql b/manila/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql
deleted file mode 100644
index d2fe9b6930..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql
+++ /dev/null
@@ -1,32 +0,0 @@
--- As sqlite does not support the DROP FOREIGN KEY, we need to create
--- the table, and move all the data to it.
-
-BEGIN TRANSACTION;
-
-CREATE TABLE snapshots_v6 (
-    created_at DATETIME,
-    updated_at DATETIME,
-    deleted_at DATETIME,
-    deleted BOOLEAN,
-    id VARCHAR(36) NOT NULL,
-    volume_id VARCHAR(36) NOT NULL,
-    user_id VARCHAR(255),
-    project_id VARCHAR(255),
-    status VARCHAR(255),
-    progress VARCHAR(255),
-    volume_size INTEGER,
-    scheduled_at DATETIME,
-    display_name VARCHAR(255),
-    display_description VARCHAR(255),
-    provider_location VARCHAR(255),
-    PRIMARY KEY (id),
-    CHECK (deleted IN (0, 1))
-);
-
-INSERT INTO snapshots_v6 SELECT * FROM snapshots;
-
-DROP TABLE snapshots;
-
-ALTER TABLE snapshots_v6 RENAME TO snapshots;
-
-COMMIT;
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/008_add_backup.py b/manila/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
deleted file mode 100644
index 085c11bd16..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
-# 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
-from sqlalchemy import MetaData, Integer, String, Table
-
-from manila.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    # New table
-    backups = Table(
-        'backups', 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', String(36), primary_key=True, nullable=False),
-        Column('volume_id', String(36), nullable=False),
-        Column('user_id', String(length=255, convert_unicode=False,
-                                 unicode_error=None,
-                                 _warn_on_bytestring=False)),
-        Column('project_id', String(length=255, convert_unicode=False,
-                                    unicode_error=None,
-                                    _warn_on_bytestring=False)),
-        Column('host', String(length=255, convert_unicode=False,
-                              unicode_error=None,
-                              _warn_on_bytestring=False)),
-        Column('availability_zone', String(length=255,
-                                           convert_unicode=False,
-                                           unicode_error=None,
-                                           _warn_on_bytestring=False)),
-        Column('display_name', String(length=255, convert_unicode=False,
-                                      unicode_error=None,
-                                      _warn_on_bytestring=False)),
-        Column('display_description', String(length=255,
-                                             convert_unicode=False,
-                                             unicode_error=None,
-                                             _warn_on_bytestring=False)),
-        Column('container', String(length=255, convert_unicode=False,
-                                   unicode_error=None,
-                                   _warn_on_bytestring=False)),
-        Column('status', String(length=255, convert_unicode=False,
-                                unicode_error=None,
-                                _warn_on_bytestring=False)),
-        Column('fail_reason', String(length=255, convert_unicode=False,
-                                     unicode_error=None,
-                                     _warn_on_bytestring=False)),
-        Column('service_metadata', String(length=255, convert_unicode=False,
-                                          unicode_error=None,
-                                          _warn_on_bytestring=False)),
-        Column('service', String(length=255, convert_unicode=False,
-                                 unicode_error=None,
-                                 _warn_on_bytestring=False)),
-        Column('size', Integer()),
-        Column('object_count', Integer()),
-        mysql_engine='InnoDB'
-    )
-
-    try:
-        backups.create()
-    except Exception:
-        LOG.error(_("Table |%s| not created!"), repr(backups))
-        raise
-
-
-def downgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    backups = Table('backups', meta, autoload=True)
-    try:
-        backups.drop()
-    except Exception:
-        LOG.error(_("backups table not dropped"))
-        raise
diff --git a/manila/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py b/manila/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py
deleted file mode 100644
index 0f7fc51a56..0000000000
--- a/manila/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-#    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 Integer, MetaData, String, Table, ForeignKey
-
-from manila.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-
-    snapshots = Table('snapshots', meta, autoload=True)
-
-    # New table
-    snapshot_metadata = Table(
-        'snapshot_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('snapshot_id', String(length=36), ForeignKey('snapshots.id'),
-               nullable=False),
-        Column('key', String(length=255)),
-        Column('value', String(length=255)),
-        mysql_engine='InnoDB'
-    )
-
-    try:
-        snapshot_metadata.create()
-    except Exception:
-        LOG.error(_("Table |%s| not created!"), repr(snapshot_metadata))
-        raise
-
-
-def downgrade(migrate_engine):
-    meta = MetaData()
-    meta.bind = migrate_engine
-    snapshot_metadata = Table('snapshot_metadata',
-                              meta,
-                              autoload=True)
-    try:
-        snapshot_metadata.drop()
-    except Exception:
-        LOG.error(_("snapshot_metadata table not dropped"))