Basic labels support
Adds basic labels support to the registry code (V2), and the API. Note that this does not yet add any UI related support.
This commit is contained in:
parent
427070b453
commit
608ffd9663
24 changed files with 907 additions and 36 deletions
|
@ -0,0 +1,89 @@
|
|||
"""Add labels to the schema
|
||||
|
||||
Revision ID: c9b91bee7554
|
||||
Revises: 983247d75af3
|
||||
Create Date: 2016-08-22 15:40:25.226541
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c9b91bee7554'
|
||||
down_revision = '983247d75af3'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from util.migrate import UTF8LongText, UTF8CharField
|
||||
|
||||
def upgrade(tables):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('labelsourcetype',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('mutable', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_labelsourcetype'))
|
||||
)
|
||||
op.create_index('labelsourcetype_name', 'labelsourcetype', ['name'], unique=True)
|
||||
op.create_table('mediatype',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_mediatype'))
|
||||
)
|
||||
op.create_index('mediatype_name', 'mediatype', ['name'], unique=True)
|
||||
op.create_table('label',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('uuid', sa.String(length=255), nullable=False),
|
||||
sa.Column('key', UTF8CharField(length=255), nullable=False),
|
||||
sa.Column('value', UTF8LongText(), nullable=False),
|
||||
sa.Column('media_type_id', sa.Integer(), nullable=False),
|
||||
sa.Column('source_type_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['media_type_id'], ['mediatype.id'], name=op.f('fk_label_media_type_id_mediatype')),
|
||||
sa.ForeignKeyConstraint(['source_type_id'], ['labelsourcetype.id'], name=op.f('fk_label_source_type_id_labelsourcetype')),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_label'))
|
||||
)
|
||||
op.create_index('label_key', 'label', ['key'], unique=False)
|
||||
op.create_index('label_media_type_id', 'label', ['media_type_id'], unique=False)
|
||||
op.create_index('label_source_type_id', 'label', ['source_type_id'], unique=False)
|
||||
op.create_index('label_uuid', 'label', ['uuid'], unique=True)
|
||||
op.create_table('tagmanifestlabel',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('repository_id', sa.Integer(), nullable=False),
|
||||
sa.Column('annotated_id', sa.Integer(), nullable=False),
|
||||
sa.Column('label_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['annotated_id'], ['tagmanifest.id'], name=op.f('fk_tagmanifestlabel_annotated_id_tagmanifest')),
|
||||
sa.ForeignKeyConstraint(['label_id'], ['label.id'], name=op.f('fk_tagmanifestlabel_label_id_label')),
|
||||
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], name=op.f('fk_tagmanifestlabel_repository_id_repository')),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_tagmanifestlabel'))
|
||||
)
|
||||
op.create_index('tagmanifestlabel_annotated_id', 'tagmanifestlabel', ['annotated_id'], unique=False)
|
||||
op.create_index('tagmanifestlabel_annotated_id_label_id', 'tagmanifestlabel', ['annotated_id', 'label_id'], unique=True)
|
||||
op.create_index('tagmanifestlabel_label_id', 'tagmanifestlabel', ['label_id'], unique=False)
|
||||
op.create_index('tagmanifestlabel_repository_id', 'tagmanifestlabel', ['repository_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
op.bulk_insert(tables.logentrykind, [
|
||||
{'name':'manifest_label_add'},
|
||||
{'name':'manifest_label_delete'},
|
||||
])
|
||||
|
||||
op.bulk_insert(tables.mediatype, [
|
||||
{'name':'text/plain'},
|
||||
{'name':'application/json'},
|
||||
])
|
||||
|
||||
op.bulk_insert(tables.labelsourcetype, [
|
||||
{'name':'manifest', 'mutable': False},
|
||||
{'name':'api', 'mutable': True},
|
||||
{'name':'internal', 'mutable': False},
|
||||
])
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
op.execute(tables.logentrykind.delete().where(tables.logentrykind.c.name == op.inline_literal('manifest_label_add')))
|
||||
op.execute(tables.logentrykind.delete().where(tables.logentrykind.c.name == op.inline_literal('manifest_label_delete')))
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('tagmanifestlabel')
|
||||
op.drop_table('label')
|
||||
op.drop_table('mediatype')
|
||||
op.drop_table('labelsourcetype')
|
||||
### end Alembic commands ###
|
Reference in a new issue