Пример #1
0
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 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])
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()))
Пример #4
0
#    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 drop_tables
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])
Пример #5
0
from trove.db.sqlalchemy.migrate_repo.schema import Table
from trove.db.sqlalchemy import utils as db_utils


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):
Пример #6
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])
Пример #7
0
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",
                   onupdate="CASCADE")),
    Column('instance_id', String(length=36),
Пример #8
0
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,
Пример #9
0
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 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])
Пример #10
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()

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
Пример #11
0
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),
Пример #12
0
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 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()

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(
Пример #13
0
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):
    meta.bind = migrate_engine
    drop_tables([backups, ])
Пример #14
0
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])


def downgrade(migrate_engine):
    meta.bind = migrate_engine