]> git.lizzy.rs Git - cheatdb.git/blob - migrations/versions/b370c3eb4227_.py
Add Content Warnings
[cheatdb.git] / migrations / versions / b370c3eb4227_.py
1 """empty message
2
3 Revision ID: b370c3eb4227
4 Revises: c5e4213721dd
5 Create Date: 2020-07-17 19:22:15.267179
6
7 """
8 from alembic import op
9 import sqlalchemy as sa
10 from sqlalchemy import orm
11 from app.models import ContentWarning
12
13
14 # revision identifiers, used by Alembic.
15 revision = 'b370c3eb4227'
16 down_revision = 'c5e4213721dd'
17 branch_labels = None
18 depends_on = None
19
20
21 def upgrade():
22         # ### commands auto generated by Alembic - please adjust! ###
23         op.create_table('content_warning',
24         sa.Column('id', sa.Integer(), nullable=False),
25         sa.Column('name', sa.String(length=100), nullable=False),
26         sa.Column('title', sa.String(length=100), nullable=False),
27         sa.Column('description', sa.String(length=500), nullable=False),
28         sa.PrimaryKeyConstraint('id'),
29         sa.UniqueConstraint('name')
30         )
31         op.create_table('content_warnings',
32         sa.Column('content_warning_id', sa.Integer(), nullable=False),
33         sa.Column('package_id', sa.Integer(), nullable=False),
34         sa.ForeignKeyConstraint(['content_warning_id'], ['content_warning.id'], ),
35         sa.ForeignKeyConstraint(['package_id'], ['package.id'], ),
36         sa.PrimaryKeyConstraint('content_warning_id', 'package_id')
37         )
38
39         bind = op.get_bind()
40         session = orm.Session(bind=bind)
41
42         session.add(ContentWarning("Violence", "Non-cartoon violence"))
43         session.add(ContentWarning("Drugs", "Drugs or alcohol"))
44         session.add(ContentWarning("Bad Language"))
45         session.add(ContentWarning("Gambling"))
46         session.add(ContentWarning("Horror"))
47         session.commit()
48
49         # ### end Alembic commands ###
50
51
52 def downgrade():
53         # ### commands auto generated by Alembic - please adjust! ###
54         op.drop_table('content_warnings')
55         op.drop_table('content_warning')
56         # ### end Alembic commands ###