contentdb/migrations/versions/3f5836a3df5c_.py

38 lines
1011 B
Python
Raw Normal View History

2020-12-04 23:35:22 +01:00
"""empty message
Revision ID: 3f5836a3df5c
Revises: b3c7ff6655af
Create Date: 2020-12-04 22:30:33.420071
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import text
2020-12-04 23:35:22 +01:00
# revision identifiers, used by Alembic.
revision = '3f5836a3df5c'
down_revision = 'b3c7ff6655af'
branch_labels = None
depends_on = None
def upgrade():
op.alter_column('user', 'password',
existing_type=sa.VARCHAR(length=255),
nullable=True,
existing_server_default=sa.text("''::character varying"))
op.execute(text("""
2020-12-04 23:35:22 +01:00
UPDATE "user" SET password=NULL WHERE password=''
"""))
2020-12-04 23:35:22 +01:00
op.create_check_constraint("CK_password", "user",
"password IS NULL OR password != ''")
def downgrade():
op.drop_constraint("CK_password", "user", type_="check")
op.alter_column('user', 'password',
existing_type=sa.VARCHAR(length=255),
nullable=False,
existing_server_default=sa.text("''::character varying"))