Remove outdated migration script
Change-Id: I6365b37b7b31dbc7337aa4903e4ad4cf27df9faf
This commit is contained in:
parent
b1c74bf6bf
commit
0759d68135
@ -1,4 +0,0 @@
|
||||
This is a database migration repository.
|
||||
|
||||
More information at
|
||||
http://code.google.com/p/sqlalchemy-migrate/
|
@ -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='.')
|
@ -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']
|
@ -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)
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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)
|
@ -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)))
|
@ -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()))
|
@ -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])
|
@ -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])
|
@ -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, ])
|
@ -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])
|
@ -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())
|
@ -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()
|
@ -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])
|
@ -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')
|
@ -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)
|
@ -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])
|
@ -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")))
|
@ -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])
|
@ -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))
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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])
|
@ -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])
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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()
|
@ -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])
|
@ -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))
|
@ -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))
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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()
|
@ -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()
|
@ -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)))
|
@ -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")))
|
@ -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])
|
@ -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])
|
@ -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])
|
@ -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))
|
@ -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)
|
@ -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])
|
@ -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)
|
Loading…
Reference in New Issue
Block a user