def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    modules = Table('modules', meta, autoload=True)
    modules.drop_column(COLUMN_NAME_1)
    modules.drop_column(COLUMN_NAME_2)
    modules.drop_column(COLUMN_NAME_3)
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")))
示例#3
0
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)
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()
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))
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)
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # drop column:
    backups = Table('backups', meta, autoload=True)
    backups.drop_column('parent_id')
示例#8
0
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")))
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()))
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # drop column:
    instances = Table('instances', meta, autoload=True)
    instances.drop_column('deleted')
    instances.drop_column('deleted_at')
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)
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)))
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')
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # drop column:
    instances = Table('instances', meta, autoload=True)

    instances.drop_column('flavor_id')
    instances.drop_column('volume_size')
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # drop column:
    backups = Table('backups', meta, autoload=True)
    migrate_engine.execute('DROP INDEX backups_parent_id_idx ON backups')
    migrate_engine.execute('DROP INDEX backups_deleted_idx ON backups')
    backups.drop_column('parent_id')
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # drop column:
    instances = Table('instances', meta, autoload=True)

    instances.drop_column('tenant_id')
    instances.drop_column('server_status')
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    instance_vip = Table('instance_vip', meta, autoload=True)
    instance_vip.create_column(Column('virtual_instance_id', String(36)))
    
    def update_instance_vips():
        update(table = instance_vip, whereclause="deleted = 0", 
               values=dict(virtual_instance_id = instance_vip.c.instance_id)).execute()
    
    update_instance_vips()
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)
示例#19
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    instances = Table("instances", meta, autoload=True)
    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine, table="instances", columns=[COLUMN_NAME], ref_table="instances", ref_columns=["id"]
    )
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names, columns=[instances.c.slave_of_id], ref_columns=[instances.c.id]
    )
    instances.drop_column(COLUMN_NAME)
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    create_tables([datastores, datastore_versions])
    
#     ----------------------------------------------------
#     Fore. 2014/06/19 Not modify old schemas on Instance.
#     ----------------------------------------------------
    instances = Table('instances', meta, autoload=True)
#     datastore_version_id = Column('datastore_version_id', String(36),
#                                   ForeignKey('datastore_versions.id'))
    datastore_version_id = Column('datastore_version_id', String(36), nullable = True)
    instances.create_column(datastore_version_id)
示例#21
0
def upgrade(migrate_engine):
    meta.bind = migrate_engine

    # since the downgrade is a no-op, an upgrade after a downgrade will
    # cause an exception because the tables already exist
    # we will catch that case and log an info message
    try:
        create_tables([configurations])
        create_tables([configuration_parameters])

        instances = Table('instances', meta, autoload=True)
        instances.create_column(Column('configuration_id', String(36),
                                       ForeignKey("configurations.id")))
    except OperationalError as e:
        logger.info(e)
示例#22
0
def downgrade(migrate_engine):
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine,
        table='instances',
        columns=['configuration_id'],
        ref_table='configurations',
        ref_columns=['id'])
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names,
        columns=[instances.c.configuration_id],
        ref_columns=[configurations.c.id])
    instances.drop_column('configuration_id')
    drop_tables([configuration_parameters, configurations])
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # add column:
    backups = Table('backups', meta, autoload=True)
    try:
        parent_id = backups.c.parent_id
    except AttributeError as e:
        backups.create_column(Column('parent_id', String(36), nullable=True))
        pass


    migrate_engine.execute('ALTER TABLE backups ADD INDEX backups_parent_id_idx (parent_id)')
    migrate_engine.execute('ALTER TABLE backups ADD INDEX backups_deleted_idx (deleted)')
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    backups = Table('backups', meta, autoload=True)
    datastore_versions = Table('datastore_versions', meta, autoload=True)
    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine,
        table='backups',
        columns=['datastore_version_id'],
        ref_table='datastore_versions',
        ref_columns=['id'])
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names,
        columns=[backups.c.datastore_version_id],
        ref_columns=[datastore_versions.c.id])
    backups.drop_column('datastore_version_id')
示例#25
0
def downgrade(migrate_engine):
    meta.bind = migrate_engine

    datastore_versions = Table('datastore_versions', meta, autoload=True)
    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine,
        table='clusters',
        columns=['datastore_version_id'],
        ref_table='datastore_versions',
        ref_columns=['id'])
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names,
        columns=[clusters.c.datastore_version_id],
        ref_columns=[datastore_versions.c.id])

    instances = Table('instances', meta, autoload=True)
    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine,
        table='instances',
        columns=['cluster_id'],
        ref_table='clusters',
        ref_columns=['id'])
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names,
        columns=[instances.c.cluster_id],
        ref_columns=[clusters.c.id])

    instances.drop_column('cluster_id')
    instances.drop_column('shard_id')
    instances.drop_column('type')

    drop_tables([clusters])
def downgrade(migrate_engine):
    meta.bind = migrate_engine
    clusters = Table('clusters', meta, autoload=True)
    configurations = Table('configurations', meta, autoload=True,
                           autoload_with=migrate_engine)

    constraint_names = db_utils.get_foreign_key_constraint_names(
        engine=migrate_engine,
        table='clusters',
        columns=['configuration_id'],
        ref_table='configurations',
        ref_columns=['id'])
    db_utils.drop_foreign_key_constraints(
        constraint_names=constraint_names,
        columns=[clusters.c.configuration_id],
        ref_columns=[configurations.c.id])

    clusters.drop_column('configuration_id')
示例#27
0
def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([datastores, datastore_versions])
    instances = Table('instances', meta, autoload=True)
    instances.drop_column('datastore_version_id')
    service_type = Column('service_type', String(36))
    instances.create_column(service_type)
    instances.update().values({'service_type': 'mysql'}).execute()
示例#28
0
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()
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    datastores = Table('datastores', meta, autoload=True)
    datastore_versions = Table('datastore_versions', meta, autoload=True)

    # drop column from datastore_versions
    datastore_versions.drop_column('manager')

    # add column to datastores
    manager = Column('manager', String(255))
    datastores.create_column(manager)
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="visible=0 or auto_apply=1 or tenant_id is null"
           ).execute()
示例#31
0
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 drop_tables
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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([instances])
示例#32
0
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
from trove.db.sqlalchemy import utils as db_utils

logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema')

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),
def downgrade(migrate_engine):
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    instances.c.flavor_id.alter(Integer())
示例#34
0
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])
示例#35
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])
示例#36
0
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])
示例#37
0
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.os_region_name).execute()
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    instances.c.flavor_id.alter(String(255))
示例#39
0
from trove.db.sqlalchemy.migrate_repo.schema import Table
from trove.openstack.common import log as logging

logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema')

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)
示例#40
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    # modify column:
    instances = Table('instances', meta, autoload=True)
    instances.drop_column('service_type')
示例#41
0
#    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 drop_tables
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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([root_enabled_history])
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 drop_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')
示例#43
0
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 drop_tables
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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([usage_events])
示例#44
0
from trove.db.sqlalchemy.migrate_repo.schema import DateTime
from trove.db.sqlalchemy.migrate_repo.schema import Boolean
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])
示例#45
0
def downgrade(migrate_engine):
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    instances.drop_column('region_id')
示例#46
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 drop_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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([dns_records])
示例#47
0
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    Table('instances', meta, autoload=True)
    create_tables([instance_faults])
示例#48
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    instances.drop_column(COLUMN_NAME)
from trove.db.sqlalchemy.migrate_repo.schema import drop_tables
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 String
from trove.db.sqlalchemy.migrate_repo.schema import DateTime
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",
示例#50
0
#    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])
示例#51
0
from trove.db.sqlalchemy.migrate_repo.schema import drop_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
from trove.db.sqlalchemy.migrate_repo.schema import Boolean

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, ])


def downgrade(migrate_engine):
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 drop_tables
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

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'))
示例#53
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    # modify column:
    instances = Table('instances', meta, autoload=True)
    instances.c.flavor_id.alter(type=String(36))
示例#54
0
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    Table('datastore_versions', meta, autoload=True)
    create_tables([datastore_configuration_parameters])
示例#55
0
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    instances = Table('instances', meta, autoload=True)
    #modify column
    instances.c.flavor_id.alter(type=Integer())
示例#56
0
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 drop_tables
from trove.db.sqlalchemy.migrate_repo.schema import Integer
from trove.db.sqlalchemy.migrate_repo.schema import BigInteger
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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine
    drop_tables([agent_heartbeats])
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)
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    Table('datastores', meta, autoload=True)
    Table('datastore_versions', meta, autoload=True)
    create_tables([capabilities, capability_overrides])