diff --git a/data/migrations/versions/509d2857566f_track_the_lifetime_start_and_end_for_.py b/data/migrations/versions/509d2857566f_track_the_lifetime_start_and_end_for_.py new file mode 100644 index 000000000..41d8bf3c2 --- /dev/null +++ b/data/migrations/versions/509d2857566f_track_the_lifetime_start_and_end_for_.py @@ -0,0 +1,36 @@ +"""Track the lifetime start and end for tags to allow the state of a repository to be rewound. + +Revision ID: 509d2857566f +Revises: 1d2d86d09fcd +Create Date: 2015-02-13 14:35:38.939049 + +""" + +# revision identifiers, used by Alembic. +revision = '509d2857566f' +down_revision = '1d2d86d09fcd' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('repositorytag', sa.Column('lifetime_end_ts', sa.Integer(), nullable=True)) + op.add_column('repositorytag', sa.Column('lifetime_start_ts', sa.Integer(), nullable=False)) + op.create_index('repositorytag_lifetime_end_ts', 'repositorytag', ['lifetime_end_ts'], unique=False) + op.drop_index('repositorytag_repository_id_name', table_name='repositorytag') + op.create_index('repositorytag_repository_id_name', 'repositorytag', ['repository_id', 'name'], unique=False) + op.add_column('user', sa.Column('removed_tag_expiration_s', sa.Integer(), nullable=False)) + ### end Alembic commands ### + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('user', 'removed_tag_expiration_s') + op.drop_index('repositorytag_repository_id_name', table_name='repositorytag') + op.create_index('repositorytag_repository_id_name', 'repositorytag', ['repository_id', 'name'], unique=True) + op.drop_index('repositorytag_lifetime_end_ts', table_name='repositorytag') + op.drop_column('repositorytag', 'lifetime_start_ts') + op.drop_column('repositorytag', 'lifetime_end_ts') + ### end Alembic commands ### diff --git a/test/data/test.db b/test/data/test.db index 977469f56..544a04df7 100644 Binary files a/test/data/test.db and b/test/data/test.db differ diff --git a/util/backfill_user_uuids.py b/util/backfill_user_uuids.py index ab9ca4567..e71ec82a2 100644 --- a/util/backfill_user_uuids.py +++ b/util/backfill_user_uuids.py @@ -15,7 +15,7 @@ def backfill_user_uuids(): # Check to see if any users are missing uuids. has_missing_uuids = True try: - User.select().where(User.uuid >> None).get() + User.select(User.id).where(User.uuid >> None).get() except User.DoesNotExist: has_missing_uuids = False @@ -39,9 +39,9 @@ def backfill_user_uuids(): for user_id in batch_user_ids: with app.config['DB_TRANSACTION_FACTORY'](db): try: - user = User.get(User.id == user_id) + user = User.select(User.id, User.uuid).where(User.id == user_id).get() user.uuid = str(uuid.uuid4()) - user.save() + user.save(only=[User.uuid]) except User.DoesNotExist: pass