Add initial database state for Alembic, update existing migrations

Existing migrations will apply changes to both Nyaa and Sukebei
(adjusted manually - in the future Alembic should be able to create operations
for both, thanks to having both models loaded)

Added a down_revision for previously-earliest revision.
This commit is contained in:
TheAMM
2017-05-27 17:40:53 +03:00
parent 1b3e05339d
commit 6f9341d3f1
3 changed files with 189 additions and 35 deletions

View File

@@ -11,20 +11,19 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3001f79b7722'
down_revision = None
down_revision = '97ddefed1834'
branch_labels = None
depends_on = None
TABLE_PREFIXES = ('nyaa', 'sukebei')
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('nyaa_torrents', sa.Column('uploader_ip', sa.Binary(), nullable=True))
op.add_column('sukebei_torrents', sa.Column('uploader_ip', sa.Binary(), nullable=True))
# ### end Alembic commands ###
for prefix in TABLE_PREFIXES:
op.add_column(prefix + '_torrents', sa.Column('uploader_ip', sa.Binary(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('nyaa_torrents', 'uploader_ip')
op.drop_column('sukebei_torrents', 'uploader_ip')
# ### end Alembic commands ###
for prefix in TABLE_PREFIXES:
op.drop_column(prefix + '_torrents', 'uploader_ip')