"""Set translations not null

Revision ID: 58e7f2fc7ff7
Revises: 0ab02337f372
Create Date: 2017-03-09 10:23:37.343117

"""

# revision identifiers, used by Alembic.
revision = '58e7f2fc7ff7'
down_revision = '0ab02337f372'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("UPDATE translated_string SET base_string='' WHERE base_string is NULL")
    op.alter_column('translated_string', 'base_string',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET comment='' WHERE comment is NULL")
    op.alter_column('translated_string', 'comment',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET context='' WHERE context is NULL")
    op.alter_column('translated_string', 'context',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET translation='' WHERE translation is NULL")
    op.alter_column('translated_string', 'translation',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET translator_comment='' WHERE translator_comment is NULL")
    op.alter_column('translated_string', 'translator_comment',
               existing_type=sa.TEXT(),
               nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('translated_string', 'translator_comment',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'translation',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'context',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'comment',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'base_string',
               existing_type=sa.TEXT(),
               nullable=True)
    # ### end Alembic commands ###
