def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "elixhauserci", sa.Column( "congestive_heart_failure", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "cardiac_arrhythmias", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "valvular_disease", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "pulmonary_circulation_disorders", sa.Boolean(name=op.f("ck_elixhauserci_pulm_circ")), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "peripheral_vascular_disorders", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "hypertension_uncomplicated", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "hypertension_complicated", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "paralysis", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "other_neurological_disorders", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "chronic_pulmonary_disease", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "diabetes_uncomplicated", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "diabetes_complicated", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "hypothyroidism", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "renal_failure", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "liver_disease", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "peptic_ulcer_disease_exc_bleeding", sa.Boolean(name=op.f("ck_elixhauserci_peptic")), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "aids_hiv", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "lymphoma", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "metastatic_cancer", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "solid_tumor_without_metastasis", sa.Boolean(name=op.f("ck_elixhauserci_tumour_no_mets")), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "rheumatoid_arthritis_collagen_vascular_diseases", sa.Boolean(name=op.f("ck_elixhauserci_ra_cvd")), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "coagulopathy", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "obesity", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "weight_loss", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "fluid_electrolyte_disorders", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "blood_loss_anemia", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "deficiency_anemia", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "alcohol_abuse", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "drug_abuse", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "psychoses", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "depression", sa.Boolean(), nullable=True, comment="Disease present (0 no, 1 yes)", ), sa.Column( "patient_id", sa.Integer(), nullable=False, comment="(TASK) Foreign key to patient.id (for this device/era)", ), sa.Column( "clinician_specialty", sa.Text(), nullable=True, comment=( "(CLINICIAN) Clinician's specialty (e.g. Liaison Psychiatry)" ), ), sa.Column( "clinician_name", sa.Text(), nullable=True, comment="(CLINICIAN) Clinician's name (e.g. Dr X)", ), sa.Column( "clinician_professional_registration", sa.Text(), nullable=True, comment=( "(CLINICIAN) Clinician's professional registration (e.g. GMC#" " 12345)" ), ), sa.Column( "clinician_post", sa.Text(), nullable=True, comment="(CLINICIAN) Clinician's post (e.g. Consultant)", ), sa.Column( "clinician_service", sa.Text(), nullable=True, comment=( "(CLINICIAN) Clinician's service (e.g. Liaison Psychiatry" " Service)" ), ), sa.Column( "clinician_contact_details", sa.Text(), nullable=True, comment=( "(CLINICIAN) Clinician's contact details (e.g. bleep," " extension)" ), ), sa.Column( "when_created", PendulumDateTimeAsIsoTextColType(length=32), nullable=False, comment=( "(TASK) Date/time this task instance was created (ISO 8601)" ), ), sa.Column( "when_firstexit", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(TASK) Date/time of the first exit from this task (ISO 8601)" ), ), sa.Column( "firstexit_is_finish", sa.Boolean(), nullable=True, comment=( "(TASK) Was the first exit from the task because it was" " finished (1)?" ), ), sa.Column( "firstexit_is_abort", sa.Boolean(), nullable=True, comment=( "(TASK) Was the first exit from this task because it was" " aborted (1)?" ), ), sa.Column( "editing_time_s", sa.Float(), nullable=True, comment="(TASK) Time spent editing (s)", ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)" ), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)" ), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)" ), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)" ), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=( "(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?" ), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)" ), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)" ), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_elixhauserci__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_elixhauserci__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_elixhauserci__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op.f("fk_elixhauserci__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f("fk_elixhauserci__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_elixhauserci__removing_user_id"), ), sa.PrimaryKeyConstraint("_pk", name=op.f("pk_elixhauserci")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("elixhauserci", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix_elixhauserci__current"), ["_current"], unique=False ) batch_op.create_index( batch_op.f("ix_elixhauserci__device_id"), ["_device_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_elixhauserci__era"), ["_era"], unique=False ) batch_op.create_index( batch_op.f("ix_elixhauserci__group_id"), ["_group_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_elixhauserci__pk"), ["_pk"], unique=False ) batch_op.create_index( batch_op.f("ix_elixhauserci_id"), ["id"], unique=False ) batch_op.create_index( batch_op.f("ix_elixhauserci_patient_id"), ["patient_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_elixhauserci_when_last_modified"), ["when_last_modified"], unique=False, )
def upgrade(): op.create_table( "_task_schedule", sa.Column( "id", sa.Integer(), autoincrement=True, nullable=False, comment="Arbitrary primary key", ), sa.Column( "group_id", sa.Integer(), nullable=False, comment="FK to _security_groups.id", ), sa.Column("name", sa.UnicodeText(), nullable=True, comment="name"), sa.ForeignKeyConstraint( ["group_id"], ["_security_groups.id"], name=op.f("fk__task_schedule_group_id"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk__task_schedule")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) op.create_table( "_task_schedule_item", sa.Column( "id", sa.Integer(), autoincrement=True, nullable=False, comment="Arbitrary primary key", ), sa.Column( "schedule_id", sa.Integer(), nullable=False, comment="FK to _task_schedule.id", ), sa.Column( "task_table_name", sa.String(length=128), nullable=True, comment="Table name of the task's base table", ), sa.Column( "due_from", PendulumDurationAsIsoTextColType(length=29), nullable=True, comment=( "Relative time from the start date by which the task may be" " started" ), ), sa.Column( "due_by", PendulumDurationAsIsoTextColType(length=29), nullable=True, comment=( "Relative time from the start date by which the task must be" " completed" ), ), sa.ForeignKeyConstraint( ["schedule_id"], ["_task_schedule.id"], name=op.f("fk__task_schedule_item_schedule_id"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk__task_schedule_item")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("_task_schedule_item", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix__task_schedule_item_task_table_name"), ["task_table_name"], unique=False, ) op.create_table( "_patient_task_schedule", sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), sa.Column("patient_pk", sa.Integer(), nullable=True), sa.Column("schedule_id", sa.Integer(), nullable=True), sa.Column( "start_datetime", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "Schedule start date for the patient. Due from/within" " durations for a task schedule item are relative to this." ), ), sa.Column( "settings", JsonColType(), nullable=True, comment="Task-specific settings for this patient", ), sa.ForeignKeyConstraint( ["patient_pk"], ["patient._pk"], name=op.f("fk__patient_task_schedule_patient_pk"), ondelete="CASCADE", ), sa.ForeignKeyConstraint( ["schedule_id"], ["_task_schedule.id"], name=op.f("fk__patient_task_schedule_schedule_id"), ondelete="CASCADE", ), sa.PrimaryKeyConstraint("id", name=op.f("pk__patient_task_schedule")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "maas", sa.Column( "q1", sa.Integer(), nullable=True, comment=("Q1 (thinking about baby; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q2", sa.Integer(), nullable=True, comment=( "Q2 (strength of emotional feelings; 1 least attachment - 5" " most attachment)"), ), sa.Column( "q3", sa.Integer(), nullable=True, comment=("Q3 (feelings about baby, negative to positive; 1 least" " attachment - 5 most attachment)"), ), sa.Column( "q4", sa.Integer(), nullable=True, comment=( "Q4 (desire for info; 1 least attachment - 5 most attachment)" ), ), sa.Column( "q5", sa.Integer(), nullable=True, comment=( "Q5 (picturing baby; 1 least attachment - 5 most attachment)"), ), sa.Column( "q6", sa.Integer(), nullable=True, comment=("Q6 (baby's personhood; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q7", sa.Integer(), nullable=True, comment=("Q7 (baby depends on me; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q8", sa.Integer(), nullable=True, comment=( "Q8 (talking to baby; 1 least attachment - 5 most attachment)" ), ), sa.Column( "q9", sa.Integer(), nullable=True, comment=( "Q9 (thoughts, irritation to tender/loving; 1 least attachment" " - 5 most attachment)"), ), sa.Column( "q10", sa.Integer(), nullable=True, comment=( "Q10 (clarity of mental picture; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q11", sa.Integer(), nullable=True, comment=( "Q11 (emotions about baby, sad to happy; 1 least attachment -" " 5 most attachment)"), ), sa.Column( "q12", sa.Integer(), nullable=True, comment=( "Q12 (thoughts of punishing baby; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q13", sa.Integer(), nullable=True, comment=( "Q13 (emotionally distant or close; 1 least attachment - 5" " most attachment)"), ), sa.Column( "q14", sa.Integer(), nullable=True, comment="Q14 (good diet; 1 least attachment - 5 most attachment)", ), sa.Column( "q15", sa.Integer(), nullable=True, comment=( "Q15 (expectation of feelings after birth; 1 least attachment" " - 5 most attachment)"), ), sa.Column( "q16", sa.Integer(), nullable=True, comment=( "Q16 (would like to hold baby when; 1 least attachment - 5" " most attachment)"), ), sa.Column( "q17", sa.Integer(), nullable=True, comment=("Q17 (dreams about baby; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q18", sa.Integer(), nullable=True, comment=("Q18 (rubbing over baby; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "q19", sa.Integer(), nullable=True, comment=( "Q19 (feelings if pregnancy lost; 1 least attachment - 5 most" " attachment)"), ), sa.Column( "patient_id", sa.Integer(), nullable=False, comment="(TASK) Foreign key to patient.id (for this device/era)", ), sa.Column( "when_created", PendulumDateTimeAsIsoTextColType(length=32), nullable=False, comment=( "(TASK) Date/time this task instance was created (ISO 8601)"), ), sa.Column( "when_firstexit", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(TASK) Date/time of the first exit from this task (ISO 8601)" ), ), sa.Column( "firstexit_is_finish", sa.Boolean(), nullable=True, comment=("(TASK) Was the first exit from the task because it was" " finished (1)?"), ), sa.Column( "firstexit_is_abort", sa.Boolean(), nullable=True, comment=("(TASK) Was the first exit from this task because it was" " aborted (1)?"), ), sa.Column( "editing_time_s", sa.Float(), nullable=True, comment="(TASK) Time spent editing (s)", ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)"), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)"), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=("(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)"), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)"), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=("(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?"), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)"), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)"), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_maas__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_maas__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_maas__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op.f("fk_maas__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f("fk_maas__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_maas__removing_user_id"), ), sa.PrimaryKeyConstraint("_pk", name=op.f("pk_maas")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("maas", schema=None) as batch_op: batch_op.create_index(batch_op.f("ix_maas__current"), ["_current"], unique=False) batch_op.create_index(batch_op.f("ix_maas__device_id"), ["_device_id"], unique=False) batch_op.create_index(batch_op.f("ix_maas__era"), ["_era"], unique=False) batch_op.create_index(batch_op.f("ix_maas__group_id"), ["_group_id"], unique=False) batch_op.create_index(batch_op.f("ix_maas__pk"), ["_pk"], unique=False) batch_op.create_index(batch_op.f("ix_maas_id"), ["id"], unique=False) batch_op.create_index(batch_op.f("ix_maas_patient_id"), ["patient_id"], unique=False) batch_op.create_index( batch_op.f("ix_maas_when_last_modified"), ["when_last_modified"], unique=False, )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "chit", sa.Column( "q1", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q1 (hate unfinished task) (0 strongly disagree - 3 strongly" " agree)" ), ), sa.Column( "q2", sa.Integer(), nullable=True, comment="Q2 (just right) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q3", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q3 (keep doing task) (0 strongly disagree - 3 strongly agree)" ), ), sa.Column( "q4", sa.Integer(), nullable=True, comment="Q4 (get stuck) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q5", sa.Integer(), nullable=True, comment="Q5 (habit) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q6", sa.Integer(), nullable=True, comment="Q6 (addictive) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q7", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q7 (stubborn rigid) (0 strongly disagree - 3 strongly agree)" ), ), sa.Column( "q8", sa.Integer(), nullable=True, comment="Q8 (urges) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q9", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q9 (rewarding things) (0 strongly disagree - 3 strongly" " agree)" ), ), sa.Column( "q10", sa.Integer(), nullable=True, comment=( "Q10 (hard moving) (0 strongly disagree - 3 strongly agree)" ), ), sa.Column( "q11", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q11 (higher standards) (0 strongly disagree - 3 strongly" " agree)" ), ), sa.Column( "q12", sa.Integer(), nullable=True, comment=( "Q12 (improvement) (0 strongly disagree - 3 strongly agree)" ), ), sa.Column( "q13", sa.Integer(), nullable=True, comment="Q13 (complete) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q14", sa.Integer(), nullable=True, comment=( # noqa: E501 "Q14 (avoid situations) (0 strongly disagree - 3 strongly" " agree)" ), ), sa.Column( "q15", sa.Integer(), nullable=True, comment="Q15 (hobby) (0 strongly disagree - 3 strongly agree)", ), sa.Column( "q16", sa.Boolean(), nullable=True, comment="Q16 (negative effect) (0 no, 1 yes)", ), sa.Column( "patient_id", sa.Integer(), nullable=False, comment="(TASK) Foreign key to patient.id (for this device/era)", ), sa.Column( "clinician_specialty", sa.Text(), nullable=True, comment=( "(CLINICIAN) Clinician's specialty (e.g. Liaison Psychiatry)" ), ), sa.Column( "clinician_name", sa.Text(), nullable=True, comment="(CLINICIAN) Clinician's name (e.g. Dr X)", ), sa.Column( "clinician_professional_registration", sa.Text(), nullable=True, comment=( # noqa: E501 "(CLINICIAN) Clinician's professional registration (e.g. GMC#" " 12345)" ), ), sa.Column( "clinician_post", sa.Text(), nullable=True, comment="(CLINICIAN) Clinician's post (e.g. Consultant)", ), sa.Column( "clinician_service", sa.Text(), nullable=True, comment=( # noqa: E501 "(CLINICIAN) Clinician's service (e.g. Liaison Psychiatry" " Service)" ), ), sa.Column( "clinician_contact_details", sa.Text(), nullable=True, comment=( # noqa: E501 "(CLINICIAN) Clinician's contact details (e.g. bleep," " extension)" ), ), sa.Column( "when_created", PendulumDateTimeAsIsoTextColType(length=32), nullable=False, comment=( "(TASK) Date/time this task instance was created (ISO 8601)" ), ), sa.Column( "when_firstexit", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(TASK) Date/time of the first exit from this task (ISO 8601)" ), ), sa.Column( "firstexit_is_finish", sa.Boolean(), nullable=True, comment=( # noqa: E501 "(TASK) Was the first exit from the task because it was" " finished (1)?" ), ), sa.Column( "firstexit_is_abort", sa.Boolean(), nullable=True, comment=( # noqa: E501 "(TASK) Was the first exit from this task because it was" " aborted (1)?" ), ), sa.Column( "editing_time_s", sa.Float(), nullable=True, comment="(TASK) Time spent editing (s)", ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( # noqa: E501 "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)" ), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( # noqa: E501 "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)" ), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( # noqa: E501 "(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)" ), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( # noqa: E501 "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)" ), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=( # noqa: E501 "(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?" ), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( # noqa: E501 "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)" ), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( # noqa: E501 "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)" ), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_chit__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_chit__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_chit__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op.f("fk_chit__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f("fk_chit__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_chit__removing_user_id"), ), sa.PrimaryKeyConstraint("_pk", name=op.f("pk_chit")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("chit", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix_chit__current"), ["_current"], unique=False ) batch_op.create_index( batch_op.f("ix_chit__device_id"), ["_device_id"], unique=False ) batch_op.create_index( batch_op.f("ix_chit__era"), ["_era"], unique=False ) batch_op.create_index( batch_op.f("ix_chit__group_id"), ["_group_id"], unique=False ) batch_op.create_index(batch_op.f("ix_chit__pk"), ["_pk"], unique=False) batch_op.create_index(batch_op.f("ix_chit_id"), ["id"], unique=False) batch_op.create_index( batch_op.f("ix_chit_patient_id"), ["patient_id"], unique=False ) batch_op.create_index( batch_op.f("ix_chit_when_last_modified"), ["when_last_modified"], unique=False, )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "khandaker_mojo_medication_item", sa.Column( "medicationtable_id", sa.Integer(), nullable=False, comment="FK to medicationtable", ), sa.Column( "seqnum", sa.Integer(), nullable=False, comment="Sequence number of this medication", ), sa.Column( "medication_name", sa.UnicodeText(), nullable=True, comment="Medication name", ), sa.Column( "chemical_name", sa.UnicodeText(), nullable=True, comment="Chemical name for study team", ), sa.Column("dose", sa.UnicodeText(), nullable=True, comment="Dose"), sa.Column("frequency", sa.UnicodeText(), nullable=True, comment="Frequency"), sa.Column( "duration_months", sa.Float(), nullable=True, comment="Duration (months)", ), sa.Column( "indication", sa.UnicodeText(), nullable=True, comment="Indication (what is the medication used for?)", ), sa.Column( "response", sa.Integer(), nullable=True, comment=("1 = treats all symptoms, 2 = most symptoms, 3 = some" " symptoms, 4 = no symptoms)"), ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)"), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)"), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=("(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)"), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)"), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=("(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?"), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)"), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)"), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_medication_item__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_khandaker_mojo_medication_item__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_khandaker_mojo_medication_item__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op.f( "fk_khandaker_mojo_medication_item__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_medication_item__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_medication_item__removing_user_id"), ), sa.PrimaryKeyConstraint( "_pk", name=op.f("pk_khandaker_mojo_medication_item")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("khandaker_mojo_medication_item", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item__current"), ["_current"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item__device_id"), ["_device_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item__era"), ["_era"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item__group_id"), ["_group_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item__pk"), ["_pk"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item_id"), ["id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medication_item_when_last_modified"), ["when_last_modified"], unique=False, ) op.create_table( "khandaker_mojo_medicationtherapy", sa.Column( "patient_id", sa.Integer(), nullable=False, comment="(TASK) Foreign key to patient.id (for this device/era)", ), sa.Column( "when_created", PendulumDateTimeAsIsoTextColType(length=32), nullable=False, comment=( "(TASK) Date/time this task instance was created (ISO 8601)"), ), sa.Column( "when_firstexit", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(TASK) Date/time of the first exit from this task (ISO 8601)" ), ), sa.Column( "firstexit_is_finish", sa.Boolean(), nullable=True, comment=("(TASK) Was the first exit from the task because it was" " finished (1)?"), ), sa.Column( "firstexit_is_abort", sa.Boolean(), nullable=True, comment=("(TASK) Was the first exit from this task because it was" " aborted (1)?"), ), sa.Column( "editing_time_s", sa.Float(), nullable=True, comment="(TASK) Time spent editing (s)", ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)"), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)"), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=("(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)"), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)"), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=("(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?"), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)"), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)"), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_medicationtherapy__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_khandaker_mojo_medicationtherapy__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_khandaker_mojo_medicationtherapy__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op. f("fk_khandaker_mojo_medicationtherapy__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f( "fk_khandaker_mojo_medicationtherapy__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_medicationtherapy__removing_user_id"), ), sa.PrimaryKeyConstraint( "_pk", name=op.f("pk_khandaker_mojo_medicationtherapy")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("khandaker_mojo_medicationtherapy", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy__current"), ["_current"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy__device_id"), ["_device_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy__era"), ["_era"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy__group_id"), ["_group_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy__pk"), ["_pk"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy_id"), ["id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_medicationtherapy_patient_id"), ["patient_id"], unique=False, ) batch_op.create_index( batch_op.f( "ix_khandaker_mojo_medicationtherapy_when_last_modified"), ["when_last_modified"], unique=False, ) op.create_table( "khandaker_mojo_therapy_item", sa.Column( "medicationtable_id", sa.Integer(), nullable=False, comment="FK to medicationtable", ), sa.Column( "seqnum", sa.Integer(), nullable=False, comment="Sequence number of this therapy", ), sa.Column("therapy", sa.UnicodeText(), nullable=True, comment="Therapy"), sa.Column("frequency", sa.UnicodeText(), nullable=True, comment="Frequency"), sa.Column( "sessions_completed", sa.Integer(), nullable=True, comment="Sessions completed", ), sa.Column( "sessions_planned", sa.Integer(), nullable=True, comment="Total number of sessions planned", ), sa.Column( "indication", sa.UnicodeText(), nullable=True, comment="Indication (what is the medication used for?)", ), sa.Column( "response", sa.Integer(), nullable=True, comment=("1 = treats all symptoms, 2 = most symptoms, 3 = some" " symptoms, 4 = no symptoms)"), ), sa.Column( "_pk", sa.Integer(), autoincrement=True, nullable=False, comment="(SERVER) Primary key (on the server)", ), sa.Column( "_device_id", sa.Integer(), nullable=False, comment="(SERVER) ID of the source tablet device", ), sa.Column( "_era", sa.String(length=32), nullable=False, comment=( "(SERVER) 'NOW', or when this row was preserved and removed" " from the source device (UTC ISO 8601)"), ), sa.Column( "_current", sa.Boolean(), nullable=False, comment="(SERVER) Is the row current (1) or not (0)?", ), sa.Column( "_when_added_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time this row was added (ISO 8601)", ), sa.Column( "_when_added_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that added this row" " (DATETIME in UTC)"), ), sa.Column( "_adding_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that added this row", ), sa.Column( "_when_removed_exact", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=("(SERVER) Date/time this row was removed, i.e. made not" " current (ISO 8601)"), ), sa.Column( "_when_removed_batch_utc", sa.DateTime(), nullable=True, comment=( "(SERVER) Date/time of the upload batch that removed this row" " (DATETIME in UTC)"), ), sa.Column( "_removing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that removed this row", ), sa.Column( "_preserving_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that preserved this row", ), sa.Column( "_forcibly_preserved", sa.Boolean(), nullable=True, comment=("(SERVER) Forcibly preserved by superuser (rather than" " normally preserved by tablet)?"), ), sa.Column( "_predecessor_pk", sa.Integer(), nullable=True, comment="(SERVER) PK of predecessor record, prior to modification", ), sa.Column( "_successor_pk", sa.Integer(), nullable=True, comment=( "(SERVER) PK of successor record (after modification) or NULL" " (whilst live, or after deletion)"), ), sa.Column( "_manually_erased", sa.Boolean(), nullable=True, comment="(SERVER) Record manually erased (content destroyed)?", ), sa.Column( "_manually_erased_at", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment="(SERVER) Date/time of manual erasure (ISO 8601)", ), sa.Column( "_manually_erasing_user_id", sa.Integer(), nullable=True, comment="(SERVER) ID of user that erased this row manually", ), sa.Column( "_camcops_version", SemanticVersionColType(length=147), nullable=True, comment="(SERVER) CamCOPS version number of the uploading device", ), sa.Column( "_addition_pending", sa.Boolean(), nullable=False, comment="(SERVER) Addition pending?", ), sa.Column( "_removal_pending", sa.Boolean(), nullable=True, comment="(SERVER) Removal pending?", ), sa.Column( "_group_id", sa.Integer(), nullable=False, comment="(SERVER) ID of group to which this record belongs", ), sa.Column( "id", sa.Integer(), nullable=False, comment="(TASK) Primary key (task ID) on the tablet device", ), sa.Column( "when_last_modified", PendulumDateTimeAsIsoTextColType(length=32), nullable=True, comment=( "(STANDARD) Date/time this row was last modified on the source" " tablet device (ISO 8601)"), ), sa.Column( "_move_off_tablet", sa.Boolean(), nullable=True, comment="(SERVER/TABLET) Record-specific preservation pending?", ), sa.ForeignKeyConstraint( ["_adding_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_therapy_item__adding_user_id"), ), sa.ForeignKeyConstraint( ["_device_id"], ["_security_devices.id"], name=op.f("fk_khandaker_mojo_therapy_item__device_id"), ), sa.ForeignKeyConstraint( ["_group_id"], ["_security_groups.id"], name=op.f("fk_khandaker_mojo_therapy_item__group_id"), ), sa.ForeignKeyConstraint( ["_manually_erasing_user_id"], ["_security_users.id"], name=op.f( "fk_khandaker_mojo_therapy_item__manually_erasing_user_id"), ), sa.ForeignKeyConstraint( ["_preserving_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_therapy_item__preserving_user_id"), ), sa.ForeignKeyConstraint( ["_removing_user_id"], ["_security_users.id"], name=op.f("fk_khandaker_mojo_therapy_item__removing_user_id"), ), sa.PrimaryKeyConstraint("_pk", name=op.f("pk_khandaker_mojo_therapy_item")), mysql_charset="utf8mb4 COLLATE utf8mb4_unicode_ci", mysql_engine="InnoDB", mysql_row_format="DYNAMIC", ) with op.batch_alter_table("khandaker_mojo_therapy_item", schema=None) as batch_op: batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item__current"), ["_current"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item__device_id"), ["_device_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item__era"), ["_era"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item__group_id"), ["_group_id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item__pk"), ["_pk"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item_id"), ["id"], unique=False, ) batch_op.create_index( batch_op.f("ix_khandaker_mojo_therapy_item_when_last_modified"), ["when_last_modified"], unique=False, )