diff options
author | Rasmus Luha <rasmus.luha@gmail.com> | 2022-02-24 02:57:29 +0200 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@gmail.com> | 2022-02-24 02:57:29 +0200 |
commit | 3ce694bbebb9c24606e83f8923ca8055b7c9c63d (patch) | |
tree | 79bdc75a28eadabb18fb65978f0dec914eea546d /alembic/versions/4fa455e8771b_auto_add_votes_table.py | |
parent | f1ab105a7620160c16d7c91bdf3ca1cff6deef7c (diff) |
Added Alembic stuff
Diffstat (limited to 'alembic/versions/4fa455e8771b_auto_add_votes_table.py')
-rw-r--r-- | alembic/versions/4fa455e8771b_auto_add_votes_table.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/alembic/versions/4fa455e8771b_auto_add_votes_table.py b/alembic/versions/4fa455e8771b_auto_add_votes_table.py new file mode 100644 index 0000000..6c60f85 --- /dev/null +++ b/alembic/versions/4fa455e8771b_auto_add_votes_table.py @@ -0,0 +1,34 @@ +"""auto-add Votes table + +Revision ID: 4fa455e8771b +Revises: f60bfe68b20f +Create Date: 2022-02-24 02:53:06.350609 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '4fa455e8771b' +down_revision = 'f60bfe68b20f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('votes', + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('post_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('user_id', 'post_id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('votes') + # ### end Alembic commands ### |