mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-13 23:29:02 +00:00
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:
@@ -15,34 +15,23 @@ down_revision = '3001f79b7722'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
TABLE_PREFIXES = ('nyaa', 'sukebei')
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('nyaa_comments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('torrent_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('text', sa.String(length=255, collation='utf8mb4_bin'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['torrent_id'], ['nyaa_torrents.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('sukebei_comments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('torrent_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('text', sa.String(length=255, collation='utf8mb4_bin'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['torrent_id'], ['sukebei_torrents.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
for prefix in TABLE_PREFIXES:
|
||||
op.create_table(prefix + '_comments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('torrent_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('text', sa.String(length=255, collation='utf8mb4_bin'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['torrent_id'], [prefix + '_torrents.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('nyaa_comments')
|
||||
op.drop_table('sukebei_comments')
|
||||
# ### end Alembic commands ###
|
||||
for prefix in TABLE_PREFIXES:
|
||||
op.drop_table(prefix + '_comments')
|
||||
|
||||
Reference in New Issue
Block a user