Ejemplo n.º 1
0
def _add_metadef_namespace_resource_types_table():
    op.create_table('metadef_namespace_resource_types',
                    Column('resource_type_id', Integer(), nullable=False),
                    Column('namespace_id', Integer(), nullable=False),
                    Column('properties_target',
                           String(length=80),
                           nullable=True),
                    Column('prefix', String(length=80), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    ForeignKeyConstraint(
                        ['namespace_id'],
                        ['metadef_namespaces.id'],
                    ),
                    ForeignKeyConstraint(
                        ['resource_type_id'],
                        ['metadef_resource_types.id'],
                    ),
                    PrimaryKeyConstraint('resource_type_id', 'namespace_id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_metadef_ns_res_types_namespace_id',
                    'metadef_namespace_resource_types', ['namespace_id'],
                    unique=False)
Ejemplo n.º 2
0
def _add_artifact_properties_table():
    op.create_table('artifact_properties',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=False),
                    Column('string_value', String(length=255), nullable=True),
                    Column('int_value', Integer(), nullable=True),
                    Column('numeric_value', Numeric(), nullable=True),
                    Column('bool_value', Boolean(), nullable=True),
                    Column('text_value', Text(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    Column('position', Integer(), nullable=True),
                    ForeignKeyConstraint(
                        ['artifact_id'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_properties_artifact_id',
                    'artifact_properties', ['artifact_id'],
                    unique=False)
    op.create_index('ix_artifact_properties_name',
                    'artifact_properties', ['name'],
                    unique=False)
Ejemplo n.º 3
0
def define_image_properties_table(meta):
    (define_images_table, ) = from_migration_import('001_add_images_table',
                                                    ['define_images_table'])

    images = define_images_table(meta)

    image_properties = Table('image_properties',
                             meta,
                             Column('id',
                                    Integer(),
                                    primary_key=True,
                                    nullable=False),
                             Column('image_id',
                                    Integer(),
                                    ForeignKey('images.id'),
                                    nullable=False,
                                    index=True),
                             Column('key', String(255), nullable=False),
                             Column('value', Text()),
                             Column('created_at', DateTime(), nullable=False),
                             Column('updated_at', DateTime()),
                             Column('deleted_at', DateTime()),
                             Column('deleted',
                                    Boolean(),
                                    nullable=False,
                                    default=False,
                                    index=True),
                             UniqueConstraint('image_id', 'key'),
                             mysql_engine='InnoDB',
                             extend_existing=True)

    Index('ix_image_properties_image_id_key', image_properties.c.image_id,
          image_properties.c.key)

    return image_properties
def define_images_table(meta):
    images = Table('images',
                   meta,
                   Column('id', Integer(), primary_key=True, nullable=False),
                   Column('name', String(255)),
                   Column('type', String(30)),
                   Column('size', Integer()),
                   Column('status', String(30), nullable=False),
                   Column('is_public',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   Column('location', Text()),
                   Column('created_at', DateTime(), nullable=False),
                   Column('updated_at', DateTime()),
                   Column('deleted_at', DateTime()),
                   Column('deleted',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   mysql_engine='InnoDB',
                   extend_existing=True)

    return images
Ejemplo n.º 5
0
def _add_metadef_objects_table():
    ns_id_name_constraint = 'uq_metadef_objects_namespace_id_name'

    op.create_table('metadef_objects',
                    Column('id', Integer(), nullable=False),
                    Column('namespace_id', Integer(), nullable=False),
                    Column('name', String(length=80), nullable=False),
                    Column('description', Text(), nullable=True),
                    Column('required', Text(), nullable=True),
                    Column('json_schema', JSONEncodedDict(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    ForeignKeyConstraint(
                        ['namespace_id'],
                        ['metadef_namespaces.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    UniqueConstraint('namespace_id',
                                     'name',
                                     name=ns_id_name_constraint),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_metadef_objects_name',
                    'metadef_objects', ['name'],
                    unique=False)
Ejemplo n.º 6
0
def _add_images_table():
    op.create_table('images',
                    Column('id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=True),
                    Column('size', BigInteger(), nullable=True),
                    Column('status', String(length=30), nullable=False),
                    Column('is_public', Boolean(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    Column('deleted_at', DateTime(), nullable=True),
                    Column('deleted', Boolean(), nullable=False),
                    Column('disk_format', String(length=20), nullable=True),
                    Column('container_format',
                           String(length=20),
                           nullable=True),
                    Column('checksum', String(length=32), nullable=True),
                    Column('owner', String(length=255), nullable=True),
                    Column('min_disk', Integer(), nullable=False),
                    Column('min_ram', Integer(), nullable=False),
                    Column('protected',
                           Boolean(),
                           server_default=sql.false(),
                           nullable=False),
                    Column('virtual_size', BigInteger(), nullable=True),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('checksum_image_idx', 'images', ['checksum'], unique=False)
    op.create_index('ix_images_deleted', 'images', ['deleted'], unique=False)
    op.create_index('ix_images_is_public',
                    'images', ['is_public'],
                    unique=False)
    op.create_index('owner_image_idx', 'images', ['owner'], unique=False)
def define_metadef_namespace_resource_types_table(meta):

    _constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        _constr_kwargs['name'] = 'ix_metadef_ns_res_types_res_type_id_ns_id'

    metadef_associations = Table(
        'metadef_namespace_resource_types',
        meta,
        Column('resource_type_id',
               Integer(),
               ForeignKey('metadef_resource_types.id'),
               primary_key=True,
               nullable=False),
        Column('namespace_id',
               Integer(),
               ForeignKey('metadef_namespaces.id'),
               primary_key=True,
               nullable=False),
        Column('properties_target', String(80)),
        Column('prefix', String(80)),
        Column('created_at', DateTime(), nullable=False),
        Column('updated_at', DateTime()),
        UniqueConstraint('resource_type_id', 'namespace_id', **_constr_kwargs),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
        extend_existing=True)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_metadef_ns_res_types_res_type_id_ns_id',
              metadef_associations.c.resource_type_id,
              metadef_associations.c.namespace_id)

    return metadef_associations
Ejemplo n.º 8
0
def define_artifact_properties_table(meta):
    artifact_properties = Table('artifact_properties',
                                meta,
                                Column('id', String(36),
                                       primary_key=True,
                                       nullable=False),
                                Column('artifact_id', String(36),
                                       ForeignKey('artifacts.id'),
                                       nullable=False),
                                Column('name', String(255),
                                       nullable=False),
                                Column('string_value', String(255)),
                                Column('int_value', Integer()),
                                Column('numeric_value', Numeric()),
                                Column('bool_value', Boolean()),
                                Column('text_value', Text()),
                                Column('created_at', DateTime(),
                                       nullable=False),
                                Column('updated_at', DateTime(),
                                       nullable=False),
                                Column('position', Integer()),
                                mysql_engine='InnoDB',
                                extend_existing=True)
    Index('ix_artifact_properties_artifact_id',
          artifact_properties.c.artifact_id)
    Index('ix_artifact_properties_name', artifact_properties.c.name)
    return artifact_properties
def define_metadef_objects_table(meta):

    _constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        _constr_kwargs['name'] = 'ix_objects_namespace_id_name'

    objects = Table('metadef_objects',
                    meta,
                    Column('id', Integer(), primary_key=True, nullable=False),
                    Column('namespace_id',
                           Integer(),
                           ForeignKey('metadef_namespaces.id'),
                           nullable=False),
                    Column('name', String(80), nullable=False),
                    Column('description', Text()),
                    Column('required', Text()),
                    Column('schema', Text(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime()),
                    UniqueConstraint('namespace_id', 'name', **_constr_kwargs),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_objects_namespace_id_name', objects.c.namespace_id,
              objects.c.name)

    return objects
Ejemplo n.º 10
0
def get_images_table(meta):
    """
    Returns the Table object for the images table that
    corresponds to the images table definition of this version.
    """
    images = Table('images',
                   meta,
                   Column('id', Integer(), primary_key=True, nullable=False),
                   Column('name', String(255)),
                   Column('disk_format', String(20)),
                   Column('container_format', String(20)),
                   Column('size', Integer()),
                   Column('status', String(30), nullable=False),
                   Column('is_public',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   Column('location', Text()),
                   Column('created_at', DateTime(), nullable=False),
                   Column('updated_at', DateTime()),
                   Column('deleted_at', DateTime()),
                   Column('deleted',
                          Boolean(),
                          nullable=False,
                          default=False,
                          index=True),
                   Column('checksum', String(32)),
                   mysql_engine='InnoDB',
                   extend_existing=True)

    return images
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    images = get_images_table(meta)

    min_disk = Column('min_disk', Integer(), default=0)
    min_disk.create(images)

    min_ram = Column('min_ram', Integer(), default=0)
    min_ram.create(images)
Ejemplo n.º 12
0
def define_image_properties_table(meta):
    (define_images_table,) = from_migration_import(
        '001_add_images_table', ['define_images_table'])

    images = define_images_table(meta)  # noqa

    # NOTE(dperaza) DB2: specify the UniqueConstraint option when creating the
    # table will cause an index being created to specify the index
    # name and skip the step of creating another index with the same columns.
    # The index name is needed so it can be dropped and re-created later on.

    constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        constr_kwargs['name'] = 'ix_image_properties_image_id_key'

    image_properties = Table('image_properties',
                             meta,
                             Column('id',
                                    Integer(),
                                    primary_key=True,
                                    nullable=False),
                             Column('image_id',
                                    Integer(),
                                    ForeignKey('images.id'),
                                    nullable=False,
                                    index=True),
                             Column('key', String(255), nullable=False),
                             Column('value', Text()),
                             Column('created_at', DateTime(), nullable=False),
                             Column('updated_at', DateTime()),
                             Column('deleted_at', DateTime()),
                             Column('deleted',
                                    Boolean(),
                                    nullable=False,
                                    default=False,
                                    index=True),
                             UniqueConstraint('image_id', 'key',
                                              **constr_kwargs),
                             mysql_engine='InnoDB',
                             mysql_charset='utf8',
                             extend_existing=True)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_image_properties_image_id_key',
              image_properties.c.image_id,
              image_properties.c.key)

    return image_properties
Ejemplo n.º 13
0
def _add_image_locations_table():
    op.create_table('image_locations',
                    Column('id', Integer(), nullable=False),
                    Column('image_id', String(length=36), nullable=False),
                    Column('value', Text(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    Column('deleted_at', DateTime(), nullable=True),
                    Column('deleted', Boolean(), nullable=False),
                    Column('meta_data', JSONEncodedDict(), nullable=True),
                    Column('status',
                           String(length=30),
                           server_default='active',
                           nullable=False),
                    PrimaryKeyConstraint('id'),
                    ForeignKeyConstraint(
                        ['image_id'],
                        ['images.id'],
                    ),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_image_locations_deleted',
                    'image_locations', ['deleted'],
                    unique=False)
    op.create_index('ix_image_locations_image_id',
                    'image_locations', ['image_id'],
                    unique=False)
Ejemplo n.º 14
0
def _add_image_properties_table():
    op.create_table('image_properties',
                    Column('id', Integer(), nullable=False),
                    Column('image_id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=False),
                    Column('value', Text(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    Column('deleted_at', DateTime(), nullable=True),
                    Column('deleted', Boolean(), nullable=False),
                    PrimaryKeyConstraint('id'),
                    ForeignKeyConstraint(
                        ['image_id'],
                        ['images.id'],
                    ),
                    UniqueConstraint('image_id',
                                     'name',
                                     name='ix_image_properties_image_id_name'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_image_properties_deleted',
                    'image_properties', ['deleted'],
                    unique=False)
    op.create_index('ix_image_properties_image_id',
                    'image_properties', ['image_id'],
                    unique=False)
Ejemplo n.º 15
0
def define_artifact_dependencies_table(meta):
    artifact_dependencies = Table('artifact_dependencies',
                                  meta,
                                  Column('id', String(36), primary_key=True,
                                         nullable=False),
                                  Column('artifact_source', String(36),
                                         ForeignKey('artifacts.id'),
                                         nullable=False),
                                  Column('artifact_dest', String(36),
                                         ForeignKey('artifacts.id'),
                                         nullable=False),
                                  Column('artifact_origin', String(36),
                                         ForeignKey('artifacts.id'),
                                         nullable=False),
                                  Column('is_direct', Boolean(),
                                         nullable=False),
                                  Column('position', Integer()),
                                  Column('name', String(36)),
                                  Column('created_at', DateTime(),
                                         nullable=False),
                                  Column('updated_at', DateTime(),
                                         nullable=False),
                                  mysql_engine='InnoDB',
                                  extend_existing=True)

    Index('ix_artifact_dependencies_source_id',
          artifact_dependencies.c.artifact_source)
    Index('ix_artifact_dependencies_dest_id',
          artifact_dependencies.c.artifact_dest),
    Index('ix_artifact_dependencies_origin_id',
          artifact_dependencies.c.artifact_origin)
    Index('ix_artifact_dependencies_direct_dependencies',
          artifact_dependencies.c.artifact_source,
          artifact_dependencies.c.is_direct)
    return artifact_dependencies
Ejemplo n.º 16
0
def _add_artifact_blobs_table():
    op.create_table('artifact_blobs',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_id', String(length=36), nullable=False),
                    Column('size', BigInteger(), nullable=False),
                    Column('checksum', String(length=32), nullable=True),
                    Column('name', String(length=255), nullable=False),
                    Column('item_key', String(length=329), nullable=True),
                    Column('position', Integer(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    ForeignKeyConstraint(
                        ['artifact_id'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_blobs_artifact_id',
                    'artifact_blobs', ['artifact_id'],
                    unique=False)
    op.create_index('ix_artifact_blobs_name',
                    'artifact_blobs', ['name'],
                    unique=False)
def define_artifact_blob_locations_table(meta):
    artifact_blob_locations = Table('artifact_blob_locations',
                                    meta,
                                    Column('id',
                                           String(36),
                                           primary_key=True,
                                           nullable=False),
                                    Column('blob_id',
                                           String(36),
                                           ForeignKey('artifact_blobs.id'),
                                           nullable=False),
                                    Column('value', Text(), nullable=False),
                                    Column('created_at',
                                           DateTime(),
                                           nullable=False),
                                    Column('updated_at',
                                           DateTime(),
                                           nullable=False),
                                    Column('position', Integer()),
                                    Column('status', String(36),
                                           nullable=True),
                                    mysql_engine='InnoDB',
                                    mysql_charset='utf8',
                                    extend_existing=True)
    Index('ix_artifact_blob_locations_blob_id',
          artifact_blob_locations.c.blob_id)

    return artifact_blob_locations
Ejemplo n.º 18
0
def define_metadef_namespaces_table(meta):

    # NOTE: For DB2 if UniqueConstraint is used when creating a table
    # an index will automatically be created. So, for DB2 specify the
    # index name up front. If not DB2 then create the Index.
    _constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        _constr_kwargs['name'] = 'ix_namespaces_namespace'

    namespaces = Table('metadef_namespaces',
                       meta,
                       Column('id',
                              Integer(),
                              primary_key=True,
                              nullable=False),
                       Column('namespace', String(80), nullable=False),
                       Column('display_name', String(80)),
                       Column('description', Text()),
                       Column('visibility', String(32)),
                       Column('protected', Boolean()),
                       Column('owner', String(255), nullable=False),
                       Column('created_at', DateTime(), nullable=False),
                       Column('updated_at', DateTime()),
                       UniqueConstraint('namespace', **_constr_kwargs),
                       mysql_engine='InnoDB',
                       mysql_charset='utf8',
                       extend_existing=True)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_namespaces_namespace', namespaces.c.namespace)

    return namespaces
Ejemplo n.º 19
0
def define_metadef_resource_types_table(meta):

    _constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        _constr_kwargs['name'] = 'ix_metadef_resource_types_name'

    metadef_res_types = Table('metadef_resource_types',
                              meta,
                              Column('id',
                                     Integer(),
                                     primary_key=True,
                                     nullable=False),
                              Column('name', String(80), nullable=False),
                              Column('protected',
                                     Boolean(),
                                     nullable=False,
                                     default=False),
                              Column('created_at', DateTime(), nullable=False),
                              Column('updated_at', DateTime()),
                              UniqueConstraint('name', **_constr_kwargs),
                              mysql_engine='InnoDB',
                              mysql_charset='utf8',
                              extend_existing=True)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_metadef_resource_types_name', metadef_res_types.c.name)

    return metadef_res_types
def get_image_members_table(meta):
    images = get_images_table(meta)

    image_members = Table('image_members', meta,
        Column('id', Integer(), primary_key=True, nullable=False),
        Column('image_id', Integer(), ForeignKey('images.id'), nullable=False,
               index=True),
        Column('member', String(255), nullable=False),
        Column('can_share', Boolean(), nullable=False, default=False),
        Column('created_at', DateTime(), nullable=False),
        Column('updated_at', DateTime()),
        Column('deleted_at', DateTime()),
        Column('deleted', Boolean(), nullable=False, default=False,
               index=True),
        UniqueConstraint('image_id', 'member'),
        mysql_engine='InnoDB',
        extend_existing=True)

    Index('ix_image_members_image_id_member', image_members.c.image_id,
          image_members.c.member)

    return image_members
Ejemplo n.º 21
0
def define_metadef_tags_table(meta):
    _constr_kwargs = {}
    metadef_tags = Table('metadef_tags',
                         meta,
                         Column('id',
                                Integer(),
                                primary_key=True,
                                nullable=False),
                         Column('namespace_id', Integer(), nullable=False),
                         Column('name', String(80), nullable=False),
                         Column('created_at', DateTime(), nullable=False),
                         Column('updated_at', DateTime()),
                         UniqueConstraint('namespace_id', 'name',
                                          **_constr_kwargs),
                         mysql_engine='InnoDB',
                         extend_existing=False)

    if meta.bind.name != 'ibm_db_sa':
        Index('ix_tags_namespace_id_name', metadef_tags.c.namespace_id,
              metadef_tags.c.name)

    return metadef_tags
Ejemplo n.º 22
0
def get_image_members_table(meta):
    images = get_images_table(meta)  # noqa

    image_members = Table('image_members',
                          meta,
                          Column('id',
                                 Integer(),
                                 primary_key=True,
                                 nullable=False),
                          Column('image_id',
                                 Integer(),
                                 ForeignKey('images.id'),
                                 nullable=False,
                                 index=True),
                          Column('member', String(255), nullable=False),
                          Column('can_share',
                                 Boolean(),
                                 nullable=False,
                                 default=False),
                          Column('created_at', DateTime(), nullable=False),
                          Column('updated_at', DateTime()),
                          Column('deleted_at', DateTime()),
                          Column('deleted',
                                 Boolean(),
                                 nullable=False,
                                 default=False,
                                 index=True),
                          UniqueConstraint('image_id', 'member'),
                          mysql_charset='utf8',
                          mysql_engine='InnoDB',
                          extend_existing=True)

    # DB2: an index has already been created for the UniqueConstraint option
    # specified on the Table() statement above.
    if meta.bind.name != "ibm_db_sa":
        Index('ix_image_members_image_id_member', image_members.c.image_id,
              image_members.c.member)

    return image_members
Ejemplo n.º 23
0
def _add_metadef_resource_types_table():
    op.create_table('metadef_resource_types',
                    Column('id', Integer(), nullable=False),
                    Column('name', String(length=80), nullable=False),
                    Column('protected', Boolean(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    PrimaryKeyConstraint('id'),
                    UniqueConstraint('name',
                                     name='uq_metadef_resource_types_name'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)
Ejemplo n.º 24
0
def _add_metadef_tags_table():
    op.create_table('metadef_tags',
                    Column('id', Integer(), nullable=False),
                    Column('namespace_id', Integer(), nullable=False),
                    Column('name', String(length=80), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    ForeignKeyConstraint(
                        ['namespace_id'],
                        ['metadef_namespaces.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    UniqueConstraint('namespace_id',
                                     'name',
                                     name='uq_metadef_tags_namespace_id_name'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_metadef_tags_name',
                    'metadef_tags', ['name'],
                    unique=False)
Ejemplo n.º 25
0
def get_image_properties_table(meta):
    """
    Returns the Table object for the image_properties table that
    corresponds to the image_properties table definition of this version.
    """
    (get_images_table, ) = from_migration_import('004_add_checksum',
                                                 ['get_images_table'])

    images = get_images_table(meta)

    image_properties = Table('image_properties',
                             meta,
                             Column('id',
                                    Integer(),
                                    primary_key=True,
                                    nullable=False),
                             Column('image_id',
                                    Integer(),
                                    ForeignKey('images.id'),
                                    nullable=False,
                                    index=True),
                             Column('name', String(255), nullable=False),
                             Column('value', Text()),
                             Column('created_at', DateTime(), nullable=False),
                             Column('updated_at', DateTime()),
                             Column('deleted_at', DateTime()),
                             Column('deleted',
                                    Boolean(),
                                    nullable=False,
                                    default=False,
                                    index=True),
                             UniqueConstraint('image_id', 'name'),
                             mysql_engine='InnoDB',
                             extend_existing=True)

    return image_properties
Ejemplo n.º 26
0
def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    # No changes to SQLite stores are necessary, since
    # there is no BIG INTEGER type in SQLite. Unfortunately,
    # running the Python 005_size_big_integer.py migration script
    # on a SQLite datastore results in an error in the sa-migrate
    # code that does the workarounds for SQLite not having
    # ALTER TABLE MODIFY COLUMN ability

    dialect = migrate_engine.url.get_dialect().name

    if not dialect.startswith('sqlite'):
        images = get_images_table(meta)
        images.columns['size'].alter(type=Integer())
Ejemplo n.º 27
0
def _add_artifact_dependencies_table():
    op.create_table('artifact_dependencies',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_source',
                           String(length=36),
                           nullable=False),
                    Column('artifact_dest', String(length=36), nullable=False),
                    Column('artifact_origin',
                           String(length=36),
                           nullable=False),
                    Column('is_direct', Boolean(), nullable=False),
                    Column('position', Integer(), nullable=True),
                    Column('name', String(length=36), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    ForeignKeyConstraint(
                        ['artifact_dest'],
                        ['artifacts.id'],
                    ),
                    ForeignKeyConstraint(
                        ['artifact_origin'],
                        ['artifacts.id'],
                    ),
                    ForeignKeyConstraint(
                        ['artifact_source'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_dependencies_dest_id',
                    'artifact_dependencies', ['artifact_dest'],
                    unique=False)
    op.create_index('ix_artifact_dependencies_direct_dependencies',
                    'artifact_dependencies', ['artifact_source', 'is_direct'],
                    unique=False)
    op.create_index('ix_artifact_dependencies_origin_id',
                    'artifact_dependencies', ['artifact_origin'],
                    unique=False)
    op.create_index('ix_artifact_dependencies_source_id',
                    'artifact_dependencies', ['artifact_source'],
                    unique=False)
Ejemplo n.º 28
0
def _add_artifact_blob_locations_table():
    op.create_table('artifact_blob_locations',
                    Column('id', String(length=36), nullable=False),
                    Column('blob_id', String(length=36), nullable=False),
                    Column('value', Text(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    Column('position', Integer(), nullable=True),
                    Column('status', String(length=36), nullable=True),
                    ForeignKeyConstraint(
                        ['blob_id'],
                        ['artifact_blobs.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_blob_locations_blob_id',
                    'artifact_blob_locations', ['blob_id'],
                    unique=False)
Ejemplo n.º 29
0
def _add_metadef_namespaces_table():
    op.create_table('metadef_namespaces',
                    Column('id', Integer(), nullable=False),
                    Column('namespace', String(length=80), nullable=False),
                    Column('display_name', String(length=80), nullable=True),
                    Column('description', Text(), nullable=True),
                    Column('visibility', String(length=32), nullable=True),
                    Column('protected', Boolean(), nullable=True),
                    Column('owner', String(length=255), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    PrimaryKeyConstraint('id'),
                    UniqueConstraint('namespace',
                                     name='uq_metadef_namespaces_namespace'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_metadef_namespaces_owner',
                    'metadef_namespaces', ['owner'],
                    unique=False)
Ejemplo n.º 30
0
def define_artifact_blobs_table(meta):
    artifact_blobs = Table('artifact_blobs',
                           meta,
                           Column('id', String(36), primary_key=True,
                                  nullable=False),
                           Column('artifact_id', String(36),
                                  ForeignKey('artifacts.id'),
                                  nullable=False),
                           Column('size', BigInteger(), nullable=False),
                           Column('checksum', String(32)),
                           Column('name', String(255), nullable=False),
                           Column('item_key', String(329)),
                           Column('position', Integer()),
                           Column('created_at', DateTime(), nullable=False),
                           Column('updated_at', DateTime(),
                                  nullable=False),
                           mysql_engine='InnoDB',
                           extend_existing=True)
    Index('ix_artifact_blobs_artifact_id',
          artifact_blobs.c.artifact_id)
    Index('ix_artifact_blobs_name',
          artifact_blobs.c.name)
    return artifact_blobs