From 0759d68135eec4aba89f78c46c3df1928ea37111 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Fri, 23 Aug 2024 22:42:06 +0800 Subject: [PATCH] Remove outdated migration script Change-Id: I6365b37b7b31dbc7337aa4903e4ad4cf27df9faf --- trove/db/sqlalchemy/migrate_repo/README | 4 - trove/db/sqlalchemy/migrate_repo/__init__.py | 0 trove/db/sqlalchemy/migrate_repo/manage.py | 21 --- trove/db/sqlalchemy/migrate_repo/migrate.cfg | 21 --- trove/db/sqlalchemy/migrate_repo/schema.py | 79 ----------- .../migrate_repo/versions/001_base_schema.py | 45 ------ .../versions/002_service_images.py | 36 ----- .../versions/003_service_statuses.py | 40 ------ .../migrate_repo/versions/004_root_enabled.py | 38 ----- .../migrate_repo/versions/005_heartbeat.py | 37 ----- .../migrate_repo/versions/006_dns_records.py | 35 ----- .../versions/007_add_volume_flavor.py | 33 ----- .../versions/008_add_instance_fields.py | 29 ---- .../009_add_deleted_flag_to_instances.py | 30 ---- .../migrate_repo/versions/010_add_usage.py | 45 ------ .../migrate_repo/versions/011_quota.py | 61 -------- .../migrate_repo/versions/012_backup.py | 47 ------- .../013_add_security_group_artifacts.py | 89 ------------ .../versions/014_update_instance_flavor_id.py | 34 ----- .../versions/015_add_service_type.py | 28 ---- .../versions/016_add_datastore_type.py | 62 --------- .../versions/017_update_datastores.py | 48 ------- .../versions/018_datastore_versions_fix.py | 25 ---- .../versions/019_datastore_fix.py | 131 ------------------ .../versions/020_configurations.py | 59 -------- .../versions/021_conductor_last_seen.py | 35 ----- .../versions/022_add_backup_parent_id.py | 28 ---- .../versions/023_add_instance_indexes.py | 42 ------ .../versions/024_add_backup_indexes.py | 42 ------ .../025_add_service_statuses_indexes.py | 35 ----- .../026_datastore_versions_unique_fix.py | 43 ------ .../027_add_datastore_capabilities.py | 55 -------- .../versions/028_recreate_agent_heartbeat.py | 55 -------- .../versions/029_add_backup_datastore.py | 30 ---- .../versions/030_add_master_slave.py | 32 ----- .../031_add_timestamps_to_configurations.py | 28 ---- .../migrate_repo/versions/032_clusters.py | 59 -------- .../versions/033_datastore_parameters.py | 54 -------- .../versions/034_change_task_description.py | 25 ---- .../versions/035_flavor_id_int_to_string.py | 28 ---- .../036_add_datastore_version_metadata.py | 55 -------- .../migrate_repo/versions/037_modules.py | 78 ----------- .../versions/038_instance_faults.py | 50 ------- .../migrate_repo/versions/039_region.py | 36 ----- .../versions/040_module_priority.py | 49 ------- .../versions/041_instance_keys.py | 30 ---- .../042_add_cluster_configuration_id.py | 38 ----- .../043_instance_ds_version_nullable.py | 50 ------- ...astore_configuration_parameters_deleted.py | 67 --------- .../versions/045_add_backup_strategy.py | 46 ------ .../versions/046_add_access_to_instance.py | 28 ---- .../047_image_tag_in_datastore_version.py | 29 ---- .../048_add_version_to_datastore_version.py | 71 ---------- ...9_add_registry_ext_to_datastore_version.py | 79 ----------- .../migrate_repo/versions/__init__.py | 0 55 files changed, 2374 deletions(-) delete mode 100644 trove/db/sqlalchemy/migrate_repo/README delete mode 100644 trove/db/sqlalchemy/migrate_repo/__init__.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/manage.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/migrate.cfg delete mode 100644 trove/db/sqlalchemy/migrate_repo/schema.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/001_base_schema.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/002_service_images.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/003_service_statuses.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/004_root_enabled.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/005_heartbeat.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/007_add_volume_flavor.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/008_add_instance_fields.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/009_add_deleted_flag_to_instances.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/010_add_usage.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/011_quota.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/012_backup.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/015_add_service_type.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/017_update_datastores.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/022_add_backup_parent_id.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/028_recreate_agent_heartbeat.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/029_add_backup_datastore.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/034_change_task_description.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/035_flavor_id_int_to_string.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/036_add_datastore_version_metadata.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/037_modules.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/039_region.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/040_module_priority.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/041_instance_keys.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/043_instance_ds_version_nullable.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/044_remove_datastore_configuration_parameters_deleted.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/045_add_backup_strategy.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/046_add_access_to_instance.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/047_image_tag_in_datastore_version.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/048_add_version_to_datastore_version.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/049_add_registry_ext_to_datastore_version.py delete mode 100644 trove/db/sqlalchemy/migrate_repo/versions/__init__.py diff --git a/trove/db/sqlalchemy/migrate_repo/README b/trove/db/sqlalchemy/migrate_repo/README deleted file mode 100644 index 6218f8cac4..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/README +++ /dev/null @@ -1,4 +0,0 @@ -This is a database migration repository. - -More information at -http://code.google.com/p/sqlalchemy-migrate/ diff --git a/trove/db/sqlalchemy/migrate_repo/__init__.py b/trove/db/sqlalchemy/migrate_repo/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/trove/db/sqlalchemy/migrate_repo/manage.py b/trove/db/sqlalchemy/migrate_repo/manage.py deleted file mode 100644 index 0ed08637f1..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/manage.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2011 OpenStack Foundation -# 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.versioning.shell import main - -if __name__ == "__main__": - main(debug='False', repository='.') diff --git a/trove/db/sqlalchemy/migrate_repo/migrate.cfg b/trove/db/sqlalchemy/migrate_repo/migrate.cfg deleted file mode 100644 index 4e362a237c..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/migrate.cfg +++ /dev/null @@ -1,21 +0,0 @@ -[db_settings] -# Used to identify which repository this database is versioned under. -# You can use the name of your project. -repository_id=Trove Migrations - -# The name of the database table used to track the schema version. -# This name shouldn't already be used by your project. -# If this is changed once a database is under version control, you'll need to -# change the table name in each database too. -version_table=migrate_version - -# When committing a change script, Migrate will attempt to generate the -# sql for all supported databases; normally, if one of them fails - probably -# because you don't have that database installed - it is ignored and the -# commit continues, perhaps ending successfully. -# Databases in this list MUST compile successfully during a commit, or the -# entire commit will fail. List the databases your application will actually -# be using to ensure your updates to that database work properly. -# This must be a list; example: ['postgres','sqlite'] - -required_dbs=['mysql','postgres','sqlite'] diff --git a/trove/db/sqlalchemy/migrate_repo/schema.py b/trove/db/sqlalchemy/migrate_repo/schema.py deleted file mode 100644 index b4f69d6303..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/schema.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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. - -"""Various conveniences used for migration scripts.""" - -from oslo_log import log as logging -import sqlalchemy.types - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -class String(sqlalchemy.types.String): - def __init__(self, length, *args, **kwargs): - super(String, self).__init__(*args, length=length, **kwargs) - - -class Text(sqlalchemy.types.Text): - def __init__(self, length=None, *args, **kwargs): - super(Text, self).__init__(*args, **kwargs) - self.with_variant(sqlalchemy.types.Text(length=length), 'mysql') - - -class Boolean(sqlalchemy.types.Boolean): - def __init__(self, create_constraint=True, name=None, *args, **kwargs): - super(Boolean, self).__init__(*args, - create_constraint=create_constraint, - name=name, - **kwargs) - - -class DateTime(sqlalchemy.types.DateTime): - def __init__(self, timezone=False, *args, **kwargs): - super(DateTime, self).__init__(*args, - timezone=timezone, - **kwargs) - - -class Integer(sqlalchemy.types.Integer): - def __init__(self, *args, **kwargs): - super(Integer, self).__init__(*args, **kwargs) - - -class BigInteger(sqlalchemy.types.BigInteger): - def __init__(self, *args, **kwargs): - super(BigInteger, self).__init__(*args, **kwargs) - - -class Float(sqlalchemy.types.Float): - def __init__(self, *args, **kwargs): - super(Float, self).__init__(*args, **kwargs) - - -def create_tables(tables): - for table in tables: - logger.info("creating table %(table)s", {'table': table}) - table.create() - - -def drop_tables(tables): - for table in tables: - logger.info("dropping table %(table)s", {'table': table}) - table.drop() - - -def Table(name, metadata, *args, **kwargs): - return sqlalchemy.schema.Table(name, metadata, *args, - mysql_engine='INNODB', **kwargs) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/001_base_schema.py b/trove/db/sqlalchemy/migrate_repo/versions/001_base_schema.py deleted file mode 100644 index 2db500994c..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/001_base_schema.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -instances = Table( - 'instances', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('name', String(255)), - Column('hostname', String(255)), - Column('compute_instance_id', String(36)), - Column('task_id', Integer()), - Column('task_description', String(32)), - Column('task_start_time', DateTime()), - Column('volume_id', String(36))) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([instances]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/002_service_images.py b/trove/db/sqlalchemy/migrate_repo/versions/002_service_images.py deleted file mode 100644 index 3d1a1b010d..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/002_service_images.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -service_images = Table( - 'service_images', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('service_name', String(255)), - Column('image_id', String(255))) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([service_images]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/003_service_statuses.py b/trove/db/sqlalchemy/migrate_repo/versions/003_service_statuses.py deleted file mode 100644 index 416caa6cc1..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/003_service_statuses.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -service_statuses = Table( - 'service_statuses', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('instance_id', String(36), nullable=False), - Column('status_id', Integer(), nullable=False), - Column('status_description', String(64), nullable=False), - Column('updated_at', DateTime())) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([service_statuses]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/004_root_enabled.py b/trove/db/sqlalchemy/migrate_repo/versions/004_root_enabled.py deleted file mode 100644 index 478e54b26d..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/004_root_enabled.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -root_enabled_history = Table( - 'root_enabled_history', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('user', String(length=255)), - Column('created', DateTime()), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([root_enabled_history]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/005_heartbeat.py b/trove/db/sqlalchemy/migrate_repo/versions/005_heartbeat.py deleted file mode 100644 index efe4783e12..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/005_heartbeat.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -agent_heartbeats = Table( - 'agent_heartbeats', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('instance_id', String(36), nullable=False), - Column('updated_at', DateTime())) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([agent_heartbeats]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py b/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py deleted file mode 100644 index 46f97999e2..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -dns_records = Table( - 'dns_records', meta, - Column('name', String(length=255), primary_key=True), - Column('record_id', String(length=64))) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([dns_records]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/007_add_volume_flavor.py b/trove/db/sqlalchemy/migrate_repo/versions/007_add_volume_flavor.py deleted file mode 100644 index 3ee23757d1..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/007_add_volume_flavor.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # add column: - instances = Table('instances', meta, autoload=True) - volume_size = Column('volume_size', Integer()) - flavor_id = Column('flavor_id', String(36)) - - instances.create_column(flavor_id) - instances.create_column(volume_size) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/008_add_instance_fields.py b/trove/db/sqlalchemy/migrate_repo/versions/008_add_instance_fields.py deleted file mode 100644 index eb722e0691..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/008_add_instance_fields.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # add column: - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('tenant_id', String(36), nullable=True)) - instances.create_column(Column('server_status', String(64))) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/009_add_deleted_flag_to_instances.py b/trove/db/sqlalchemy/migrate_repo/versions/009_add_deleted_flag_to_instances.py deleted file mode 100644 index f5668df2b0..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/009_add_deleted_flag_to_instances.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # add column: - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('deleted', Boolean())) - instances.create_column(Column('deleted_at', DateTime())) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/010_add_usage.py b/trove/db/sqlalchemy/migrate_repo/versions/010_add_usage.py deleted file mode 100644 index b55a205643..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/010_add_usage.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -usage_events = Table( - 'usage_events', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('instance_name', String(36)), - Column('tenant_id', String(36)), - Column('nova_instance_id', String(36)), - Column('instance_size', Integer()), - Column('nova_volume_id', String(36)), - Column('volume_size', Integer()), - Column('end_time', DateTime()), - Column('updated', DateTime())) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([usage_events]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py b/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py deleted file mode 100644 index 616e18032e..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright [2013] Hewlett-Packard Development Company, L.P. - -# 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.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -quotas = Table('quotas', meta, - Column('id', String(36), - primary_key=True, nullable=False), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('tenant_id', String(36)), - Column('resource', String(length=255), nullable=False), - Column('hard_limit', Integer()), - UniqueConstraint('tenant_id', 'resource')) - -quota_usages = Table('quota_usages', meta, - Column('id', String(36), - primary_key=True, nullable=False), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('tenant_id', String(36)), - Column('in_use', Integer(), default=0), - Column('reserved', Integer(), default=0), - Column('resource', String(length=255), nullable=False), - UniqueConstraint('tenant_id', 'resource')) - -reservations = Table('reservations', meta, - Column('created', DateTime()), - Column('updated', DateTime()), - Column('id', String(36), - primary_key=True, nullable=False), - Column('usage_id', String(36)), - Column('delta', Integer(), nullable=False), - Column('status', String(length=36))) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([quotas, quota_usages, reservations]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py b/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py deleted file mode 100644 index 6da31474c5..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright [2013] Hewlett-Packard Development Company, L.P. - -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Float -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - -meta = MetaData() - -backups = Table('backups', meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('name', String(255), nullable=False), - Column('description', String(512)), - Column('location', String(1024)), - Column('backup_type', String(32)), - Column('size', Float()), - Column('tenant_id', String(36)), - Column('state', String(32), nullable=False), - Column('instance_id', String(36)), - Column('checksum', String(32)), - Column('backup_timestamp', DateTime()), - Column('deleted', Boolean()), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('deleted_at', DateTime())) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([backups, ]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py b/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py deleted file mode 100644 index 499be5fdd0..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2011 OpenStack Foundation -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -security_groups = Table( - 'security_groups', - meta, - Column('id', String(length=36), primary_key=True, nullable=False), - Column('name', String(length=255)), - Column('description', String(length=255)), - Column('user', String(length=255)), - Column('tenant_id', String(length=255)), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('deleted', Boolean(), default=0), - Column('deleted_at', DateTime()), -) - -security_group_instance_associations = Table( - 'security_group_instance_associations', - meta, - Column('id', String(length=36), primary_key=True, nullable=False), - Column('security_group_id', String(length=36), - ForeignKey('security_groups.id', ondelete="CASCADE", - onupdate="CASCADE")), - Column('instance_id', String(length=36), - ForeignKey('instances.id', ondelete="CASCADE", - onupdate="CASCADE")), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('deleted', Boolean(), default=0), - Column('deleted_at', DateTime()), -) - -security_group_rules = Table( - 'security_group_rules', - meta, - Column('id', String(length=36), primary_key=True, nullable=False), - Column('group_id', String(length=36), - ForeignKey('security_groups.id', ondelete="CASCADE", - onupdate="CASCADE")), - Column('parent_group_id', String(length=36), - ForeignKey('security_groups.id', ondelete="CASCADE", - onupdate="CASCADE")), - Column('protocol', String(length=255)), - Column('from_port', Integer()), - Column('to_port', Integer()), - Column('cidr', String(length=255)), - Column('created', DateTime()), - Column('updated', DateTime()), - Column('deleted', Boolean(), default=0), - Column('deleted_at', DateTime()), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table( - 'instances', - meta, - autoload=True, - ) - create_tables([security_groups, security_group_rules, - security_group_instance_associations]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py b/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py deleted file mode 100644 index 23eb57493e..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - # pgsql <= 8.3 was lax about char->other casting but this was tightened up - # in 8.4+. We now have to specify the USING clause for the cast to succeed. - # NB: The generated sqlalchemy query doesn't support this, so this override - # is needed. - if migrate_engine.name == 'postgresql': - migrate_engine.execute('ALTER TABLE instances ALTER COLUMN flavor_id ' - 'TYPE INTEGER USING flavor_id::integer') - else: - instances = Table('instances', meta, autoload=True) - # modify column - instances.c.flavor_id.alter(type=Integer()) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/015_add_service_type.py b/trove/db/sqlalchemy/migrate_repo/versions/015_add_service_type.py deleted file mode 100644 index a5b41fe4e3..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/015_add_service_type.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - service_type = Column('service_type', String(36)) - instances.create_column(service_type) - instances.update().values({'service_type': 'mysql'}).execute() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py b/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py deleted file mode 100644 index 9bfd834c63..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -datastores = Table( - 'datastores', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('name', String(255), unique=True), - Column('manager', String(255), nullable=False), - Column('default_version_id', String(36)), -) - - -datastore_versions = Table( - 'datastore_versions', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('datastore_id', String(36), ForeignKey('datastores.id')), - Column('name', String(255), unique=True), - Column('image_id', String(36), nullable=False), - Column('packages', String(511)), - Column('active', Boolean(), nullable=False), - UniqueConstraint('datastore_id', 'name', name='ds_versions') -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([datastores, datastore_versions]) - instances = Table('instances', meta, autoload=True) - datastore_version_id = Column('datastore_version_id', String(36), - ForeignKey('datastore_versions.id')) - instances.create_column(datastore_version_id) - instances.drop_column('service_type') - # Table 'service_images' is deprecated since this version. - # Leave it for few releases. - # drop_tables([service_images]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/017_update_datastores.py b/trove/db/sqlalchemy/migrate_repo/versions/017_update_datastores.py deleted file mode 100644 index 68383260ef..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/017_update_datastores.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.sql.expression import select - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def migrate_datastore_manager(datastores, datastore_versions): - versions = select([datastore_versions]).execute() - for ds_v in versions: - ds = select([datastores]).\ - where(datastores.c.id == ds_v.datastore_id).\ - execute().fetchone() - datastore_versions.update().\ - where(datastore_versions.c.id == ds_v.id).\ - values(manager=ds.manager).\ - execute() - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - datastores = Table('datastores', meta, autoload=True) - datastore_versions = Table('datastore_versions', meta, autoload=True) - - # add column to datastore_versions - manager = Column('manager', String(255)) - datastore_versions.create_column(manager) - migrate_datastore_manager(datastores, datastore_versions) - - # drop column from datastores - datastores.drop_column('manager') diff --git a/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py deleted file mode 100644 index 5d05db9401..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - datastore_versions = Table('datastore_versions', meta, autoload=True) - # modify column - datastore_versions.c.name.alter(unique=False) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py deleted file mode 100644 index e59e4e129e..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py +++ /dev/null @@ -1,131 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import MetaData -from sqlalchemy.sql.expression import insert -from sqlalchemy.sql.expression import select -from sqlalchemy.sql.expression import update -from sqlalchemy import text - -from trove.common import cfg -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy import utils as db_utils - -CONF = cfg.CONF -LEGACY_IMAGE_ID = "00000000-0000-0000-0000-000000000000" -LEGACY_DATASTORE_ID = "10000000-0000-0000-0000-000000000001" -LEGACY_VERSION_ID = "20000000-0000-0000-0000-000000000002" -meta = MetaData() - - -def create_legacy_version(datastores_table, - datastore_versions_table, - image_id): - insert( - table=datastores_table, - values=dict(id=LEGACY_DATASTORE_ID, name="Legacy MySQL") - ).execute() - - insert( - table=datastore_versions_table, - values=dict(id=LEGACY_VERSION_ID, - datastore_id=LEGACY_DATASTORE_ID, - name="Unknown Legacy Version", - image_id=image_id, - packages="", - active=False, - manager="mysql") - ).execute() - - return LEGACY_VERSION_ID - - -def find_image(service_name): - image_table = Table('service_images', meta, autoload=True) - image = select( - columns=[text("id"), text("image_id"), text("service_name")], - from_obj=image_table, - whereclause=text("service_name='%s'" % service_name), - limit=1 - ).execute().fetchone() - - if image: - return image.id - return LEGACY_IMAGE_ID - - -def has_instances_wo_datastore_version(instances_table): - instance = select( - columns=[text("id")], - from_obj=instances_table, - whereclause=text("datastore_version_id is NULL"), - limit=1 - ).execute().fetchone() - - return instance is not None - - -def find_all_instances_wo_datastore_version(instances_table): - instances = select( - columns=[text("id")], - from_obj=instances_table, - whereclause=text("datastore_version_id is NULL") - ).execute() - - return instances - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - - instance_table = Table('instances', meta, autoload=True) - datastore_versions_table = Table('datastore_versions', - meta, - autoload=True) - - if has_instances_wo_datastore_version(instance_table): - instances = find_all_instances_wo_datastore_version(instance_table) - image_id = find_image("mysql") - - datastores_table = Table('datastores', - meta, - autoload=True) - - version_id = create_legacy_version(datastores_table, - datastore_versions_table, - image_id) - for instance in instances: - update( - table=instance_table, - whereclause=text("id='%s'" % instance.id), - values=dict(datastore_version_id=version_id) - ).execute() - - constraint_names = db_utils.get_foreign_key_constraint_names( - engine=migrate_engine, - table='instances', - columns=[text('datastore_version_id')], - ref_table='datastore_versions', - ref_columns=[text('id')]) - db_utils.drop_foreign_key_constraints( - constraint_names=constraint_names, - columns=[instance_table.c.datastore_version_id], - ref_columns=[datastore_versions_table.c.id]) - - instance_table.c.datastore_version_id.alter(nullable=False) - - db_utils.create_foreign_key_constraints( - constraint_names=constraint_names, - columns=[instance_table.c.datastore_version_id], - ref_columns=[datastore_versions_table.c.id]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py b/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py deleted file mode 100644 index 3b4fc1f26b..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2014 Rackspace -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -configurations = Table( - 'configurations', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('name', String(64), nullable=False), - Column('description', String(256)), - Column('tenant_id', String(36), nullable=False), - Column('datastore_version_id', String(36), nullable=False), - Column('deleted', Boolean(), nullable=False, default=False), - Column('deleted_at', DateTime()), -) - -configuration_parameters = Table( - 'configuration_parameters', - meta, - Column('configuration_id', String(36), ForeignKey("configurations.id"), - nullable=False, primary_key=True), - Column('configuration_key', String(128), nullable=False, primary_key=True), - Column('configuration_value', String(128)), - Column('deleted', Boolean(), nullable=False, default=False), - Column('deleted_at', DateTime()), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([configurations]) - create_tables([configuration_parameters]) - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('configuration_id', String(36), - ForeignKey("configurations.id"))) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py b/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py deleted file mode 100644 index 7bf683af5d..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import Float -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - -meta = MetaData() - -conductor_lastseen = Table( - 'conductor_lastseen', - meta, - Column('instance_id', String(36), primary_key=True, nullable=False), - Column('method_name', String(36), primary_key=True, nullable=False), - Column('sent', Float(precision=32))) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([conductor_lastseen]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/022_add_backup_parent_id.py b/trove/db/sqlalchemy/migrate_repo/versions/022_add_backup_parent_id.py deleted file mode 100644 index 62c2fdd8b2..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/022_add_backup_parent_id.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2013 OpenStack Foundation -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # add column: - backups = Table('backups', meta, autoload=True) - backups.create_column(Column('parent_id', String(36), nullable=True)) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py deleted file mode 100644 index 6a53eade02..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# 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 oslo_log import log as logging -from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import Index -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - instances = Table('instances', meta, autoload=True) - - tenant_id_idx = Index("instances_tenant_id", instances.c.tenant_id) - - try: - tenant_id_idx.create() - except OperationalError as e: - logger.info(e) - - deleted_idx = Index("instances_deleted", instances.c.deleted) - try: - deleted_idx.create() - except OperationalError as e: - logger.info(e) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py deleted file mode 100644 index d4472a2014..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# 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 oslo_log import log as logging -from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import Index -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - backups = Table('backups', meta, autoload=True) - backups_instance_id_idx = Index("backups_instance_id", - backups.c.instance_id) - backups_deleted_idx = Index("backups_deleted", backups.c.deleted) - - try: - backups_instance_id_idx.create() - except OperationalError as e: - logger.info(e) - - try: - backups_deleted_idx.create() - except OperationalError as e: - logger.info(e) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py deleted file mode 100644 index 2f4d3e6e86..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# 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 oslo_log import log as logging -from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import Index -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - service_statuses = Table('service_statuses', meta, autoload=True) - idx = Index("service_statuses_instance_id", service_statuses.c.instance_id) - - try: - idx.create() - except OperationalError as e: - logger.info(e) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py deleted file mode 100644 index f37337b18f..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/026_datastore_versions_unique_fix.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# 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.changeset import UniqueConstraint -from oslo_log import log as logging -from sqlalchemy.exc import InternalError -from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - datastore_versions = Table('datastore_versions', meta, autoload=True) - - # drop the unique index on the name column - unless we are - # using sqlite - it doesn't support dropping unique constraints - uc = None - if migrate_engine.name == "mysql": - uc = UniqueConstraint('name', table=datastore_versions, name='name') - elif migrate_engine.name == "postgresql": - uc = UniqueConstraint('name', table=datastore_versions, - name='datastore_versions_name_key') - if uc: - try: - uc.drop() - except (OperationalError, InternalError) as e: - logger.info(e) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py b/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py deleted file mode 100644 index 1daae101b0..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2014 Rackspace Hosting -# -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -capabilities = Table( - 'capabilities', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('name', String(255), unique=True), - Column('description', String(255), nullable=False), - Column('enabled', Boolean()) -) - - -capability_overrides = Table( - 'capability_overrides', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('datastore_version_id', String(36), - ForeignKey('datastore_versions.id')), - Column('capability_id', String(36), ForeignKey('capabilities.id')), - Column('enabled', Boolean()), - UniqueConstraint('datastore_version_id', 'capability_id', - name='idx_datastore_capabilities_enabled') -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table('datastores', meta, autoload=True) - Table('datastore_versions', meta, autoload=True) - create_tables([capabilities, capability_overrides]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/028_recreate_agent_heartbeat.py b/trove/db/sqlalchemy/migrate_repo/versions/028_recreate_agent_heartbeat.py deleted file mode 100644 index 2c4ea6d4fb..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/028_recreate_agent_heartbeat.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# 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 oslo_log import log as logging -from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # new table with desired columns, indexes, and constraints - new_agent_heartbeats = Table( - 'agent_heartbeats', meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('instance_id', String(36), - nullable=False, unique=True, index=True), - Column('guest_agent_version', String(255), index=True), - Column('deleted', Boolean(), index=True), - Column('deleted_at', DateTime()), - Column('updated_at', DateTime(), nullable=False)) - - # original table from migration 005_heartbeat.py - previous_agent_heartbeats = Table('agent_heartbeats', meta, autoload=True) - - try: - drop_tables([previous_agent_heartbeats]) - except OperationalError as e: - logger.warn("This table may have been dropped by some other means.") - logger.warn(e) - - create_tables([new_agent_heartbeats]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/029_add_backup_datastore.py b/trove/db/sqlalchemy/migrate_repo/versions/029_add_backup_datastore.py deleted file mode 100644 index c1156ba5c2..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/029_add_backup_datastore.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2013 OpenStack Foundation -# -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - backups = Table('backups', meta, autoload=True) - Table('datastore_versions', meta, autoload=True) - datastore_version_id = Column('datastore_version_id', String(36), - ForeignKey('datastore_versions.id')) - backups.create_column(datastore_version_id) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py b/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py deleted file mode 100644 index 6db24cd665..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright Tesora, Inc. 2014 -# -# 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.schema import Column -from sqlalchemy.schema import ForeignKey -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -COLUMN_NAME = 'slave_of_id' - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - instances.create_column( - Column(COLUMN_NAME, String(36), ForeignKey('instances.id')), - nullable=True) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py b/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py deleted file mode 100644 index 6f90ccf888..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2014 Rackspace Hosting -# -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData(bind=migrate_engine) - configurations = Table('configurations', meta, autoload=True) - created = Column('created', DateTime()) - updated = Column('updated', DateTime()) - configurations.create_column(created) - configurations.create_column(updated) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py b/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py deleted file mode 100644 index bfbc91f403..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2014 eBay Software Foundation -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import Index -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - -clusters = Table( - 'clusters', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('created', DateTime(), nullable=False), - Column('updated', DateTime(), nullable=False), - Column('name', String(255), nullable=False), - Column('task_id', Integer(), nullable=False), - Column('tenant_id', String(36), nullable=False), - Column("datastore_version_id", String(36), - ForeignKey('datastore_versions.id'), nullable=False), - Column('deleted', Boolean()), - Column('deleted_at', DateTime()), - Index("clusters_tenant_id", "tenant_id"), - Index("clusters_deleted", "deleted"),) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table('datastores', meta, autoload=True) - Table('datastore_versions', meta, autoload=True) - instances = Table('instances', meta, autoload=True) - create_tables([clusters]) - instances.create_column(Column('cluster_id', String(36), - ForeignKey("clusters.id"))) - instances.create_column(Column('shard_id', String(36))) - instances.create_column(Column('type', String(64))) - cluster_id_idx = Index("instances_cluster_id", instances.c.cluster_id) - cluster_id_idx.create() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py b/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py deleted file mode 100644 index bee56629a2..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2014 Rackspace -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -datastore_configuration_parameters = Table( - 'datastore_configuration_parameters', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('name', String(128), primary_key=True, nullable=False), - Column('datastore_version_id', String(36), - ForeignKey("datastore_versions.id"), - primary_key=True, nullable=False), - Column('restart_required', Boolean(), nullable=False, default=False), - Column('max_size', String(40)), - Column('min_size', String(40)), - Column('data_type', String(128), nullable=False), - Column('deleted', Boolean()), - Column('deleted_at', DateTime()), - UniqueConstraint( - 'datastore_version_id', 'name', - name='UQ_datastore_configuration_parameters_datastore_version_id_name') -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table('datastore_versions', meta, autoload=True) - create_tables([datastore_configuration_parameters]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/034_change_task_description.py b/trove/db/sqlalchemy/migrate_repo/versions/034_change_task_description.py deleted file mode 100644 index 7fc4b18180..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/034_change_task_description.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2014 AWCloud -# -# 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.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - instances.c.task_description.alter(type=String(255)) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/035_flavor_id_int_to_string.py b/trove/db/sqlalchemy/migrate_repo/versions/035_flavor_id_int_to_string.py deleted file mode 100644 index 3c46190586..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/035_flavor_id_int_to_string.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# 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.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - instances.c.flavor_id.alter(String(255)) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/036_add_datastore_version_metadata.py b/trove/db/sqlalchemy/migrate_repo/versions/036_add_datastore_version_metadata.py deleted file mode 100644 index e98674a2eb..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/036_add_datastore_version_metadata.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2015 Rackspace -# 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - -meta = MetaData() - -datastore_version_metadata = Table( - 'datastore_version_metadata', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column( - 'datastore_version_id', - String(36), - ForeignKey('datastore_versions.id', ondelete='CASCADE'), - ), - Column('key', String(128), nullable=False), - Column('value', String(128)), - Column('created', DateTime(), nullable=False), - Column('deleted', Boolean(), nullable=False, default=False), - Column('deleted_at', DateTime()), - Column('updated_at', DateTime()), - UniqueConstraint( - 'datastore_version_id', 'key', 'value', - name='UQ_datastore_version_metadata_datastore_version_id_key_value') -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - # Load the datastore_versions table into the session. - # creates datastore_version_metadata table - Table('datastore_versions', meta, autoload=True) - create_tables([datastore_version_metadata]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py b/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py deleted file mode 100644 index ad264bf43f..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2016 Tesora, 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Text - - -meta = MetaData() - -modules = Table( - 'modules', - meta, - Column('id', String(length=64), primary_key=True, nullable=False), - Column('name', String(length=255), nullable=False), - Column('type', String(length=255), nullable=False), - Column('contents', Text(length=16777215), nullable=False), - Column('description', String(length=255)), - Column('tenant_id', String(length=64), nullable=True), - Column('datastore_id', String(length=64), nullable=True), - Column('datastore_version_id', String(length=64), nullable=True), - Column('auto_apply', Boolean(), default=0, nullable=False), - Column('visible', Boolean(), default=1, nullable=False), - Column('live_update', Boolean(), default=0, nullable=False), - Column('md5', String(length=32), nullable=False), - Column('created', DateTime(), nullable=False), - Column('updated', DateTime(), nullable=False), - Column('deleted', Boolean(), default=0, nullable=False), - Column('deleted_at', DateTime()), - UniqueConstraint( - 'type', 'tenant_id', 'datastore_id', 'datastore_version_id', - 'name', 'deleted_at', - name='UQ_type_tenant_datastore_datastore_version_name'), -) - -instance_modules = Table( - 'instance_modules', - meta, - Column('id', String(length=64), primary_key=True, nullable=False), - Column('instance_id', String(length=64), - ForeignKey('instances.id', ondelete="CASCADE", - onupdate="CASCADE"), nullable=False), - Column('module_id', String(length=64), - ForeignKey('modules.id', ondelete="CASCADE", - onupdate="CASCADE"), nullable=False), - Column('md5', String(length=32), nullable=False), - Column('created', DateTime(), nullable=False), - Column('updated', DateTime(), nullable=False), - Column('deleted', Boolean(), default=0, nullable=False), - Column('deleted_at', DateTime()), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table('instances', meta, autoload=True) - create_tables([modules, instance_modules]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py b/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py deleted file mode 100644 index fe3411431b..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2016 Tesora, 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 ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Text - - -meta = MetaData() - -instance_faults = Table( - 'instance_faults', - meta, - Column('id', String(length=64), primary_key=True, nullable=False), - Column('instance_id', String(length=64), - ForeignKey('instances.id', ondelete="CASCADE", - onupdate="CASCADE"), nullable=False), - Column('message', String(length=255), nullable=False), - Column('details', Text(length=65535), nullable=False), - Column('created', DateTime(), nullable=False), - Column('updated', DateTime(), nullable=False), - Column('deleted', Boolean(), default=0, nullable=False), - Column('deleted_at', DateTime()), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - Table('instances', meta, autoload=True) - create_tables([instance_faults]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/039_region.py b/trove/db/sqlalchemy/migrate_repo/versions/039_region.py deleted file mode 100644 index fa0668f0cf..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/039_region.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2016 Tesora 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 oslo_log import log as logging -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.common import cfg -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -CONF = cfg.CONF -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - -meta = MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('region_id', String(255))) - instances.update().values( - region_id=CONF.service_credentials.region_name).execute() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/040_module_priority.py b/trove/db/sqlalchemy/migrate_repo/versions/040_module_priority.py deleted file mode 100644 index 49876c807f..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/040_module_priority.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2016 Tesora, 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.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.sql.expression import update -from sqlalchemy import text - -from trove.db.sqlalchemy.migrate_repo.schema import Boolean -from trove.db.sqlalchemy.migrate_repo.schema import Integer -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Text - - -COLUMN_NAME_1 = 'priority_apply' -COLUMN_NAME_2 = 'apply_order' -COLUMN_NAME_3 = 'is_admin' - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - modules = Table('modules', meta, autoload=True) - is_nullable = True if migrate_engine.name == "sqlite" else False - column = Column(COLUMN_NAME_1, Boolean(), nullable=is_nullable, default=0) - modules.create_column(column) - column = Column(COLUMN_NAME_2, Integer(), nullable=is_nullable, default=5) - modules.create_column(column) - column = Column(COLUMN_NAME_3, Boolean(), nullable=is_nullable, default=0) - modules.create_column(column) - modules.c.contents.alter(Text(length=4294967295)) - # mark all non-visible, auto-apply and all-tenant modules as is_admin - update(table=modules, - values=dict(is_admin=1), - whereclause=text("visible=0 or auto_apply=1 or tenant_id is null") - ).execute() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/041_instance_keys.py b/trove/db/sqlalchemy/migrate_repo/versions/041_instance_keys.py deleted file mode 100644 index 7477cfaf71..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/041_instance_keys.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2016 Tesora, 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -meta = MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('encrypted_key', String(255))) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py b/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py deleted file mode 100644 index 9d4c199fd6..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2016 Tesora, 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 oslo_log import log as logging -from sqlalchemy import ForeignKey -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData - -from trove.common import cfg -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -CONF = cfg.CONF -logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') - -meta = MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - # Load 'configurations' table to MetaData. - Table('configurations', meta, autoload=True, autoload_with=migrate_engine) - instances = Table('clusters', meta, autoload=True) - instances.create_column(Column('configuration_id', String(36), - ForeignKey("configurations.id"))) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/043_instance_ds_version_nullable.py b/trove/db/sqlalchemy/migrate_repo/versions/043_instance_ds_version_nullable.py deleted file mode 100644 index 66e898807d..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/043_instance_ds_version_nullable.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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.schema import MetaData -from sqlalchemy import text - -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy import utils as db_utils - -meta = MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - - instance_table = Table('instances', meta, autoload=True) - datastore_versions_table = Table('datastore_versions', - meta, - autoload=True) - - constraint_names = db_utils.get_foreign_key_constraint_names( - engine=migrate_engine, - table='instances', - columns=[text('datastore_version_id')], - ref_table='datastore_versions', - ref_columns=[text('id')]) - db_utils.drop_foreign_key_constraints( - constraint_names=constraint_names, - columns=[instance_table.c.datastore_version_id], - ref_columns=[datastore_versions_table.c.id]) - - # Make datastore_version_id nullable so that this field could be set to - # NULL when instance is deleted. - instance_table.c.datastore_version_id.alter(nullable=True) - - db_utils.create_foreign_key_constraints( - constraint_names=constraint_names, - columns=[instance_table.c.datastore_version_id], - ref_columns=[datastore_versions_table.c.id]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/044_remove_datastore_configuration_parameters_deleted.py b/trove/db/sqlalchemy/migrate_repo/versions/044_remove_datastore_configuration_parameters_deleted.py deleted file mode 100644 index 7b34b00035..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/044_remove_datastore_configuration_parameters_deleted.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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 -from sqlalchemy import schema - -from trove.db.sqlalchemy.migrate_repo import schema as trove_schema - -meta = schema.MetaData() - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - - ds_config_param = trove_schema.Table('datastore_configuration_parameters', - meta, - autoload=True) - - # Remove records with deleted=1 - if 'deleted' in ds_config_param.c: - ds_config_param.delete(). \ - where(ds_config_param.c.deleted == 1). \ - execute() - - # Delete columns deleted and deleted_at - if migrate_engine.name != "sqlite": - ds_config_param.drop_column('deleted') - ds_config_param.drop_column('deleted_at') - else: - # It is not possible to remove a column from a table in SQLite. - # SQLite is just for testing, so we re-create the table. - ds_config_param.drop() - meta.clear() - trove_schema.Table('datastore_versions', meta, autoload=True) - new_table = trove_schema.Table( - 'datastore_configuration_parameters', - meta, - schema.Column('id', trove_schema.String(36), - primary_key=True, nullable=False), - schema.Column('name', trove_schema.String(128), - primary_key=True, nullable=False), - schema.Column('datastore_version_id', trove_schema.String(36), - sqlalchemy.ForeignKey("datastore_versions.id"), - primary_key=True, nullable=False), - schema.Column('restart_required', trove_schema.Boolean(), - nullable=False, default=False), - schema.Column('max_size', trove_schema.String(40)), - schema.Column('min_size', trove_schema.String(40)), - schema.Column('data_type', trove_schema.String(128), - nullable=False), - schema.UniqueConstraint( - 'datastore_version_id', 'name', - name=('UQ_datastore_configuration_parameters_datastore_' - 'version_id_name') - ) - ) - trove_schema.create_tables([new_table]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/045_add_backup_strategy.py b/trove/db/sqlalchemy/migrate_repo/versions/045_add_backup_strategy.py deleted file mode 100644 index 5b5deaea4a..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/045_add_backup_strategy.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2020 Catalyst Cloud -# 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.schema import Column -from sqlalchemy.schema import Index -from sqlalchemy.schema import MetaData -from sqlalchemy.schema import UniqueConstraint - -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - -meta = MetaData() - -backup_strategy = Table( - 'backup_strategy', - meta, - Column('id', String(36), primary_key=True, nullable=False), - Column('tenant_id', String(36), nullable=False), - Column('instance_id', String(36), nullable=False, default=''), - Column('backend', String(255), nullable=False), - Column('swift_container', String(255), nullable=True), - Column('created', DateTime()), - UniqueConstraint( - 'tenant_id', 'instance_id', - name='UQ_backup_strategy_tenant_id_instance_id'), - Index("backup_strategy_tenant_id_instance_id", "tenant_id", "instance_id"), -) - - -def upgrade(migrate_engine): - meta.bind = migrate_engine - create_tables([backup_strategy]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/046_add_access_to_instance.py b/trove/db/sqlalchemy/migrate_repo/versions/046_add_access_to_instance.py deleted file mode 100644 index faf45d1770..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/046_add_access_to_instance.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2020 Catalyst Cloud -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Text - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - instances = Table('instances', meta, autoload=True) - instances.create_column(Column('access', Text(), nullable=True)) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/047_image_tag_in_datastore_version.py b/trove/db/sqlalchemy/migrate_repo/versions/047_image_tag_in_datastore_version.py deleted file mode 100644 index 6d5c6c215f..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/047_image_tag_in_datastore_version.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2020 Catalyst Cloud -# 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.schema import Column -from sqlalchemy.schema import MetaData - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - ds_version = Table('datastore_versions', meta, autoload=True) - ds_version.create_column(Column('image_tags', String(255), nullable=True)) - ds_version.c.image_id.alter(nullable=True) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/048_add_version_to_datastore_version.py b/trove/db/sqlalchemy/migrate_repo/versions/048_add_version_to_datastore_version.py deleted file mode 100644 index 3346a0dd6a..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/048_add_version_to_datastore_version.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2020 Catalyst Cloud -# 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.changeset.constraint import UniqueConstraint -from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.sql.expression import select -from sqlalchemy.sql.expression import update -from sqlalchemy import text - -from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy import utils as db_utils - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - ds_table = Table('datastores', meta, autoload=True) - ds_version_table = Table('datastore_versions', meta, autoload=True) - ds_version_table.create_column( - Column('version', String(255), nullable=True)) - - ds_versions = select( - columns=[text("id"), text("name")], - from_obj=ds_version_table - ).execute() - - # Use 'name' value as init 'version' value - for version in ds_versions: - update( - table=ds_version_table, - whereclause=text("id='%s'" % version.id), - values=dict(version=version.name) - ).execute() - - # Change unique constraint, need to drop the foreign key first and add back - # later - constraint_names = db_utils.get_foreign_key_constraint_names( - engine=migrate_engine, - table='datastore_versions', - columns=['datastore_id'], - ref_table='datastores', - ref_columns=['id']) - db_utils.drop_foreign_key_constraints( - constraint_names=constraint_names, - columns=[ds_version_table.c.datastore_id], - ref_columns=[ds_table.c.id]) - - UniqueConstraint('datastore_id', 'name', name='ds_versions', - table=ds_version_table).drop() - UniqueConstraint('datastore_id', 'name', 'version', name='ds_versions', - table=ds_version_table).create() - - db_utils.create_foreign_key_constraints( - constraint_names=constraint_names, - columns=[ds_version_table.c.datastore_id], - ref_columns=[ds_table.c.id]) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/049_add_registry_ext_to_datastore_version.py b/trove/db/sqlalchemy/migrate_repo/versions/049_add_registry_ext_to_datastore_version.py deleted file mode 100644 index 977f3e631b..0000000000 --- a/trove/db/sqlalchemy/migrate_repo/versions/049_add_registry_ext_to_datastore_version.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2023 Bizfly Cloud -# 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.schema import Column -from sqlalchemy.schema import MetaData -from sqlalchemy.sql.expression import select -from sqlalchemy.sql.expression import update -from sqlalchemy import text - -from trove.common.constants import REGISTRY_EXT_DEFAULTS -from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Text - - -repl_namespaces = { - "mariadb": "trove.guestagent.strategies.replication.mariadb_gtid", - "mongodb": - "trove.guestagent.strategies.replication.experimental.mongo_impl", - "mysql": "trove.guestagent.strategies.replication.mysql_gtid", - "percona": "trove.guestagent.strategies.replication.mysql_gtid", - "postgresql": "trove.guestagent.strategies.replication.postgresql", - "pxc": "trove.guestagent.strategies.replication.mysql_gtid", - "redis": "trove.guestagent.strategies.replication.experimental.redis_sync", - -} - -repl_strategies = { - "mariadb": "MariaDBGTIDReplication", - "mongodb": "Replication", - "mysql": "MysqlGTIDReplication", - "percona": "MysqlGTIDReplication", - "postgresql": "PostgresqlReplicationStreaming", - "pxc": "MysqlGTIDReplication", - "redis": "RedisSyncReplication", - -} - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - ds_version = Table('datastore_versions', meta, autoload=True) - ds_version.create_column(Column('registry_ext', Text(), nullable=True)) - ds_version.create_column(Column('repl_strategy', Text(), nullable=True)) - - ds_versions = select( - columns=[text("id"), text("manager")], - from_obj=ds_version - ).execute() - # Use 'name' value as init 'version' value - for version in ds_versions: - registry_ext = REGISTRY_EXT_DEFAULTS.get(version.manager, '') - repl_strategy = "%(repl_namespace)s.%(repl_strategy)s" % { - 'repl_namespace': repl_namespaces.get(version.manager, ''), - 'repl_strategy': repl_strategies.get(version.manager, '') - } - update( - table=ds_version, - whereclause=text("id='%s'" % version.id), - values=dict( - registry_ext=registry_ext, - repl_strategy=repl_strategy) - ).execute() - - ds_version.c.registry_ext.alter(nullable=False) - ds_version.c.repl_strategy.alter(nullable=False) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/__init__.py b/trove/db/sqlalchemy/migrate_repo/versions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000