diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2015-09-11 18:28:12 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:46:30 +0100 |
commit | 462f6d3b21558ed0a283c24e0e0332eac6ccbbb3 (patch) | |
tree | 451c583b5f47bbf6e38743881c66f2f27371bd82 /migrations | |
parent | moving the root of source code from / to /src/ (diff) | |
download | newspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.tar.gz newspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.tar.bz2 newspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.zip |
base modification in model for category support
Diffstat (limited to 'migrations')
-rw-r--r-- | migrations/versions/3f83bfe93fc_adding_category.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/migrations/versions/3f83bfe93fc_adding_category.py b/migrations/versions/3f83bfe93fc_adding_category.py new file mode 100644 index 00000000..bd65a01f --- /dev/null +++ b/migrations/versions/3f83bfe93fc_adding_category.py @@ -0,0 +1,42 @@ +"""adding category + +Revision ID: 3f83bfe93fc +Revises: 25ca960a207 +Create Date: 2015-09-01 14:15:04.212563 +""" + +# revision identifiers, used by Alembic. +revision = '3f83bfe93fc' +down_revision = '25ca960a207' + +import conf +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.create_table('category', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), + sa.PrimaryKeyConstraint('id')) + op.add_column('article', + sa.Column('category_id', sa.Integer(), nullable=True)) + op.add_column('feed', + sa.Column('category_id', sa.Integer(), nullable=True)) + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.create_foreign_key(None, 'article', 'category', + ['category_id'], ['id']) + op.create_foreign_key(None, 'feed', 'category', + ['category_id'], ['id']) + + +def downgrade(): + if 'sqlite' not in conf.SQLALCHEMY_DATABASE_URI: + op.drop_constraint(None, 'feed', type_='foreignkey') + op.drop_constraint(None, 'feed', type_='foreignkey') + op.drop_column('feed', 'category_id') + op.drop_constraint(None, 'article', type_='foreignkey') + op.drop_column('article', 'category_id') + op.drop_table('category') |