123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- """Add more non nullables
- Revision ID: 933bd7d807c4
- Revises: d87cea4e995d
- Create Date: 2017-05-04 11:44:16.146471
- """
- from alembic import op
- import sqlalchemy as sa
- import flaskbb
- # revision identifiers, used by Alembic.
- revision = '933bd7d807c4'
- down_revision = 'd87cea4e995d'
- branch_labels = ()
- depends_on = None
- def upgrade():
- connection = op.get_bind()
- # ### commands auto generated by Alembic - please adjust! ###
- with op.batch_alter_table('conversations', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- with op.batch_alter_table('forumsread', schema=None) as batch_op:
- batch_op.alter_column('last_read',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- # See https://github.com/sh4nks/flaskbb/issues/309
- if connection.engine.dialect.name == "mysql":
- op.execute('SET FOREIGN_KEY_CHECKS=0;')
- with op.batch_alter_table('groups_users', schema=None) as batch_op:
- batch_op.alter_column('group_id',
- existing_type=sa.INTEGER(),
- nullable=False)
- batch_op.alter_column('user_id',
- existing_type=sa.INTEGER(),
- nullable=False)
- # activate them again
- if connection.engine.dialect.name == "mysql":
- op.execute('SET FOREIGN_KEY_CHECKS=1;')
- with op.batch_alter_table('messages', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- with op.batch_alter_table('posts', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- with op.batch_alter_table('reports', schema=None) as batch_op:
- batch_op.alter_column('post_id',
- existing_type=sa.INTEGER(),
- nullable=True)
- batch_op.alter_column('reported',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- batch_op.alter_column('reporter_id',
- existing_type=sa.INTEGER(),
- nullable=True)
- with op.batch_alter_table('topics', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- batch_op.alter_column('important',
- existing_type=sa.BOOLEAN(),
- nullable=False)
- batch_op.alter_column('last_updated',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- batch_op.alter_column('locked',
- existing_type=sa.BOOLEAN(),
- nullable=False)
- batch_op.alter_column('post_count',
- existing_type=sa.INTEGER(),
- nullable=False)
- batch_op.alter_column('views',
- existing_type=sa.INTEGER(),
- nullable=False)
- with op.batch_alter_table('topicsread', schema=None) as batch_op:
- batch_op.alter_column('last_read',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- with op.batch_alter_table('users', schema=None) as batch_op:
- batch_op.alter_column('activated',
- existing_type=sa.BOOLEAN(),
- nullable=False)
- batch_op.alter_column('date_joined',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=False)
- batch_op.alter_column('login_attempts',
- existing_type=sa.INTEGER(),
- nullable=False)
- # ### end Alembic commands ###
- def downgrade():
- connection = op.get_bind()
- # ### commands auto generated by Alembic - please adjust! ###
- with op.batch_alter_table('users', schema=None) as batch_op:
- batch_op.alter_column('login_attempts',
- existing_type=sa.INTEGER(),
- nullable=True)
- batch_op.alter_column('date_joined',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- batch_op.alter_column('activated',
- existing_type=sa.BOOLEAN(),
- nullable=True)
- with op.batch_alter_table('topicsread', schema=None) as batch_op:
- batch_op.alter_column('last_read',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- with op.batch_alter_table('topics', schema=None) as batch_op:
- batch_op.alter_column('views',
- existing_type=sa.INTEGER(),
- nullable=True)
- batch_op.alter_column('post_count',
- existing_type=sa.INTEGER(),
- nullable=True)
- batch_op.alter_column('locked',
- existing_type=sa.BOOLEAN(),
- nullable=True)
- batch_op.alter_column('last_updated',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- batch_op.alter_column('important',
- existing_type=sa.BOOLEAN(),
- nullable=True)
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- with op.batch_alter_table('reports', schema=None) as batch_op:
- batch_op.alter_column('reporter_id',
- existing_type=sa.INTEGER(),
- nullable=False)
- batch_op.alter_column('reported',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- batch_op.alter_column('post_id',
- existing_type=sa.INTEGER(),
- nullable=False)
- with op.batch_alter_table('posts', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- with op.batch_alter_table('messages', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- if connection.engine.dialect.name == "mysql":
- op.execute('SET FOREIGN_KEY_CHECKS=0;')
- with op.batch_alter_table('groups_users', schema=None) as batch_op:
- batch_op.alter_column('user_id',
- existing_type=sa.INTEGER(),
- nullable=True)
- batch_op.alter_column('group_id',
- existing_type=sa.INTEGER(),
- nullable=True)
- if connection.engine.dialect.name == "mysql":
- op.execute('SET FOREIGN_KEY_CHECKS=1;')
- with op.batch_alter_table('forumsread', schema=None) as batch_op:
- batch_op.alter_column('last_read',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- with op.batch_alter_table('conversations', schema=None) as batch_op:
- batch_op.alter_column('date_created',
- existing_type=flaskbb.utils.database.UTCDateTime(timezone=True),
- nullable=True)
- # ### end Alembic commands ###
|