Make consent_to_research nullable

It should be nullable so we can tell whether someone has answered the
question already or not.

No real users have entered data into this column yet, so it’s fine to
wipe it.
This commit is contained in:
Chris Hill-Scott
2019-03-01 13:53:02 +00:00
parent 27a0ac289b
commit b27bcc1d80
3 changed files with 74 additions and 3 deletions

View File

@@ -0,0 +1,71 @@
"""
Revision ID: 0277_consent_to_research_null
Revises: 0266_user_folder_perms_table
Create Date: 2019-03-01 13:47:15.720238
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0277_consent_to_research_null'
down_revision = '0266_user_folder_perms_table'
def upgrade():
op.alter_column(
'services',
'consent_to_research',
existing_type=sa.BOOLEAN(),
nullable=True,
server_default=sa.null(),
)
op.alter_column(
'services_history',
'consent_to_research',
existing_type=sa.BOOLEAN(),
nullable=True,
server_default=sa.null(),
)
op.execute("""
UPDATE
services
SET
consent_to_research = null
""")
op.execute("""
UPDATE
services_history
SET
consent_to_research = null
""")
def downgrade():
op.execute("""
UPDATE
services
SET
consent_to_research = false
""")
op.execute("""
UPDATE
services_history
SET
consent_to_research = false
""")
op.alter_column(
'services_history',
'consent_to_research',
existing_type=sa.BOOLEAN(),
nullable=False,
server_default=sa.false(),
)
op.alter_column(
'services',
'consent_to_research',
existing_type=sa.BOOLEAN(),
nullable=False,
server_default=sa.false(),
)