def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "deletedrepository", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("marked", sa.DateTime(), nullable=False), sa.Column("original_name", sa.String(length=255), nullable=False), sa.Column("queue_id", sa.String(length=255), nullable=True), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_deletedrepository_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_deletedrepository")), ) op.create_index("deletedrepository_original_name", "deletedrepository", ["original_name"], unique=False) op.create_index("deletedrepository_queue_id", "deletedrepository", ["queue_id"], unique=False) op.create_index("deletedrepository_repository_id", "deletedrepository", ["repository_id"], unique=True)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "logentry3", sa.Column("id", sa.BigInteger(), nullable=False), sa.Column("kind_id", sa.Integer(), nullable=False), sa.Column("account_id", sa.Integer(), nullable=False), sa.Column("performer_id", sa.Integer(), nullable=True), sa.Column("repository_id", sa.Integer(), nullable=True), sa.Column("datetime", sa.DateTime(), nullable=False), sa.Column("ip", sa.String(length=255), nullable=True), sa.Column("metadata_json", sa.Text(), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_logentry3")), ) op.create_index("logentry3_account_id_datetime", "logentry3", ["account_id", "datetime"], unique=False) op.create_index("logentry3_datetime", "logentry3", ["datetime"], unique=False) op.create_index("logentry3_performer_id_datetime", "logentry3", ["performer_id", "datetime"], unique=False) op.create_index( "logentry3_repository_id_datetime_kind_id", "logentry3", ["repository_id", "datetime", "kind_id"], unique=False, )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'tagtorepositorytag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('repository_id', sa.Integer(), nullable=False), sa.Column('tag_id', sa.Integer(), nullable=False), sa.Column('repository_tag_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['repository_id'], ['repository.id'], name=op.f('fk_tagtorepositorytag_repository_id_repository')), sa.ForeignKeyConstraint( ['repository_tag_id'], ['repositorytag.id'], name=op.f( 'fk_tagtorepositorytag_repository_tag_id_repositorytag')), sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], name=op.f('fk_tagtorepositorytag_tag_id_tag')), sa.PrimaryKeyConstraint('id', name=op.f('pk_tagtorepositorytag'))) op.create_index('tagtorepositorytag_repository_id', 'tagtorepositorytag', ['repository_id'], unique=False) op.create_index('tagtorepositorytag_repository_tag_id', 'tagtorepositorytag', ['repository_tag_id'], unique=True) op.create_index('tagtorepositorytag_tag_id', 'tagtorepositorytag', ['tag_id'], unique=True) # ### end Alembic commands ### tester.populate_table('tagtorepositorytag', [ ('repository_id', tester.TestDataType.Foreign('repository')), ('tag_id', tester.TestDataType.Foreign('tag')), ('repository_tag_id', tester.TestDataType.Foreign('repositorytag')), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "robotaccountmetadata", sa.Column("id", sa.Integer(), nullable=False), sa.Column("robot_account_id", sa.Integer(), nullable=False), sa.Column("description", UTF8CharField(length=255), nullable=False), sa.Column("unstructured_json", sa.Text(), nullable=False), sa.ForeignKeyConstraint( ["robot_account_id"], ["user.id"], name=op.f("fk_robotaccountmetadata_robot_account_id_user"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_robotaccountmetadata")), ) op.create_index( "robotaccountmetadata_robot_account_id", "robotaccountmetadata", ["robot_account_id"], unique=True, ) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table( "robotaccountmetadata", [ ("robot_account_id", tester.TestDataType.Foreign("user")), ("description", tester.TestDataType.UTF8Char), ("unstructured_json", tester.TestDataType.JSON), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( 'teamsync', sa.Column('id', sa.Integer(), nullable=False), sa.Column('team_id', sa.Integer(), nullable=False), sa.Column('transaction_id', sa.String(length=255), nullable=False), sa.Column('last_updated', sa.DateTime(), nullable=True), sa.Column('service_id', sa.Integer(), nullable=False), sa.Column('config', UTF8LongText(), nullable=False), sa.ForeignKeyConstraint( ['service_id'], ['loginservice.id'], name=op.f('fk_teamsync_service_id_loginservice')), sa.ForeignKeyConstraint(['team_id'], ['team.id'], name=op.f('fk_teamsync_team_id_team')), sa.PrimaryKeyConstraint('id', name=op.f('pk_teamsync'))) op.create_index('teamsync_last_updated', 'teamsync', ['last_updated'], unique=False) op.create_index('teamsync_service_id', 'teamsync', ['service_id'], unique=False) op.create_index('teamsync_team_id', 'teamsync', ['team_id'], unique=True) ### end Alembic commands ### # ### population of test data ### # tester.populate_table('teamsync', [ ('team_id', tester.TestDataType.Foreign('team')), ('transaction_id', tester.TestDataType.String), ('last_updated', tester.TestDataType.DateTime), ('service_id', tester.TestDataType.Foreign('loginservice')), ('config', tester.TestDataType.JSON), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "appspecificauthtoken", sa.Column("id", sa.Integer(), nullable=False), sa.Column("user_id", sa.Integer(), nullable=False), sa.Column("uuid", sa.String(length=36), nullable=False), sa.Column("title", UTF8CharField(length=255), nullable=False), sa.Column("token_code", sa.String(length=255), nullable=False), sa.Column("created", sa.DateTime(), nullable=False), sa.Column("expiration", sa.DateTime(), nullable=True), sa.Column("last_accessed", sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ["user_id"], ["user.id"], name=op.f("fk_appspecificauthtoken_user_id_user")), sa.PrimaryKeyConstraint("id", name=op.f("pk_appspecificauthtoken")), ) op.create_index("appspecificauthtoken_token_code", "appspecificauthtoken", ["token_code"], unique=True) op.create_index("appspecificauthtoken_user_id", "appspecificauthtoken", ["user_id"], unique=False) op.create_index( "appspecificauthtoken_user_id_expiration", "appspecificauthtoken", ["user_id", "expiration"], unique=False, ) op.create_index("appspecificauthtoken_uuid", "appspecificauthtoken", ["uuid"], unique=False) # ### end Alembic commands ### op.bulk_insert( tables.logentrykind, [ { "name": "create_app_specific_token" }, { "name": "revoke_app_specific_token" }, ], ) # ### population of test data ### # tester.populate_table( "appspecificauthtoken", [ ("user_id", tester.TestDataType.Foreign("user")), ("uuid", tester.TestDataType.UUID), ("title", tester.TestDataType.UTF8Char), ("token_code", tester.TestDataType.String), ("created", tester.TestDataType.DateTime), ("expiration", tester.TestDataType.DateTime), ("last_accessed", tester.TestDataType.DateTime), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( "repositorysearchscore", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("score", sa.BigInteger(), nullable=False), sa.Column("last_updated", sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_repositorysearchscore_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_repositorysearchscore")), ) op.create_index( "repositorysearchscore_repository_id", "repositorysearchscore", ["repository_id"], unique=True, ) op.create_index("repositorysearchscore_score", "repositorysearchscore", ["score"], unique=False) ### end Alembic commands ### # ### population of test data ### # tester.populate_table( "repositorysearchscore", [ ("repository_id", tester.TestDataType.Foreign("repository")), ("score", tester.TestDataType.BigInteger), ("last_updated", tester.TestDataType.DateTime), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( 'repositorysearchscore', sa.Column('id', sa.Integer(), nullable=False), sa.Column('repository_id', sa.Integer(), nullable=False), sa.Column('score', sa.BigInteger(), nullable=False), sa.Column('last_updated', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['repository_id'], ['repository.id'], name=op.f('fk_repositorysearchscore_repository_id_repository')), sa.PrimaryKeyConstraint('id', name=op.f('pk_repositorysearchscore'))) op.create_index('repositorysearchscore_repository_id', 'repositorysearchscore', ['repository_id'], unique=True) op.create_index('repositorysearchscore_score', 'repositorysearchscore', ['score'], unique=False) ### end Alembic commands ### # ### population of test data ### # tester.populate_table('repositorysearchscore', [ ('repository_id', tester.TestDataType.Foreign('repository')), ('score', tester.TestDataType.BigInteger), ('last_updated', tester.TestDataType.DateTime), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( "teamsync", sa.Column("id", sa.Integer(), nullable=False), sa.Column("team_id", sa.Integer(), nullable=False), sa.Column("transaction_id", sa.String(length=255), nullable=False), sa.Column("last_updated", sa.DateTime(), nullable=True), sa.Column("service_id", sa.Integer(), nullable=False), sa.Column("config", UTF8LongText(), nullable=False), sa.ForeignKeyConstraint( ["service_id"], ["loginservice.id"], name=op.f("fk_teamsync_service_id_loginservice") ), sa.ForeignKeyConstraint(["team_id"], ["team.id"], name=op.f("fk_teamsync_team_id_team")), sa.PrimaryKeyConstraint("id", name=op.f("pk_teamsync")), ) op.create_index("teamsync_last_updated", "teamsync", ["last_updated"], unique=False) op.create_index("teamsync_service_id", "teamsync", ["service_id"], unique=False) op.create_index("teamsync_team_id", "teamsync", ["team_id"], unique=True) ### end Alembic commands ### # ### population of test data ### # tester.populate_table( "teamsync", [ ("team_id", tester.TestDataType.Foreign("team")), ("transaction_id", tester.TestDataType.String), ("last_updated", tester.TestDataType.DateTime), ("service_id", tester.TestDataType.Foreign("loginservice")), ("config", tester.TestDataType.JSON), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "disablereason", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_disablereason")), ) op.create_index("disablereason_name", "disablereason", ["name"], unique=True) op.bulk_insert( tables.disablereason, [ { "id": 1, "name": "user_toggled" }, ], ) op.bulk_insert(tables.logentrykind, [ { "name": "toggle_repo_trigger" }, ]) op.add_column(u"repositorybuildtrigger", sa.Column("disabled_reason_id", sa.Integer(), nullable=True)) op.add_column( u"repositorybuildtrigger", sa.Column("enabled", sa.Boolean(), nullable=False, server_default=sa.sql.expression.true()), ) op.create_index( "repositorybuildtrigger_disabled_reason_id", "repositorybuildtrigger", ["disabled_reason_id"], unique=False, ) op.create_foreign_key( op.f("fk_repositorybuildtrigger_disabled_reason_id_disablereason"), "repositorybuildtrigger", "disablereason", ["disabled_reason_id"], ["id"], ) # ### end Alembic commands ### # ### population of test data ### # tester.populate_column("repositorybuildtrigger", "disabled_reason_id", tester.TestDataType.Foreign("disablereason")) tester.populate_column("repositorybuildtrigger", "enabled", tester.TestDataType.Boolean)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( "userpromptkind", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_userpromptkind")), ) op.create_index("userpromptkind_name", "userpromptkind", ["name"], unique=False) op.create_table( "userprompt", sa.Column("id", sa.Integer(), nullable=False), sa.Column("user_id", sa.Integer(), nullable=False), sa.Column("kind_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["kind_id"], ["userpromptkind.id"], name=op.f("fk_userprompt_kind_id_userpromptkind")), sa.ForeignKeyConstraint(["user_id"], ["user.id"], name=op.f("fk_userprompt_user_id_user")), sa.PrimaryKeyConstraint("id", name=op.f("pk_userprompt")), ) op.create_index("userprompt_kind_id", "userprompt", ["kind_id"], unique=False) op.create_index("userprompt_user_id", "userprompt", ["user_id"], unique=False) op.create_index("userprompt_user_id_kind_id", "userprompt", ["user_id", "kind_id"], unique=True) ### end Alembic commands ### op.bulk_insert(tables.userpromptkind, [ { "name": "confirm_username" }, ]) # ### population of test data ### # tester.populate_table( "userprompt", [ ("user_id", tester.TestDataType.Foreign("user")), ("kind_id", tester.TestDataType.Foreign("userpromptkind")), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'disablereason', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_disablereason'))) op.create_index('disablereason_name', 'disablereason', ['name'], unique=True) op.bulk_insert( tables.disablereason, [ { 'id': 1, 'name': 'user_toggled' }, ], ) op.bulk_insert(tables.logentrykind, [ { 'name': 'toggle_repo_trigger' }, ]) op.add_column(u'repositorybuildtrigger', sa.Column('disabled_reason_id', sa.Integer(), nullable=True)) op.add_column( u'repositorybuildtrigger', sa.Column('enabled', sa.Boolean(), nullable=False, server_default=sa.sql.expression.true())) op.create_index('repositorybuildtrigger_disabled_reason_id', 'repositorybuildtrigger', ['disabled_reason_id'], unique=False) op.create_foreign_key( op.f('fk_repositorybuildtrigger_disabled_reason_id_disablereason'), 'repositorybuildtrigger', 'disablereason', ['disabled_reason_id'], ['id']) # ### end Alembic commands ### # ### population of test data ### # tester.populate_column('repositorybuildtrigger', 'disabled_reason_id', tester.TestDataType.Foreign('disablereason')) tester.populate_column('repositorybuildtrigger', 'enabled', tester.TestDataType.Boolean)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "namespacegeorestriction", sa.Column("id", sa.Integer(), nullable=False), sa.Column("namespace_id", sa.Integer(), nullable=False), sa.Column("added", sa.DateTime(), nullable=False), sa.Column("description", sa.String(length=255), nullable=False), sa.Column("unstructured_json", sa.Text(), nullable=False), sa.Column("restricted_region_iso_code", sa.String(length=255), nullable=False), sa.ForeignKeyConstraint( ["namespace_id"], ["user.id"], name=op.f("fk_namespacegeorestriction_namespace_id_user")), sa.PrimaryKeyConstraint("id", name=op.f("pk_namespacegeorestriction")), ) op.create_index( "namespacegeorestriction_namespace_id", "namespacegeorestriction", ["namespace_id"], unique=False, ) op.create_index( "namespacegeorestriction_namespace_id_restricted_region_iso_code", "namespacegeorestriction", ["namespace_id", "restricted_region_iso_code"], unique=True, ) op.create_index( "namespacegeorestriction_restricted_region_iso_code", "namespacegeorestriction", ["restricted_region_iso_code"], unique=False, ) # ### end Alembic commands ### tester.populate_table( "namespacegeorestriction", [ ("namespace_id", tester.TestDataType.Foreign("user")), ("added", tester.TestDataType.DateTime), ("description", tester.TestDataType.String), ("unstructured_json", tester.TestDataType.JSON), ("restricted_region_iso_code", tester.TestDataType.String), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # Note: Because of a restriction in MySQL, we cannot simply remove the index and re-add # it without the unique=False, nor can we simply alter the index. To make it work, we'd have to # remove the primary key on the field, so instead we simply drop the table entirely and # recreate it with the modified index. The backfill will re-fill this in. op.drop_table("tagmanifesttomanifest") op.create_table( "tagmanifesttomanifest", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tag_manifest_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("broken", sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_tagmanifesttomanifest_manifest_id_manifest"), ), sa.ForeignKeyConstraint( ["tag_manifest_id"], ["tagmanifest.id"], name=op.f("fk_tagmanifesttomanifest_tag_manifest_id_tagmanifest"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_tagmanifesttomanifest")), ) op.create_index( "tagmanifesttomanifest_broken", "tagmanifesttomanifest", ["broken"], unique=False ) op.create_index( "tagmanifesttomanifest_manifest_id", "tagmanifesttomanifest", ["manifest_id"], unique=False ) op.create_index( "tagmanifesttomanifest_tag_manifest_id", "tagmanifesttomanifest", ["tag_manifest_id"], unique=True, ) tester.populate_table( "tagmanifesttomanifest", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("tag_manifest_id", tester.TestDataType.Foreign("tagmanifest")), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "tagtorepositorytag", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("tag_id", sa.Integer(), nullable=False), sa.Column("repository_tag_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_tagtorepositorytag_repository_id_repository"), ), sa.ForeignKeyConstraint( ["repository_tag_id"], ["repositorytag.id"], name=op.f("fk_tagtorepositorytag_repository_tag_id_repositorytag"), ), sa.ForeignKeyConstraint(["tag_id"], ["tag.id"], name=op.f("fk_tagtorepositorytag_tag_id_tag")), sa.PrimaryKeyConstraint("id", name=op.f("pk_tagtorepositorytag")), ) op.create_index("tagtorepositorytag_repository_id", "tagtorepositorytag", ["repository_id"], unique=False) op.create_index( "tagtorepositorytag_repository_tag_id", "tagtorepositorytag", ["repository_tag_id"], unique=True, ) op.create_index("tagtorepositorytag_tag_id", "tagtorepositorytag", ["tag_id"], unique=True) # ### end Alembic commands ### tester.populate_table( "tagtorepositorytag", [ ("repository_id", tester.TestDataType.Foreign("repository")), ("tag_id", tester.TestDataType.Foreign("tag")), ("repository_tag_id", tester.TestDataType.Foreign("repositorytag")), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table('logentry3', sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('kind_id', sa.Integer(), nullable=False), sa.Column('account_id', sa.Integer(), nullable=False), sa.Column('performer_id', sa.Integer(), nullable=True), sa.Column('repository_id', sa.Integer(), nullable=True), sa.Column('datetime', sa.DateTime(), nullable=False), sa.Column('ip', sa.String(length=255), nullable=True), sa.Column('metadata_json', sa.Text(), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_logentry3')) ) op.create_index('logentry3_account_id_datetime', 'logentry3', ['account_id', 'datetime'], unique=False) op.create_index('logentry3_datetime', 'logentry3', ['datetime'], unique=False) op.create_index('logentry3_performer_id_datetime', 'logentry3', ['performer_id', 'datetime'], unique=False) op.create_index('logentry3_repository_id_datetime_kind_id', 'logentry3', ['repository_id', 'datetime', 'kind_id'], unique=False)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "deletednamespace", sa.Column("id", sa.Integer(), nullable=False), sa.Column("namespace_id", sa.Integer(), nullable=False), sa.Column("marked", sa.DateTime(), nullable=False), sa.Column("original_username", sa.String(length=255), nullable=False), sa.Column("original_email", sa.String(length=255), nullable=False), sa.Column("queue_id", sa.String(length=255), nullable=True), sa.ForeignKeyConstraint( ["namespace_id"], ["user.id"], name=op.f("fk_deletednamespace_namespace_id_user")), sa.PrimaryKeyConstraint("id", name=op.f("pk_deletednamespace")), ) op.create_index("deletednamespace_namespace_id", "deletednamespace", ["namespace_id"], unique=True) op.create_index("deletednamespace_original_email", "deletednamespace", ["original_email"], unique=False) op.create_index( "deletednamespace_original_username", "deletednamespace", ["original_username"], unique=False, ) op.create_index("deletednamespace_queue_id", "deletednamespace", ["queue_id"], unique=False) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table( "deletednamespace", [ ("namespace_id", tester.TestDataType.Foreign("user")), ("marked", tester.TestDataType.DateTime), ("original_username", tester.TestDataType.UTF8Char), ("original_email", tester.TestDataType.String), ("queue_id", tester.TestDataType.Foreign("queueitem")), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) op.create_table( "repositorykind", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_repositorykind")), ) op.create_index("repositorykind_name", "repositorykind", ["name"], unique=True) op.bulk_insert( tables.repositorykind, [ { "id": 1, "name": "image" }, { "id": 2, "name": "application" }, ], ) op.add_column( u"repository", sa.Column("kind_id", sa.Integer(), nullable=False, server_default="1")) op.create_index("repository_kind_id", "repository", ["kind_id"], unique=False) op.create_foreign_key( op.f("fk_repository_kind_id_repositorykind"), "repository", "repositorykind", ["kind_id"], ["id"], ) # ### population of test data ### # tester.populate_column("repository", "kind_id", tester.TestDataType.Foreign("repositorykind"))
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_table( 'userpromptkind', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_userpromptkind'))) op.create_index('userpromptkind_name', 'userpromptkind', ['name'], unique=False) op.create_table( 'userprompt', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('kind_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['kind_id'], ['userpromptkind.id'], name=op.f('fk_userprompt_kind_id_userpromptkind')), sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_userprompt_user_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_userprompt'))) op.create_index('userprompt_kind_id', 'userprompt', ['kind_id'], unique=False) op.create_index('userprompt_user_id', 'userprompt', ['user_id'], unique=False) op.create_index('userprompt_user_id_kind_id', 'userprompt', ['user_id', 'kind_id'], unique=True) ### end Alembic commands ### op.bulk_insert(tables.userpromptkind, [ { 'name': 'confirm_username' }, ]) # ### population of test data ### # tester.populate_table('userprompt', [ ('user_id', tester.TestDataType.Foreign('user')), ('kind_id', tester.TestDataType.Foreign('userpromptkind')), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'namespacegeorestriction', sa.Column('id', sa.Integer(), nullable=False), sa.Column('namespace_id', sa.Integer(), nullable=False), sa.Column('added', sa.DateTime(), nullable=False), sa.Column('description', sa.String(length=255), nullable=False), sa.Column('unstructured_json', sa.Text(), nullable=False), sa.Column('restricted_region_iso_code', sa.String(length=255), nullable=False), sa.ForeignKeyConstraint( ['namespace_id'], ['user.id'], name=op.f('fk_namespacegeorestriction_namespace_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_namespacegeorestriction'))) op.create_index('namespacegeorestriction_namespace_id', 'namespacegeorestriction', ['namespace_id'], unique=False) op.create_index( 'namespacegeorestriction_namespace_id_restricted_region_iso_code', 'namespacegeorestriction', ['namespace_id', 'restricted_region_iso_code'], unique=True) op.create_index('namespacegeorestriction_restricted_region_iso_code', 'namespacegeorestriction', ['restricted_region_iso_code'], unique=False) # ### end Alembic commands ### tester.populate_table('namespacegeorestriction', [ ('namespace_id', tester.TestDataType.Foreign('user')), ('added', tester.TestDataType.DateTime), ('description', tester.TestDataType.String), ('unstructured_json', tester.TestDataType.JSON), ('restricted_region_iso_code', tester.TestDataType.String), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'robotaccountmetadata', sa.Column('id', sa.Integer(), nullable=False), sa.Column('robot_account_id', sa.Integer(), nullable=False), sa.Column('description', UTF8CharField(length=255), nullable=False), sa.Column('unstructured_json', sa.Text(), nullable=False), sa.ForeignKeyConstraint( ['robot_account_id'], ['user.id'], name=op.f('fk_robotaccountmetadata_robot_account_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_robotaccountmetadata'))) op.create_index('robotaccountmetadata_robot_account_id', 'robotaccountmetadata', ['robot_account_id'], unique=True) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table('robotaccountmetadata', [ ('robot_account_id', tester.TestDataType.Foreign('user')), ('description', tester.TestDataType.UTF8Char), ('unstructured_json', tester.TestDataType.JSON), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) op.create_table( 'repositorykind', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_repositorykind'))) op.create_index('repositorykind_name', 'repositorykind', ['name'], unique=True) op.bulk_insert( tables.repositorykind, [ { 'id': 1, 'name': 'image' }, { 'id': 2, 'name': 'application' }, ], ) op.add_column( u'repository', sa.Column('kind_id', sa.Integer(), nullable=False, server_default='1')) op.create_index('repository_kind_id', 'repository', ['kind_id'], unique=False) op.create_foreign_key(op.f('fk_repository_kind_id_repositorykind'), 'repository', 'repositorykind', ['kind_id'], ['id']) # ### population of test data ### # tester.populate_column('repository', 'kind_id', tester.TestDataType.Foreign('repositorykind'))
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table('appspecificauthtoken', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('uuid', sa.String(length=36), nullable=False), sa.Column('title', UTF8CharField(length=255), nullable=False), sa.Column('token_code', sa.String(length=255), nullable=False), sa.Column('created', sa.DateTime(), nullable=False), sa.Column('expiration', sa.DateTime(), nullable=True), sa.Column('last_accessed', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_appspecificauthtoken_user_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_appspecificauthtoken')) ) op.create_index('appspecificauthtoken_token_code', 'appspecificauthtoken', ['token_code'], unique=True) op.create_index('appspecificauthtoken_user_id', 'appspecificauthtoken', ['user_id'], unique=False) op.create_index('appspecificauthtoken_user_id_expiration', 'appspecificauthtoken', ['user_id', 'expiration'], unique=False) op.create_index('appspecificauthtoken_uuid', 'appspecificauthtoken', ['uuid'], unique=False) # ### end Alembic commands ### op.bulk_insert(tables.logentrykind, [ {'name': 'create_app_specific_token'}, {'name': 'revoke_app_specific_token'}, ]) # ### population of test data ### # tester.populate_table('appspecificauthtoken', [ ('user_id', tester.TestDataType.Foreign('user')), ('uuid', tester.TestDataType.UUID), ('title', tester.TestDataType.UTF8Char), ('token_code', tester.TestDataType.String), ('created', tester.TestDataType.DateTime), ('expiration', tester.TestDataType.DateTime), ('last_accessed', tester.TestDataType.DateTime), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'deletednamespace', sa.Column('id', sa.Integer(), nullable=False), sa.Column('namespace_id', sa.Integer(), nullable=False), sa.Column('marked', sa.DateTime(), nullable=False), sa.Column('original_username', sa.String(length=255), nullable=False), sa.Column('original_email', sa.String(length=255), nullable=False), sa.Column('queue_id', sa.String(length=255), nullable=True), sa.ForeignKeyConstraint( ['namespace_id'], ['user.id'], name=op.f('fk_deletednamespace_namespace_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_deletednamespace'))) op.create_index('deletednamespace_namespace_id', 'deletednamespace', ['namespace_id'], unique=True) op.create_index('deletednamespace_original_email', 'deletednamespace', ['original_email'], unique=False) op.create_index('deletednamespace_original_username', 'deletednamespace', ['original_username'], unique=False) op.create_index('deletednamespace_queue_id', 'deletednamespace', ['queue_id'], unique=False) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table('deletednamespace', [ ('namespace_id', tester.TestDataType.Foreign('user')), ('marked', tester.TestDataType.DateTime), ('original_username', tester.TestDataType.UTF8Char), ('original_email', tester.TestDataType.String), ('queue_id', tester.TestDataType.Foreign('queueitem')), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "apprblobplacementlocation", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprblobplacementlocation")), ) op.create_index( "apprblobplacementlocation_name", "apprblobplacementlocation", ["name"], unique=True ) op.create_table( "apprtagkind", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprtagkind")), ) op.create_index("apprtagkind_name", "apprtagkind", ["name"], unique=True) op.create_table( "apprblob", sa.Column("id", sa.Integer(), nullable=False), sa.Column("digest", sa.String(length=255), nullable=False), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.Column("size", sa.BigInteger(), nullable=False), sa.Column("uncompressed_size", sa.BigInteger(), nullable=True), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_apprblob_media_type_id_mediatype") ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprblob")), ) op.create_index("apprblob_digest", "apprblob", ["digest"], unique=True) op.create_index("apprblob_media_type_id", "apprblob", ["media_type_id"], unique=False) op.create_table( "apprmanifest", sa.Column("id", sa.Integer(), nullable=False), sa.Column("digest", sa.String(length=255), nullable=False), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.Column("manifest_json", sa.Text(), nullable=False), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_apprmanifest_media_type_id_mediatype"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprmanifest")), ) op.create_index("apprmanifest_digest", "apprmanifest", ["digest"], unique=True) op.create_index("apprmanifest_media_type_id", "apprmanifest", ["media_type_id"], unique=False) op.create_table( "apprmanifestlist", sa.Column("id", sa.Integer(), nullable=False), sa.Column("digest", sa.String(length=255), nullable=False), sa.Column("manifest_list_json", sa.Text(), nullable=False), sa.Column("schema_version", sa.String(length=255), nullable=False), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_apprmanifestlist_media_type_id_mediatype"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprmanifestlist")), ) op.create_index("apprmanifestlist_digest", "apprmanifestlist", ["digest"], unique=True) op.create_index( "apprmanifestlist_media_type_id", "apprmanifestlist", ["media_type_id"], unique=False ) op.create_table( "apprblobplacement", sa.Column("id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.Column("location_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["blob_id"], ["apprblob.id"], name=op.f("fk_apprblobplacement_blob_id_apprblob") ), sa.ForeignKeyConstraint( ["location_id"], ["apprblobplacementlocation.id"], name=op.f("fk_apprblobplacement_location_id_apprblobplacementlocation"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprblobplacement")), ) op.create_index("apprblobplacement_blob_id", "apprblobplacement", ["blob_id"], unique=False) op.create_index( "apprblobplacement_blob_id_location_id", "apprblobplacement", ["blob_id", "location_id"], unique=True, ) op.create_index( "apprblobplacement_location_id", "apprblobplacement", ["location_id"], unique=False ) op.create_table( "apprmanifestblob", sa.Column("id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["blob_id"], ["apprblob.id"], name=op.f("fk_apprmanifestblob_blob_id_apprblob") ), sa.ForeignKeyConstraint( ["manifest_id"], ["apprmanifest.id"], name=op.f("fk_apprmanifestblob_manifest_id_apprmanifest"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprmanifestblob")), ) op.create_index("apprmanifestblob_blob_id", "apprmanifestblob", ["blob_id"], unique=False) op.create_index( "apprmanifestblob_manifest_id", "apprmanifestblob", ["manifest_id"], unique=False ) op.create_index( "apprmanifestblob_manifest_id_blob_id", "apprmanifestblob", ["manifest_id", "blob_id"], unique=True, ) op.create_table( "apprmanifestlistmanifest", sa.Column("id", sa.Integer(), nullable=False), sa.Column("manifest_list_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("operating_system", sa.String(length=255), nullable=True), sa.Column("architecture", sa.String(length=255), nullable=True), sa.Column("platform_json", sa.Text(), nullable=True), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["manifest_id"], ["apprmanifest.id"], name=op.f("fk_apprmanifestlistmanifest_manifest_id_apprmanifest"), ), sa.ForeignKeyConstraint( ["manifest_list_id"], ["apprmanifestlist.id"], name=op.f("fk_apprmanifestlistmanifest_manifest_list_id_apprmanifestlist"), ), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_apprmanifestlistmanifest_media_type_id_mediatype"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprmanifestlistmanifest")), ) op.create_index( "apprmanifestlistmanifest_manifest_id", "apprmanifestlistmanifest", ["manifest_id"], unique=False, ) op.create_index( "apprmanifestlistmanifest_manifest_list_id", "apprmanifestlistmanifest", ["manifest_list_id"], unique=False, ) op.create_index( "apprmanifestlistmanifest_manifest_list_id_media_type_id", "apprmanifestlistmanifest", ["manifest_list_id", "media_type_id"], unique=False, ) op.create_index( "apprmanifestlistmanifest_manifest_list_id_operating_system_arch", "apprmanifestlistmanifest", ["manifest_list_id", "operating_system", "architecture", "media_type_id"], unique=False, ) op.create_index( "apprmanifestlistmanifest_media_type_id", "apprmanifestlistmanifest", ["media_type_id"], unique=False, ) op.create_table( "apprtag", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_list_id", sa.Integer(), nullable=True), sa.Column("lifetime_start", sa.BigInteger(), nullable=False), sa.Column("lifetime_end", sa.BigInteger(), nullable=True), sa.Column("hidden", sa.Boolean(), nullable=False), sa.Column("reverted", sa.Boolean(), nullable=False), sa.Column("protected", sa.Boolean(), nullable=False), sa.Column("tag_kind_id", sa.Integer(), nullable=False), sa.Column("linked_tag_id", sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ["linked_tag_id"], ["apprtag.id"], name=op.f("fk_apprtag_linked_tag_id_apprtag") ), sa.ForeignKeyConstraint( ["manifest_list_id"], ["apprmanifestlist.id"], name=op.f("fk_apprtag_manifest_list_id_apprmanifestlist"), ), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_apprtag_repository_id_repository") ), sa.ForeignKeyConstraint( ["tag_kind_id"], ["apprtagkind.id"], name=op.f("fk_apprtag_tag_kind_id_apprtagkind") ), sa.PrimaryKeyConstraint("id", name=op.f("pk_apprtag")), ) op.create_index("apprtag_lifetime_end", "apprtag", ["lifetime_end"], unique=False) op.create_index("apprtag_linked_tag_id", "apprtag", ["linked_tag_id"], unique=False) op.create_index("apprtag_manifest_list_id", "apprtag", ["manifest_list_id"], unique=False) op.create_index("apprtag_repository_id", "apprtag", ["repository_id"], unique=False) op.create_index( "apprtag_repository_id_name", "apprtag", ["repository_id", "name"], unique=False ) op.create_index( "apprtag_repository_id_name_hidden", "apprtag", ["repository_id", "name", "hidden"], unique=False, ) op.create_index( "apprtag_repository_id_name_lifetime_end", "apprtag", ["repository_id", "name", "lifetime_end"], unique=True, ) op.create_index("apprtag_tag_kind_id", "apprtag", ["tag_kind_id"], unique=False) # ### end Alembic commands ### conn = op.get_bind() copy_table_contents("blobplacementlocation", "apprblobplacementlocation", conn) copy_table_contents("tagkind", "apprtagkind", conn) # ### population of test data ### # tester.populate_table( "apprmanifest", [ ("digest", tester.TestDataType.String), ("media_type_id", tester.TestDataType.Foreign("mediatype")), ("manifest_json", tester.TestDataType.JSON), ], ) tester.populate_table( "apprmanifestlist", [ ("digest", tester.TestDataType.String), ("manifest_list_json", tester.TestDataType.JSON), ("schema_version", tester.TestDataType.String), ("media_type_id", tester.TestDataType.Foreign("mediatype")), ], ) tester.populate_table( "apprmanifestlistmanifest", [ ("manifest_list_id", tester.TestDataType.Foreign("apprmanifestlist")), ("manifest_id", tester.TestDataType.Foreign("apprmanifest")), ("operating_system", tester.TestDataType.String), ("architecture", tester.TestDataType.String), ("platform_json", tester.TestDataType.JSON), ("media_type_id", tester.TestDataType.Foreign("mediatype")), ], ) tester.populate_table( "apprblob", [ ("digest", tester.TestDataType.String), ("media_type_id", tester.TestDataType.Foreign("mediatype")), ("size", tester.TestDataType.BigInteger), ("uncompressed_size", tester.TestDataType.BigInteger), ], ) tester.populate_table( "apprmanifestblob", [ ("manifest_id", tester.TestDataType.Foreign("apprmanifest")), ("blob_id", tester.TestDataType.Foreign("apprblob")), ], ) tester.populate_table( "apprtag", [ ("name", tester.TestDataType.String), ("repository_id", tester.TestDataType.Foreign("repository")), ("manifest_list_id", tester.TestDataType.Foreign("apprmanifestlist")), ("lifetime_start", tester.TestDataType.Integer), ("hidden", tester.TestDataType.Boolean), ("reverted", tester.TestDataType.Boolean), ("protected", tester.TestDataType.Boolean), ("tag_kind_id", tester.TestDataType.Foreign("apprtagkind")), ], ) tester.populate_table( "apprblobplacement", [ ("blob_id", tester.TestDataType.Foreign("apprmanifestblob")), ("location_id", tester.TestDataType.Foreign("apprblobplacementlocation")), ], )
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table('tagkind', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_tagkind'))) op.create_index('tagkind_name', 'tagkind', ['name'], unique=True) op.create_table( 'manifestchild', sa.Column('id', sa.Integer(), nullable=False), sa.Column('repository_id', sa.Integer(), nullable=False), sa.Column('manifest_id', sa.Integer(), nullable=False), sa.Column('child_manifest_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['child_manifest_id'], ['manifest.id'], name=op.f('fk_manifestchild_child_manifest_id_manifest')), sa.ForeignKeyConstraint( ['manifest_id'], ['manifest.id'], name=op.f('fk_manifestchild_manifest_id_manifest')), sa.ForeignKeyConstraint( ['repository_id'], ['repository.id'], name=op.f('fk_manifestchild_repository_id_repository')), sa.PrimaryKeyConstraint('id', name=op.f('pk_manifestchild'))) op.create_index('manifestchild_child_manifest_id', 'manifestchild', ['child_manifest_id'], unique=False) op.create_index('manifestchild_manifest_id', 'manifestchild', ['manifest_id'], unique=False) op.create_index('manifestchild_manifest_id_child_manifest_id', 'manifestchild', ['manifest_id', 'child_manifest_id'], unique=True) op.create_index('manifestchild_repository_id', 'manifestchild', ['repository_id'], unique=False) op.create_index('manifestchild_repository_id_child_manifest_id', 'manifestchild', ['repository_id', 'child_manifest_id'], unique=False) op.create_index('manifestchild_repository_id_manifest_id', 'manifestchild', ['repository_id', 'manifest_id'], unique=False) op.create_index( 'manifestchild_repository_id_manifest_id_child_manifest_id', 'manifestchild', ['repository_id', 'manifest_id', 'child_manifest_id'], unique=False) op.create_table( 'tag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.Column('repository_id', sa.Integer(), nullable=False), sa.Column('manifest_id', sa.Integer(), nullable=True), sa.Column('lifetime_start_ms', sa.BigInteger(), nullable=False), sa.Column('lifetime_end_ms', sa.BigInteger(), nullable=True), sa.Column('hidden', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.Column('reversion', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.Column('tag_kind_id', sa.Integer(), nullable=False), sa.Column('linked_tag_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['linked_tag_id'], ['tag.id'], name=op.f('fk_tag_linked_tag_id_tag')), sa.ForeignKeyConstraint(['manifest_id'], ['manifest.id'], name=op.f('fk_tag_manifest_id_manifest')), sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], name=op.f('fk_tag_repository_id_repository')), sa.ForeignKeyConstraint(['tag_kind_id'], ['tagkind.id'], name=op.f('fk_tag_tag_kind_id_tagkind')), sa.PrimaryKeyConstraint('id', name=op.f('pk_tag'))) op.create_index('tag_lifetime_end_ms', 'tag', ['lifetime_end_ms'], unique=False) op.create_index('tag_linked_tag_id', 'tag', ['linked_tag_id'], unique=False) op.create_index('tag_manifest_id', 'tag', ['manifest_id'], unique=False) op.create_index('tag_repository_id', 'tag', ['repository_id'], unique=False) op.create_index('tag_repository_id_name', 'tag', ['repository_id', 'name'], unique=False) op.create_index('tag_repository_id_name_hidden', 'tag', ['repository_id', 'name', 'hidden'], unique=False) op.create_index('tag_repository_id_name_lifetime_end_ms', 'tag', ['repository_id', 'name', 'lifetime_end_ms'], unique=True) op.create_index('tag_repository_id_name_tag_kind_id', 'tag', ['repository_id', 'name', 'tag_kind_id'], unique=False) op.create_index('tag_tag_kind_id', 'tag', ['tag_kind_id'], unique=False) # ### end Alembic commands ### op.bulk_insert(tables.tagkind, [ { 'name': 'tag' }, ]) # ### population of test data ### # tester.populate_table('tag', [ ('repository_id', tester.TestDataType.Foreign('repository')), ('tag_kind_id', tester.TestDataType.Foreign('tagkind')), ('name', tester.TestDataType.String), ('manifest_id', tester.TestDataType.Foreign('manifest')), ('lifetime_start_ms', tester.TestDataType.BigInteger), ]) tester.populate_table('manifestchild', [ ('repository_id', tester.TestDataType.Foreign('repository')), ('manifest_id', tester.TestDataType.Foreign('manifest')), ('child_manifest_id', tester.TestDataType.Foreign('manifest')), ])
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "manifest", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("digest", sa.String(length=255), nullable=False), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.Column("manifest_bytes", sa.Text(), nullable=False), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_manifest_media_type_id_mediatype")), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifest_repository_id_repository")), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifest")), ) op.create_index("manifest_digest", "manifest", ["digest"], unique=False) op.create_index("manifest_media_type_id", "manifest", ["media_type_id"], unique=False) op.create_index("manifest_repository_id", "manifest", ["repository_id"], unique=False) op.create_index("manifest_repository_id_digest", "manifest", ["repository_id", "digest"], unique=True) op.create_index( "manifest_repository_id_media_type_id", "manifest", ["repository_id", "media_type_id"], unique=False, ) op.create_table( "manifestblob", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.Column("blob_index", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["blob_id"], ["imagestorage.id"], name=op.f("fk_manifestblob_blob_id_imagestorage")), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_manifestblob_manifest_id_manifest")), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifestblob_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestblob")), ) op.create_index("manifestblob_blob_id", "manifestblob", ["blob_id"], unique=False) op.create_index("manifestblob_manifest_id", "manifestblob", ["manifest_id"], unique=False) op.create_index("manifestblob_manifest_id_blob_id", "manifestblob", ["manifest_id", "blob_id"], unique=True) op.create_index( "manifestblob_manifest_id_blob_index", "manifestblob", ["manifest_id", "blob_index"], unique=True, ) op.create_index("manifestblob_repository_id", "manifestblob", ["repository_id"], unique=False) op.create_table( "manifestlabel", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("label_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint(["label_id"], ["label.id"], name=op.f("fk_manifestlabel_label_id_label")), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_manifestlabel_manifest_id_manifest")), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifestlabel_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlabel")), ) op.create_index("manifestlabel_label_id", "manifestlabel", ["label_id"], unique=False) op.create_index("manifestlabel_manifest_id", "manifestlabel", ["manifest_id"], unique=False) op.create_index( "manifestlabel_manifest_id_label_id", "manifestlabel", ["manifest_id", "label_id"], unique=True, ) op.create_index("manifestlabel_repository_id", "manifestlabel", ["repository_id"], unique=False) op.create_table( "manifestlegacyimage", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("image_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["image_id"], ["image.id"], name=op.f("fk_manifestlegacyimage_image_id_image")), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_manifestlegacyimage_manifest_id_manifest"), ), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifestlegacyimage_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlegacyimage")), ) op.create_index("manifestlegacyimage_image_id", "manifestlegacyimage", ["image_id"], unique=False) op.create_index("manifestlegacyimage_manifest_id", "manifestlegacyimage", ["manifest_id"], unique=True) op.create_index("manifestlegacyimage_repository_id", "manifestlegacyimage", ["repository_id"], unique=False) op.create_table( "tagmanifesttomanifest", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tag_manifest_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("broken", sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_tagmanifesttomanifest_manifest_id_manifest"), ), sa.ForeignKeyConstraint( ["tag_manifest_id"], ["tagmanifest.id"], name=op.f("fk_tagmanifesttomanifest_tag_manifest_id_tagmanifest"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_tagmanifesttomanifest")), ) op.create_index("tagmanifesttomanifest_broken", "tagmanifesttomanifest", ["broken"], unique=False) op.create_index("tagmanifesttomanifest_manifest_id", "tagmanifesttomanifest", ["manifest_id"], unique=True) op.create_index( "tagmanifesttomanifest_tag_manifest_id", "tagmanifesttomanifest", ["tag_manifest_id"], unique=True, ) op.create_table( "tagmanifestlabelmap", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tag_manifest_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=True), sa.Column("label_id", sa.Integer(), nullable=False), sa.Column("tag_manifest_label_id", sa.Integer(), nullable=False), sa.Column("manifest_label_id", sa.Integer(), nullable=True), sa.Column( "broken_manifest", sa.Boolean(), nullable=False, server_default=sa.sql.expression.false(), ), sa.ForeignKeyConstraint( ["label_id"], ["label.id"], name=op.f("fk_tagmanifestlabelmap_label_id_label")), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_tagmanifestlabelmap_manifest_id_manifest"), ), sa.ForeignKeyConstraint( ["manifest_label_id"], ["manifestlabel.id"], name=op.f( "fk_tagmanifestlabelmap_manifest_label_id_manifestlabel"), ), sa.ForeignKeyConstraint( ["tag_manifest_id"], ["tagmanifest.id"], name=op.f("fk_tagmanifestlabelmap_tag_manifest_id_tagmanifest"), ), sa.ForeignKeyConstraint( ["tag_manifest_label_id"], ["tagmanifestlabel.id"], name=op. f("fk_tagmanifestlabelmap_tag_manifest_label_id_tagmanifestlabel"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_tagmanifestlabelmap")), ) op.create_index( "tagmanifestlabelmap_broken_manifest", "tagmanifestlabelmap", ["broken_manifest"], unique=False, ) op.create_index("tagmanifestlabelmap_label_id", "tagmanifestlabelmap", ["label_id"], unique=False) op.create_index("tagmanifestlabelmap_manifest_id", "tagmanifestlabelmap", ["manifest_id"], unique=False) op.create_index( "tagmanifestlabelmap_manifest_label_id", "tagmanifestlabelmap", ["manifest_label_id"], unique=False, ) op.create_index( "tagmanifestlabelmap_tag_manifest_id", "tagmanifestlabelmap", ["tag_manifest_id"], unique=False, ) op.create_index( "tagmanifestlabelmap_tag_manifest_label_id", "tagmanifestlabelmap", ["tag_manifest_label_id"], unique=False, ) # ### end Alembic commands ### for media_type in DOCKER_SCHEMA1_CONTENT_TYPES: op.bulk_insert(tables.mediatype, [ { "name": media_type }, ]) # ### population of test data ### # tester.populate_table( "manifest", [ ("digest", tester.TestDataType.String), ("manifest_bytes", tester.TestDataType.JSON), ("media_type_id", tester.TestDataType.Foreign("mediatype")), ("repository_id", tester.TestDataType.Foreign("repository")), ], ) tester.populate_table( "manifestblob", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("repository_id", tester.TestDataType.Foreign("repository")), ("blob_id", tester.TestDataType.Foreign("imagestorage")), ("blob_index", tester.TestDataType.Integer), ], ) tester.populate_table( "manifestlabel", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("label_id", tester.TestDataType.Foreign("label")), ("repository_id", tester.TestDataType.Foreign("repository")), ], ) tester.populate_table( "manifestlegacyimage", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("image_id", tester.TestDataType.Foreign("image")), ("repository_id", tester.TestDataType.Foreign("repository")), ], ) tester.populate_table( "tagmanifesttomanifest", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("tag_manifest_id", tester.TestDataType.Foreign("tagmanifest")), ], ) tester.populate_table( "tagmanifestlabelmap", [ ("manifest_id", tester.TestDataType.Foreign("manifest")), ("tag_manifest_id", tester.TestDataType.Foreign("tagmanifest")), ("tag_manifest_label_id", tester.TestDataType.Foreign("tagmanifestlabel")), ("manifest_label_id", tester.TestDataType.Foreign("manifestlabel")), ("label_id", tester.TestDataType.Foreign("label")), ], )
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "manifestlayer", sa.Column("id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("manifest_index", sa.BigInteger(), nullable=False), sa.Column("metadata_json", UTF8LongText, nullable=False), sa.ForeignKeyConstraint(["blob_id"], ["blob.id"], name=op.f("fk_manifestlayer_blob_id_blob")), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_manifestlayer_manifest_id_manifest")), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlayer")), ) op.create_index("manifestlayer_manifest_index", "manifestlayer", ["manifest_index"], unique=False) op.create_index( "manifestlayer_manifest_id_manifest_index", "manifestlayer", ["manifest_id", "manifest_index"], unique=True, ) op.create_index("manifestlayer_manifest_id", "manifestlayer", ["manifest_id"], unique=False) op.create_index("manifestlayer_blob_id", "manifestlayer", ["blob_id"], unique=False) op.create_table( "manifestlayerscan", sa.Column("id", sa.Integer(), nullable=False), sa.Column("layer_id", sa.Integer(), nullable=False), sa.Column("scannable", sa.Boolean(), nullable=False), sa.Column("scanned_by", UTF8CharField(length=255), nullable=False), sa.ForeignKeyConstraint( ["layer_id"], ["manifestlayer.id"], name=op.f("fk_manifestlayerscan_layer_id_manifestlayer"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlayerscan")), ) op.create_index("manifestlayerscan_layer_id", "manifestlayerscan", ["layer_id"], unique=True) op.create_table( "bittorrentpieces", sa.Column("id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.Column("pieces", UTF8LongText, nullable=False), sa.Column("piece_length", sa.BigInteger(), nullable=False), sa.ForeignKeyConstraint(["blob_id"], ["blob.id"], name=op.f("fk_bittorrentpieces_blob_id_blob")), sa.PrimaryKeyConstraint("id", name=op.f("pk_bittorrentpieces")), ) op.create_index( "bittorrentpieces_blob_id_piece_length", "bittorrentpieces", ["blob_id", "piece_length"], unique=True, ) op.create_index("bittorrentpieces_blob_id", "bittorrentpieces", ["blob_id"], unique=False) op.create_table( "blobuploading", sa.Column("id", sa.Integer(), nullable=False), sa.Column("uuid", sa.String(length=255), nullable=False), sa.Column("created", sa.DateTime(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("location_id", sa.Integer(), nullable=False), sa.Column("byte_count", sa.BigInteger(), nullable=False), sa.Column("uncompressed_byte_count", sa.BigInteger(), nullable=True), sa.Column("chunk_count", sa.BigInteger(), nullable=False), sa.Column("storage_metadata", UTF8LongText, nullable=True), sa.Column("sha_state", UTF8LongText, nullable=True), sa.Column("piece_sha_state", UTF8LongText, nullable=True), sa.Column("piece_hashes", UTF8LongText, nullable=True), sa.ForeignKeyConstraint( ["location_id"], ["blobplacementlocation.id"], name=op.f("fk_blobuploading_location_id_blobplacementlocation"), ), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_blobuploading_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_blobuploading")), ) op.create_index("blobuploading_uuid", "blobuploading", ["uuid"], unique=True) op.create_index("blobuploading_repository_id_uuid", "blobuploading", ["repository_id", "uuid"], unique=True) op.create_index("blobuploading_repository_id", "blobuploading", ["repository_id"], unique=False) op.create_index("blobuploading_location_id", "blobuploading", ["location_id"], unique=False) op.create_index("blobuploading_created", "blobuploading", ["created"], unique=False) op.create_table( "manifestlayerdockerv1", sa.Column("id", sa.Integer(), nullable=False), sa.Column("manifest_layer_id", sa.Integer(), nullable=False), sa.Column("image_id", UTF8CharField(length=255), nullable=False), sa.Column("checksum", UTF8CharField(length=255), nullable=False), sa.Column("compat_json", UTF8LongText, nullable=False), sa.ForeignKeyConstraint( ["manifest_layer_id"], ["manifestlayer.id"], name=op.f( "fk_manifestlayerdockerv1_manifest_layer_id_manifestlayer"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlayerdockerv1")), ) op.create_index( "manifestlayerdockerv1_manifest_layer_id", "manifestlayerdockerv1", ["manifest_layer_id"], unique=False, ) op.create_index("manifestlayerdockerv1_image_id", "manifestlayerdockerv1", ["image_id"], unique=False) op.create_table( "manifestlabel", 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"], ["manifest.id"], name=op.f("fk_manifestlabel_annotated_id_manifest")), sa.ForeignKeyConstraint(["label_id"], ["label.id"], name=op.f("fk_manifestlabel_label_id_label")), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifestlabel_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestlabel")), ) op.create_index( "manifestlabel_repository_id_annotated_id_label_id", "manifestlabel", ["repository_id", "annotated_id", "label_id"], unique=True, ) op.create_index("manifestlabel_repository_id", "manifestlabel", ["repository_id"], unique=False) op.create_index("manifestlabel_label_id", "manifestlabel", ["label_id"], unique=False) op.create_index("manifestlabel_annotated_id", "manifestlabel", ["annotated_id"], unique=False) op.create_table( "blobplacementlocationpreference", sa.Column("id", sa.Integer(), nullable=False), sa.Column("user_id", sa.Integer(), nullable=False), sa.Column("location_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["location_id"], ["blobplacementlocation.id"], name=op.f("fk_blobplacementlocpref_locid_blobplacementlocation"), ), sa.ForeignKeyConstraint( ["user_id"], ["user.id"], name=op.f("fk_blobplacementlocationpreference_user_id_user")), sa.PrimaryKeyConstraint( "id", name=op.f("pk_blobplacementlocationpreference")), ) op.create_index( "blobplacementlocationpreference_user_id", "blobplacementlocationpreference", ["user_id"], unique=False, ) op.create_index( "blobplacementlocationpreference_location_id", "blobplacementlocationpreference", ["location_id"], unique=False, ) op.create_table( "derivedimage", sa.Column("id", sa.Integer(), nullable=False), sa.Column("uuid", sa.String(length=255), nullable=False), sa.Column("source_manifest_id", sa.Integer(), nullable=False), sa.Column("derived_manifest_json", UTF8LongText, nullable=False), sa.Column("media_type_id", sa.Integer(), nullable=False), sa.Column("blob_id", sa.Integer(), nullable=False), sa.Column("uniqueness_hash", sa.String(length=255), nullable=False), sa.Column("signature_blob_id", sa.Integer(), nullable=True), sa.ForeignKeyConstraint(["blob_id"], ["blob.id"], name=op.f("fk_derivedimage_blob_id_blob")), sa.ForeignKeyConstraint( ["media_type_id"], ["mediatype.id"], name=op.f("fk_derivedimage_media_type_id_mediatype"), ), sa.ForeignKeyConstraint( ["signature_blob_id"], ["blob.id"], name=op.f("fk_derivedimage_signature_blob_id_blob")), sa.ForeignKeyConstraint( ["source_manifest_id"], ["manifest.id"], name=op.f("fk_derivedimage_source_manifest_id_manifest"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_derivedimage")), ) op.create_index("derivedimage_uuid", "derivedimage", ["uuid"], unique=True) op.create_index("derivedimage_uniqueness_hash", "derivedimage", ["uniqueness_hash"], unique=True) op.create_index( "derivedimage_source_manifest_id_media_type_id_uniqueness_hash", "derivedimage", ["source_manifest_id", "media_type_id", "uniqueness_hash"], unique=True, ) op.create_index( "derivedimage_source_manifest_id_blob_id", "derivedimage", ["source_manifest_id", "blob_id"], unique=True, ) op.create_index("derivedimage_source_manifest_id", "derivedimage", ["source_manifest_id"], unique=False) op.create_index("derivedimage_signature_blob_id", "derivedimage", ["signature_blob_id"], unique=False) op.create_index("derivedimage_media_type_id", "derivedimage", ["media_type_id"], unique=False) op.create_index("derivedimage_blob_id", "derivedimage", ["blob_id"], unique=False)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "tagkind", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint("id", name=op.f("pk_tagkind")), ) op.create_index("tagkind_name", "tagkind", ["name"], unique=True) op.create_table( "manifestchild", sa.Column("id", sa.Integer(), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=False), sa.Column("child_manifest_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["child_manifest_id"], ["manifest.id"], name=op.f("fk_manifestchild_child_manifest_id_manifest"), ), sa.ForeignKeyConstraint( ["manifest_id"], ["manifest.id"], name=op.f("fk_manifestchild_manifest_id_manifest")), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], name=op.f("fk_manifestchild_repository_id_repository"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_manifestchild")), ) op.create_index("manifestchild_child_manifest_id", "manifestchild", ["child_manifest_id"], unique=False) op.create_index("manifestchild_manifest_id", "manifestchild", ["manifest_id"], unique=False) op.create_index( "manifestchild_manifest_id_child_manifest_id", "manifestchild", ["manifest_id", "child_manifest_id"], unique=True, ) op.create_index("manifestchild_repository_id", "manifestchild", ["repository_id"], unique=False) op.create_index( "manifestchild_repository_id_child_manifest_id", "manifestchild", ["repository_id", "child_manifest_id"], unique=False, ) op.create_index( "manifestchild_repository_id_manifest_id", "manifestchild", ["repository_id", "manifest_id"], unique=False, ) op.create_index( "manifestchild_repository_id_manifest_id_child_manifest_id", "manifestchild", ["repository_id", "manifest_id", "child_manifest_id"], unique=False, ) op.create_table( "tag", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.Column("repository_id", sa.Integer(), nullable=False), sa.Column("manifest_id", sa.Integer(), nullable=True), sa.Column("lifetime_start_ms", sa.BigInteger(), nullable=False), sa.Column("lifetime_end_ms", sa.BigInteger(), nullable=True), sa.Column("hidden", sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.Column("reversion", sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.Column("tag_kind_id", sa.Integer(), nullable=False), sa.Column("linked_tag_id", sa.Integer(), nullable=True), sa.ForeignKeyConstraint(["linked_tag_id"], ["tag.id"], name=op.f("fk_tag_linked_tag_id_tag")), sa.ForeignKeyConstraint(["manifest_id"], ["manifest.id"], name=op.f("fk_tag_manifest_id_manifest")), sa.ForeignKeyConstraint(["repository_id"], ["repository.id"], name=op.f("fk_tag_repository_id_repository")), sa.ForeignKeyConstraint(["tag_kind_id"], ["tagkind.id"], name=op.f("fk_tag_tag_kind_id_tagkind")), sa.PrimaryKeyConstraint("id", name=op.f("pk_tag")), ) op.create_index("tag_lifetime_end_ms", "tag", ["lifetime_end_ms"], unique=False) op.create_index("tag_linked_tag_id", "tag", ["linked_tag_id"], unique=False) op.create_index("tag_manifest_id", "tag", ["manifest_id"], unique=False) op.create_index("tag_repository_id", "tag", ["repository_id"], unique=False) op.create_index("tag_repository_id_name", "tag", ["repository_id", "name"], unique=False) op.create_index("tag_repository_id_name_hidden", "tag", ["repository_id", "name", "hidden"], unique=False) op.create_index( "tag_repository_id_name_lifetime_end_ms", "tag", ["repository_id", "name", "lifetime_end_ms"], unique=True, ) op.create_index( "tag_repository_id_name_tag_kind_id", "tag", ["repository_id", "name", "tag_kind_id"], unique=False, ) op.create_index("tag_tag_kind_id", "tag", ["tag_kind_id"], unique=False) # ### end Alembic commands ### op.bulk_insert(tables.tagkind, [ { "name": "tag" }, ]) # ### population of test data ### # tester.populate_table( "tag", [ ("repository_id", tester.TestDataType.Foreign("repository")), ("tag_kind_id", tester.TestDataType.Foreign("tagkind")), ("name", tester.TestDataType.String), ("manifest_id", tester.TestDataType.Foreign("manifest")), ("lifetime_start_ms", tester.TestDataType.BigInteger), ], ) tester.populate_table( "manifestchild", [ ("repository_id", tester.TestDataType.Foreign("repository")), ("manifest_id", tester.TestDataType.Foreign("manifest")), ("child_manifest_id", tester.TestDataType.Foreign("manifest")), ], )
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table('tagkind', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_tagkind'))) op.create_index('tagkind_name', 'tagkind', ['name'], unique=True) op.create_table( 'blobplacementlocation', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_blobplacementlocation'))) op.create_index('blobplacementlocation_name', 'blobplacementlocation', ['name'], unique=True) op.create_table( 'blob', sa.Column('id', sa.Integer(), nullable=False), sa.Column('digest', sa.String(length=255), nullable=False), sa.Column('media_type_id', sa.Integer(), nullable=False), sa.Column('size', sa.BigInteger(), nullable=False), sa.Column('uncompressed_size', sa.BigInteger(), nullable=True), sa.ForeignKeyConstraint(['media_type_id'], ['mediatype.id'], name=op.f('fk_blob_media_type_id_mediatype')), sa.PrimaryKeyConstraint('id', name=op.f('pk_blob'))) op.create_index('blob_digest', 'blob', ['digest'], unique=True) op.create_index('blob_media_type_id', 'blob', ['media_type_id'], unique=False) op.create_table( 'manifest', sa.Column('id', sa.Integer(), nullable=False), sa.Column('digest', sa.String(length=255), nullable=False), sa.Column('media_type_id', sa.Integer(), nullable=False), sa.Column('manifest_json', UTF8LongText, nullable=False), sa.ForeignKeyConstraint( ['media_type_id'], ['mediatype.id'], name=op.f('fk_manifest_media_type_id_mediatype')), sa.PrimaryKeyConstraint('id', name=op.f('pk_manifest'))) op.create_index('manifest_digest', 'manifest', ['digest'], unique=True) op.create_index('manifest_media_type_id', 'manifest', ['media_type_id'], unique=False) op.create_table( 'manifestlist', sa.Column('id', sa.Integer(), nullable=False), sa.Column('digest', sa.String(length=255), nullable=False), sa.Column('manifest_list_json', UTF8LongText, nullable=False), sa.Column('schema_version', UTF8CharField(length=255), nullable=False), sa.Column('media_type_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['media_type_id'], ['mediatype.id'], name=op.f('fk_manifestlist_media_type_id_mediatype')), sa.PrimaryKeyConstraint('id', name=op.f('pk_manifestlist'))) op.create_index('manifestlist_digest', 'manifestlist', ['digest'], unique=True) op.create_index('manifestlist_media_type_id', 'manifestlist', ['media_type_id'], unique=False) op.create_table( 'blobplacement', sa.Column('id', sa.Integer(), nullable=False), sa.Column('blob_id', sa.Integer(), nullable=False), sa.Column('location_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['blob_id'], ['blob.id'], name=op.f('fk_blobplacement_blob_id_blob')), sa.ForeignKeyConstraint( ['location_id'], ['blobplacementlocation.id'], name=op.f('fk_blobplacement_location_id_blobplacementlocation')), sa.PrimaryKeyConstraint('id', name=op.f('pk_blobplacement'))) op.create_index('blobplacement_blob_id', 'blobplacement', ['blob_id'], unique=False) op.create_index('blobplacement_blob_id_location_id', 'blobplacement', ['blob_id', 'location_id'], unique=True) op.create_index('blobplacement_location_id', 'blobplacement', ['location_id'], unique=False) op.create_table( 'manifestblob', sa.Column('id', sa.Integer(), nullable=False), sa.Column('manifest_id', sa.Integer(), nullable=False), sa.Column('blob_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['blob_id'], ['blob.id'], name=op.f('fk_manifestblob_blob_id_blob')), sa.ForeignKeyConstraint( ['manifest_id'], ['manifest.id'], name=op.f('fk_manifestblob_manifest_id_manifest')), sa.PrimaryKeyConstraint('id', name=op.f('pk_manifestblob'))) op.create_index('manifestblob_blob_id', 'manifestblob', ['blob_id'], unique=False) op.create_index('manifestblob_manifest_id', 'manifestblob', ['manifest_id'], unique=False) op.create_index('manifestblob_manifest_id_blob_id', 'manifestblob', ['manifest_id', 'blob_id'], unique=True) op.create_table( 'manifestlistmanifest', sa.Column('id', sa.Integer(), nullable=False), sa.Column('manifest_list_id', sa.Integer(), nullable=False), sa.Column('manifest_id', sa.Integer(), nullable=False), sa.Column('operating_system', UTF8CharField(length=255), nullable=True), sa.Column('architecture', UTF8CharField(length=255), nullable=True), sa.Column('platform_json', UTF8LongText, nullable=True), sa.Column('media_type_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['manifest_id'], ['manifest.id'], name=op.f('fk_manifestlistmanifest_manifest_id_manifest')), sa.ForeignKeyConstraint( ['manifest_list_id'], ['manifestlist.id'], name=op.f( 'fk_manifestlistmanifest_manifest_list_id_manifestlist')), sa.ForeignKeyConstraint( ['media_type_id'], ['mediatype.id'], name=op.f('fk_manifestlistmanifest_media_type_id_mediatype')), sa.PrimaryKeyConstraint('id', name=op.f('pk_manifestlistmanifest'))) op.create_index('manifestlistmanifest_manifest_id', 'manifestlistmanifest', ['manifest_id'], unique=False) op.create_index('manifestlistmanifest_manifest_list_id', 'manifestlistmanifest', ['manifest_list_id'], unique=False) op.create_index('manifestlistmanifest_manifest_listid_os_arch_mtid', 'manifestlistmanifest', [ 'manifest_list_id', 'operating_system', 'architecture', 'media_type_id' ], unique=False) op.create_index('manifestlistmanifest_manifest_listid_mtid', 'manifestlistmanifest', ['manifest_list_id', 'media_type_id'], unique=False) op.create_index('manifestlistmanifest_media_type_id', 'manifestlistmanifest', ['media_type_id'], unique=False) op.create_table( 'tag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', UTF8CharField(length=190), nullable=False), sa.Column('repository_id', sa.Integer(), nullable=False), sa.Column('manifest_list_id', sa.Integer(), nullable=True), sa.Column('lifetime_start', sa.BigInteger(), nullable=False), sa.Column('lifetime_end', sa.BigInteger(), nullable=True), sa.Column('hidden', sa.Boolean(), nullable=False), sa.Column('reverted', sa.Boolean(), nullable=False), sa.Column('protected', sa.Boolean(), nullable=False), sa.Column('tag_kind_id', sa.Integer(), nullable=False), sa.Column('linked_tag_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['linked_tag_id'], ['tag.id'], name=op.f('fk_tag_linked_tag_id_tag')), sa.ForeignKeyConstraint( ['manifest_list_id'], ['manifestlist.id'], name=op.f('fk_tag_manifest_list_id_manifestlist')), sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], name=op.f('fk_tag_repository_id_repository')), sa.ForeignKeyConstraint(['tag_kind_id'], ['tagkind.id'], name=op.f('fk_tag_tag_kind_id_tagkind')), sa.PrimaryKeyConstraint('id', name=op.f('pk_tag'))) op.create_index('tag_lifetime_end', 'tag', ['lifetime_end'], unique=False) op.create_index('tag_linked_tag_id', 'tag', ['linked_tag_id'], unique=False) op.create_index('tag_manifest_list_id', 'tag', ['manifest_list_id'], unique=False) op.create_index('tag_repository_id', 'tag', ['repository_id'], unique=False) op.create_index('tag_repository_id_name_hidden', 'tag', ['repository_id', 'name', 'hidden'], unique=False) op.create_index('tag_repository_id_name_lifetime_end', 'tag', ['repository_id', 'name', 'lifetime_end'], unique=True) op.create_index('tag_repository_id_name', 'tag', ['repository_id', 'name'], unique=False) op.create_index('tag_tag_kind_id', 'tag', ['tag_kind_id'], unique=False) # ### end Alembic commands ### blobplacementlocation_table = table( 'blobplacementlocation', column('id', sa.Integer()), column('name', sa.String()), ) op.bulk_insert( blobplacementlocation_table, [ { 'name': 'local_eu' }, { 'name': 'local_us' }, ], ) tagkind_table = table( 'tagkind', column('id', sa.Integer()), column('name', sa.String()), ) op.bulk_insert(tagkind_table, [ { 'id': 1, 'name': 'tag' }, { 'id': 2, 'name': 'release' }, { 'id': 3, 'name': 'channel' }, ])