def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('job_signup',
                            '301 工作表',
                            existing_comment='302 提交工作记录表',
                            schema=None)
    op.drop_column('job_signup', 'status')
Beispiel #2
0
def upgrade():
    op.add_column(
        'planning_areas',
        sa.Column('order_of_appearance_in_list', sa.Integer(), nullable=True))
    op.create_unique_constraint(
        'unique_list_order_for_fire_centre_constraint', 'planning_areas',
        ['order_of_appearance_in_list', 'fire_centre_id'])
    op.create_table_comment(
        'planning_areas',
        'Only one planning area can be assigned a position in the list for a fire centre',
        existing_comment=None,
        schema=None)

    # Load json file with planning areas order data
    with open(
            'alembic/versions/6d2f4d058ebc_add_column_for_order_of_appearance_in_.json'
    ) as json_file:
        planning_areas_order_data = json.load(json_file)

    fire_centres = planning_areas_order_data['fire_centres']
    for centre in fire_centres:
        for _, values in centre.items():
            for area in values['zones']:
                for pa_key in area:
                    planning_area_name = '\'' + pa_key + '\''
                    order = area[pa_key]['order_of_appearance_in_list']

                    op.execute(
                        'UPDATE planning_areas SET order_of_appearance_in_list = {} WHERE name LIKE {}'
                        .format(order, planning_area_name))
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('grade',
                            '年级班级表',
                            existing_comment=None,
                            schema=None)
    op.alter_column('staff',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'grade_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student_parent',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('teacher',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.add_column(
        'users',
        sa.Column('sex', sa.Integer(), nullable=True, comment='性别 1男  0女'))
Beispiel #4
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment(
        '__crypto_ohlc_daily',
        '外部データソースから取得したチャート',
        existing_comment=None,
        schema=None
    )
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('teacher',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment=None,
                    existing_comment='',
                    existing_nullable=True)
    op.alter_column('student_parent',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment=None,
                    existing_comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment=None,
                    existing_comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'grade_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment=None,
                    existing_comment='',
                    existing_nullable=True)
    op.alter_column('staff',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment=None,
                    existing_comment='',
                    existing_nullable=True)
    op.create_table_comment('menu',
                            '菜单权限表',
                            existing_comment='菜单表',
                            schema=None)
    op.add_column(
        'access',
        sa.Column('access_id',
                  mysql.INTEGER(display_width=11),
                  autoincrement=False,
                  nullable=True,
                  comment='权限ID'))
    op.drop_table_comment('access', existing_comment='权限表', schema=None)
    op.alter_column('access',
                    'user_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    comment='用户ID',
                    existing_comment='创建用户',
                    existing_nullable=True)
    op.drop_column('access', 'url')
    op.drop_column('access', 'status')
    op.drop_column('access', 'sort')
    op.drop_column('access', 'name')
    op.drop_column('access', 'is_del')
    op.drop_column('access', 'create_at')
    op.drop_table('user_access')
Beispiel #6
0
 def test_create_table_comment(self):
     # this is handled by SQLAlchemy's compilers
     context = op_fixture("oracle")
     op.create_table_comment(
         't2',
         comment='t2 table',
         schema='foo'
     )
     context.assert_(
         "COMMENT ON TABLE foo.t2 IS 't2 table'"
     )
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'job_signup',
        sa.Column('status',
                  sa.SmallInteger(),
                  nullable=True,
                  comment='状态 1-已报名 2-已录用 3-已到岗 4-已结算'))
    op.create_table_comment('job_signup',
                            '302 提交工作记录表',
                            existing_comment='301 工作表',
                            schema=None)
Beispiel #8
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('characters',
                            'A table for characters names',
                            existing_comment=None,
                            schema=None)
    op.create_index('name', 'characters', ['name'], unique=True)
    op.create_index('id', 'characters', ['char_id'], unique=True)
    op.drop_index(op.f('ix_characters_name'), table_name='characters')
    op.drop_index(op.f('ix_characters_char_id'), table_name='characters')
    op.create_table_comment(
        'character_moves',
        'A table for the moves of the characters of TEKKEN 7',
        existing_comment=None,
        schema=None)
    op.alter_column('character_moves',
                    'character',
                    existing_type=mysql.VARCHAR(charset='utf8mb4',
                                                collation='utf8mb4_0900_ai_ci',
                                                length=32),
                    nullable=False)
Beispiel #9
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('volunteer_info',
                            'Volunteer-specific information',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment('users',
                            'Information that is provided by all participants',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment('runner_info',
                            'Runner-specific information',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment(
        'question_responses',
        'responses to the questions in the questions table',
        existing_comment=None,
        schema=None)
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('runner_seed',
                            'currently unused',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment(
        'race_result',
        "Association table between races and users, each record holds a single user's time for one race",
        existing_comment=None,
        schema=None)
    op.create_table_comment(
        'group_member',
        'association between tournament and user for group members',
        existing_comment=None,
        schema=None)
Beispiel #11
0
 def test_create_table_comment(self):
     # this is handled by SQLAlchemy's compilers
     context = op_fixture("mysql")
     op.create_table_comment("t2", comment="t2 table", schema="foo")
     context.assert_("ALTER TABLE foo.t2 COMMENT 't2 table'")
Beispiel #12
0
def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "supervision_violated_condition_entry_history_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "This primary key should not be used. It only exists because SQLAlchemy requires every table to have a unique primary key.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The U.S. state or region that provided the source data.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "condition",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The specific condition of supervision which was violated.",
        existing_nullable=False,
    )
    op.drop_table_comment(
        "state_supervision_violated_condition_entry",
        existing_comment=
        "The StateSupervisionViolatedConditionEntry object represents a particular condition of supervision which was violated by a particular supervision violation. Each supervision violation has zero to many violated conditions. For example, a violation may be recorded because a brand new charge has been brought against the supervised person.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry",
        "supervision_violated_condition_entry_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision violated condition entry, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to others.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The U.S. state or region that provided the source data.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry",
        "condition",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The specific condition of supervision which was violated.",
        existing_nullable=False,
    )
    op.drop_table_comment(
        "state_supervision_sentence_supervision_period_association",
        existing_comment=
        "Association table that connects supervision sentences with supervision periods by their ids.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_sentence_supervision_period_association",
        "supervision_sentence_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision sentence, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision sentence information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_supervision_period_association",
        "supervision_period_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision period information.",
        existing_nullable=True,
    )
    op.drop_table_comment(
        "state_supervision_sentence_incarceration_period_association",
        existing_comment=
        "Association table that connects supervision sentences with incarceration periods by their ids.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_sentence_incarceration_period_association",
        "supervision_sentence_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision sentence, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision sentence information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_incarceration_period_association",
        "incarceration_period_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) incarceration period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant incarceration period information.",
        existing_nullable=True,
    )
    op.drop_table_comment(
        "state_supervision_sentence_history",
        existing_comment=
        "Represents all updates that have made to a(n) StateSupervisionSentence object over time.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "supervision_type_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The raw text value of the type of supervision the person is being sentenced to.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "supervision_type",
        existing_type=postgresql.ENUM(
            "CIVIL_COMMITMENT",
            "EXTERNAL_UNKNOWN",
            "INTERNAL_UNKNOWN",
            "HALFWAY_HOUSE",
            "PAROLE",
            "POST_CONFINEMENT",
            "PRE_CONFINEMENT",
            "PROBATION",
            name="state_supervision_type",
        ),
        comment=None,
        existing_comment=
        "The type of supervision the person is being sentenced to.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "supervision_sentence_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision sentence, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision sentence information.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "supervision_sentence_history_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "This primary key should not be used. It only exists because SQLAlchemy requires every table to have a unique primary key.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "status_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The raw text value of the current status of this sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "status",
        existing_type=postgresql.ENUM(
            "COMMUTED",
            "COMPLETED",
            "EXTERNAL_UNKNOWN",
            "PARDONED",
            "PRESENT_WITHOUT_INFO",
            "REVOKED",
            "SERVING",
            "SUSPENDED",
            "VACATED",
            name="state_sentence_status",
        ),
        comment=None,
        existing_comment="The current status of this sentence.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The U.S. state or region that provided the source data.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "start_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment="The date the person started serving the sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "projected_completion_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The earliest projected date the person may have completed their supervision.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "min_length_days",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment="Minimum duration of this sentence in days.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "max_length_days",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment="Maximum duration of this sentence in days.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "external_id",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The unique identifier for the StateSupervisionSentence, unique within the scope of the source data system.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "date_imposed",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The date this sentence was imposed, e.g. the date of actual sentencing, but not necessarily the date the person started serving the sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "county_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The code of the county under whose jurisdiction the sentence was imposed.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "completion_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The date the person actually did complete their supervision.",
        existing_nullable=True,
    )
    op.drop_table_comment(
        "state_supervision_sentence",
        existing_comment=
        "The StateSupervisionSentence object represents information about a single sentence to a period of supervision imposed as part of a group of related sentences. Multiple distinct, related sentences to supervision should be captured as separate supervision sentence objects within the same group. These sentences may, for example, be concurrent or consecutive to one another. Like the sentence group above, the supervision sentence represents only the imposition of some sentence terms, not an actual period of supervision experienced by the person.<br /><br />A StateSupervisionSentence object can reference many charges, and each charge can reference many sentences -- the relationship is many:many.<br /><br />A StateSupervisionSentence can have multiple child StateSupervisionPeriods. It can also have child StateIncarcerationPeriods since a sentence to supervision may result in a person's parole being revoked and the person being re-incarcerated, for example. In some jurisdictions, this would be modeled as distinct sentences of supervision and incarceration, but this is not universal.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_sentence",
        "supervision_type_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The raw text value of the type of supervision the person is being sentenced to.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "supervision_type",
        existing_type=postgresql.ENUM(
            "CIVIL_COMMITMENT",
            "EXTERNAL_UNKNOWN",
            "INTERNAL_UNKNOWN",
            "HALFWAY_HOUSE",
            "PAROLE",
            "POST_CONFINEMENT",
            "PRE_CONFINEMENT",
            "PROBATION",
            name="state_supervision_type",
        ),
        comment=None,
        existing_comment=
        "The type of supervision the person is being sentenced to.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "supervision_sentence_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision sentence, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to others.",
        existing_nullable=False,
        autoincrement=True,
        existing_server_default=sa.text(
            "nextval('state_supervision_sentence_supervision_sentence_id_seq'::regclass)"
        ),
    )
    op.alter_column(
        "state_supervision_sentence",
        "status_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The raw text value of the current status of this sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "status",
        existing_type=postgresql.ENUM(
            "COMMUTED",
            "COMPLETED",
            "EXTERNAL_UNKNOWN",
            "PARDONED",
            "PRESENT_WITHOUT_INFO",
            "REVOKED",
            "SERVING",
            "SUSPENDED",
            "VACATED",
            name="state_sentence_status",
        ),
        comment=None,
        existing_comment="The current status of this sentence.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The U.S. state or region that provided the source data.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence",
        "start_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment="The date the person started serving the sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "projected_completion_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The earliest projected date the person may have completed their supervision.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "min_length_days",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment="Minimum duration of this sentence in days.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "max_length_days",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment="Maximum duration of this sentence in days.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "external_id",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The unique identifier for the StateSupervisionSentence, unique within the scope of the source data system.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "date_imposed",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The date this sentence was imposed, e.g. the date of actual sentencing, but not necessarily the date the person started serving the sentence.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "county_code",
        existing_type=sa.VARCHAR(length=255),
        comment=None,
        existing_comment=
        "The code of the county under whose jurisdiction the sentence was imposed.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence",
        "completion_date",
        existing_type=sa.DATE(),
        comment=None,
        existing_comment=
        "The date the person actually did complete their supervision.",
        existing_nullable=True,
    )
    op.drop_table_comment(
        "state_supervision_period_supervision_violation_association",
        existing_comment=
        "Association table that connects supervision periods with supervision violations by their ids.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_period_supervision_violation_association",
        "supervision_violation_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision violation, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision violation information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_period_supervision_violation_association",
        "supervision_period_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision period information.",
        existing_nullable=True,
    )
    op.drop_table_comment(
        "state_supervision_period_supervision_contact_association",
        existing_comment=
        "Association table that connects supervision periods with supervision contacts by their ids.",
        schema=None,
    )
    op.alter_column(
        "state_supervision_period_supervision_contact_association",
        "supervision_period_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision period information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_period_supervision_contact_association",
        "supervision_contact_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision contact, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision contact information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_charge_supervision_sentence_association",
        "supervision_sentence_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) supervision sentence, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision sentence information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_charge_supervision_sentence_association",
        "charge_id",
        existing_type=sa.INTEGER(),
        comment=None,
        existing_comment=
        "Unique identifier for a(n) charge, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant charge information.",
        existing_nullable=True,
    )
    op.create_table_comment(
        "state_charge_incarceration_sentence_association",
        "Association table that connects charges with incarceration_sentences by their ids.",
        existing_comment=
        "Association table that connects charges with incarceration sentences by their ids.",
        schema=None,
    )
Beispiel #13
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'user_access', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True, comment='用户ID'),
        sa.Column('access_id', sa.Integer(), nullable=True, comment='权限ID'),
        sa.PrimaryKeyConstraint('id'))
    op.add_column(
        'access',
        sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'))
    op.add_column(
        'access',
        sa.Column('is_del', sa.Boolean(), nullable=True, comment='是否删除'))
    op.add_column(
        'access',
        sa.Column('name', sa.String(length=100), nullable=True,
                  comment='节点名称'))
    op.add_column('access',
                  sa.Column('sort', sa.Integer(), nullable=True, comment='排序'))
    op.add_column(
        'access', sa.Column('status',
                            sa.Integer(),
                            nullable=True,
                            comment='状态'))
    op.add_column(
        'access',
        sa.Column('url',
                  sa.String(length=200),
                  nullable=False,
                  comment='路由正则匹配'))
    op.alter_column('access',
                    'user_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    comment='创建用户',
                    existing_comment='用户ID',
                    existing_nullable=True)
    op.create_table_comment('access',
                            '权限表',
                            existing_comment=None,
                            schema=None)
    op.drop_column('access', 'access_id')
    op.create_table_comment('menu',
                            '菜单表',
                            existing_comment='菜单权限表',
                            schema=None)
    op.alter_column('staff',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'grade_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('student_parent',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
    op.alter_column('teacher',
                    'user_id',
                    existing_type=mysql.VARCHAR(length=50),
                    comment='',
                    existing_nullable=True)
Beispiel #14
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('job',
                            '300 工作表',
                            existing_comment=' 工作表',
                            schema=None)
Beispiel #15
0
def upgrade():
    op.create_table_comment(
        'document_type',
        'Lookup table that contains a list of inspection document types; i.e. Map, Report, Mine Manager Response, Image, Document, Final Report.'
    )
    op.create_table_comment(
        'inspected_location_type',
        'Lookup table that provides types of Areas Inspected and Observations relating to an inspection location details; i.e. general, stop. Stop = applied to Areas Inspected General = applied to General Observations Both General and Stop type observations may be applied to one or more orders, warnings, advisories, and requests… or a combination of them all.'
    )
    op.create_table_comment(
        'inspection_status',
        'Lookup table that contains a list of inspection statuses. For example; Complete, Incomplete.'
    )
    op.create_table_comment(
        'legislation_act',
        'Lookup table that contains a list of legislated Acts; i.e. "Mines Act", "Health, Safety and Reclamation Code for Mines in BC", "Mineral Tenure Act".'
    )
    op.create_table_comment(
        'legislation_compliance_article',
        'Contains the long description for each provision of the parent Act and is used to describe which part of the Act/Code was found to be in noncompliance during an inspection. Data for this table was derived through the values in the compliance_article table in the NRIS database. Note, each description is related to a corresponding legislation_act_section and parent Act. I.e. For section 1.9.1 of the HSRC, the description is ""The manager shall (1) take all reasonable and practicable measures to ensure that the workplace is free of potentially hazardous agents and conditions which could adversely affect the health, safety, or well-being of the workers'
    )
    op.create_table_comment(
        'location',
        'Contains the location details of stops added for General Observations and Areas Inspected. Location may include a general mine location or specific location details of where the infraction took place (i.e. tailings dam)'
    )
    op.create_table_comment(
        'nris_raw_data',
        'Contains the raw XML data pulled in from the CORS_CV_ASSESSMENTS_XVW view from the NRIS database. The nris_data is then parsed out into the relational based tables within the nris schema for easier reporting and data output.'
    )
    op.create_table_comment(
        'document',
        'A document is any type of additional documentation that has been generated during the INSPECTION process and is attached as part of the INSPECTION record. An example would be a photograph that was taken of the effluent being released during the inspection.'
    )
    op.create_table_comment(
        'inspection',
        'An inspection, otherwise known as a type of ASSESSMENT in NRIS, is an activity carried out by Mines Inspectors to ensure a Mine, and its relating mining activities, are in compliance with regulations in BC.'
    )
    op.create_table_comment(
        'inspection_type',
        'Categories of mine inspection types. This most directly related to the type of inspector and does not constrain potential resulting orders.'
    )
    op.create_table_comment(
        'legislation_act_section',
        'Contains a list of sections (or provisions of the act); i.e. "1.9.1", "1.5.1", etc.'
    )
    op.create_table_comment(
        'inspected_location',
        'Contains the high-level details of an observation(s) found during an inspection. Note, one observation is either a ""Stop"" or ""General"", each observation can result in one or more ""types of observations"", i.e. documents being issued (order, warning, advisory, request).'
    )
    op.create_table_comment(
        'inspection_document_xref',
        'Contains a reference between inspection documents and the details of the documents.'
    )
    op.create_table_comment(
        'inspected_location_document_xref',
        'Contains a reference between inspected location documents and the details of the documents.'
    )
    op.create_table_comment(
        'order_advisory_detail',
        'For each inspection observation, this table contains details of advisories issued by an inspector. An advisory is a written notification to a person that draws attention to a specific regulatory requirement. An advisory is used where the proponent is in compliance at the moment of inspection but may be at risk of future non-compliance.'
    )
    op.create_table_comment(
        'order_request_detail',
        'For each inspection observation, this table contains requests from the inspector to the Chief Gold Commissioner to issue an order under the Mineral Tenure Act or the Coal Act. Also included are responses to the issued orders.'
    )
    op.create_table_comment(
        'order_stop_detail',
        'For each inspection observation, this table contains details of an order issued by an inspector. An order is a written, legal instrument issued by an inspector to address non-compliance with a Regulatory Requirement and/or to reduce and manage risk. This is the most common C&E tool that will be used by inspectors in all disciplines.'
    )
    op.create_table_comment(
        'order_warning_detail',
        'For each inspection observation, this table contains details of a warning issued by an inspector.  A warning is a written notification to a person that is not in compliance with a specific Regulatory Requirement at the time of inspection.'
    )
    op.create_table_comment(
        'order_stop_detail_document_xref',
        'Contains a reference between order documents and the details of the documents.'
    )
    op.create_table_comment(
        'noncompliance_legislation',
        'Contains the additional details about the contravention(s) relating to an issued order; i.e. estimated incident date, noncompliance description, regulations/act contravened.'
    )
    op.create_table_comment(
        'noncompliance_permit',
        'For an issued order, this table contains the additional details about the permit conditions found to be in non-compliance.'
    )
def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "state_agent",
        "agent_id",
        type_=sa.INTEGER(),
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for an agent. If not specified, one will be generated.",
        existing_nullable=False,
        autoincrement=True,
        existing_server_default=sa.text(
            "nextval('state_agent_agent_id_seq'::regclass)"),
    )
    op.alter_column(
        "state_agent",
        "agent_type",
        existing_type=postgresql.ENUM(
            "CORRECTIONAL_OFFICER",
            "JUDGE",
            "PAROLE_BOARD_MEMBER",
            "SUPERVISION_OFFICER",
            "UNIT_SUPERVISOR",
            "PRESENT_WITHOUT_INFO",
            "INTERNAL_UNKNOWN",
            name="state_agent_type",
        ),
        comment="The type of agent.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_agent",
        "agent_type_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment="The raw text value of the agent type.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent",
        "external_id",
        existing_type=sa.VARCHAR(length=255),
        comment=
        "The  unique identifier for the StateAgent, unique within the scope of the source data system",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent",
        "full_name",
        existing_type=sa.VARCHAR(length=255),
        comment="The state agent's full name.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment="The state this agent operates in.",
        existing_nullable=False,
    )
    op.create_table_comment(
        "state_agent",
        "The StateAgent object represents some agent operating on behalf of the criminal justice system, usually referenced in the context of taking some action related to a person moving through that system. This includes references such as the judges trying cases, the officers supervising people on parole, the individuals who make a decision at a parole hearing, and so on. We entity match across StateAgents where possible so that we can see the full scope of actions taken by a particular agent to understand patterns in their behavior.",
        existing_comment=None,
        schema=None,
    )
    op.alter_column(
        "state_agent_history",
        "agent_history_id",
        type_=sa.INTEGER(),
        existing_type=sa.INTEGER(),
        comment=
        "This primary key should not be used. It only exists because SQLAlchemy requires every table to have a unique primary key.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.alter_column(
        "state_agent_history",
        "agent_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for an agent. If not specified, one will be generated.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_agent_history",
        "agent_type",
        existing_type=postgresql.ENUM(
            "CORRECTIONAL_OFFICER",
            "JUDGE",
            "PAROLE_BOARD_MEMBER",
            "SUPERVISION_OFFICER",
            "UNIT_SUPERVISOR",
            "PRESENT_WITHOUT_INFO",
            "INTERNAL_UNKNOWN",
            name="state_agent_type",
        ),
        comment="The type of agent.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_agent_history",
        "agent_type_raw_text",
        existing_type=sa.VARCHAR(length=255),
        comment="The raw text value of the agent type.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent_history",
        "external_id",
        existing_type=sa.VARCHAR(length=255),
        comment=
        "The  unique identifier for the StateAgent, unique within the scope of the source data system",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent_history",
        "full_name",
        existing_type=sa.VARCHAR(length=255),
        comment="The state agent's full name.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_agent_history",
        "state_code",
        existing_type=sa.VARCHAR(length=255),
        comment="The state this agent operates in.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_agent_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_agent_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_assessment_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_assessment_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_bond_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_bond_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_charge_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_charge_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_court_case_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_court_case_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_early_discharge_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_early_discharge_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_fine_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_fine_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_incarceration_incident_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_incarceration_incident_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_incarceration_incident_outcome_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_incarceration_incident_outcome_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_incarceration_period_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_incarceration_period_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_incarceration_sentence_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_incarceration_sentence_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_parole_decision_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_parole_decision_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_alias_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_person_alias_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_ethnicity_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_person_ethnicity_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_external_id_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_person_external_id_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_person_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_race_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_person_race_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_program_assignment_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_program_assignment_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_sentence_group_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_sentence_group_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_case_type_entry_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_case_type_entry_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_contact_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_contact_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_period_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_period_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_sentence_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violation_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_response_decision_entry_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violation_response_decision_entry_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_response_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violation_response_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_type_entry_history",
        "valid_from",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns started having the associated values.",
        existing_nullable=False,
    )
    op.alter_column(
        "state_supervision_violation_type_entry_history",
        "valid_to",
        existing_type=postgresql.TIMESTAMP(),
        comment=
        "Timestamp on which the columns stopped having the associated values.",
        existing_nullable=True,
    )
Beispiel #17
0
def test_alembic_scenario(alembic_table):
    """
    Exercise all of the operations we support.

    It's a little awkward because we have to avoid doing too many
    operations on the same table to avoid tripping over limits on
    table mods within a short time.
    """
    from alembic import op

    assert alembic_table("account") is None

    account = op.create_table(
        "account",
        Column("id", Integer, nullable=False),
        Column("name", String(50), nullable=False, comment="The name"),
        Column("description", String(200)),
    )
    assert alembic_table("account", "schema") == [
        "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
        "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
        "SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
    ]

    op.bulk_insert(
        account,
        [
            dict(id=1, name="home", description="the home account"),
            dict(id=2, name="operations", description="the ops account"),
            dict(id=3, name="savings", description=None),
        ],
    )

    assert alembic_table("account", "rows") == [
        {
            "description": "the home account",
            "id": 1,
            "name": "home"
        },
        {
            "description": "the ops account",
            "id": 2,
            "name": "operations"
        },
        {
            "description": None,
            "id": 3,
            "name": "savings"
        },
    ]

    op.add_column(
        "account",
        Column("last_transaction_date", DateTime, comment="when updated"))

    assert alembic_table("account", "schema") == [
        "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
        "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
        "SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
        "SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
        ", (), ())",
    ]

    op.create_table(
        "account_w_comment",
        Column("id", Integer, nullable=False),
        Column("name", String(50), nullable=False, comment="The name"),
        Column("description", String(200)),
        comment="This table has comments",
    )
    assert alembic_table(
        "account_w_comment").description == "This table has comments"
    op.drop_table_comment("account_w_comment")
    assert alembic_table("account_w_comment").description is None

    op.drop_column("account_w_comment", "description")
    assert alembic_table("account_w_comment", "schema") == [
        "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
        "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
    ]

    op.drop_table("account_w_comment")
    assert alembic_table("account_w_comment") is None

    op.rename_table("account", "accounts")
    assert alembic_table("account") is None
    assert alembic_table("accounts", "schema") == [
        "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
        "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
        "SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
        "SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
        ", (), ())",
    ]
    op.drop_table("accounts")
    assert alembic_table("accounts") is None

    op.execute("""
        create table transactions(
            account INT64 NOT NULL,
            transaction_time DATETIME NOT NULL,
            amount NUMERIC(11, 2) NOT NULL
            )
        partition by DATE(transaction_time)
        """)

    # The only thing we can alter about a column is we can make it
    # nullable:
    op.alter_column("transactions", "amount", True)
    assert alembic_table("transactions", "schema") == [
        "SchemaField('account', 'INTEGER', 'REQUIRED', None, (), ())",
        "SchemaField('transaction_time', 'DATETIME', 'REQUIRED', None, (), ())",
        "SchemaField('amount', 'NUMERIC(11, 2)', 'NULLABLE', None, (), ())",
    ]

    op.create_table_comment("transactions", "Transaction log")
    assert alembic_table("transactions").description == "Transaction log"

    op.drop_table("transactions")
Beispiel #18
0
    def test_create_table_comment_op(self):
        context = op_fixture()

        op.create_table_comment("some_table", "table comment")

        context.assert_("COMMENT ON TABLE some_table IS 'table comment'")
Beispiel #19
0
def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "state_incarceration_incident_history",
        "incarceration_incident_history_id",
        existing_type=sa.INTEGER(),
        comment=
        "This primary key should not be used. It only exists because SQLAlchemy requires every table to have a unique primary key.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.alter_column(
        "state_parole_decision",
        "incarceration_period_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) incarceration period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant incarceration period information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_parole_decision_history",
        "incarceration_period_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) incarceration period, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant incarceration period information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_person_external_id",
        "person_external_id_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) person external id, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to others.",
        existing_nullable=False,
        autoincrement=True,
    )
    op.create_table_comment(
        "state_supervision_period_program_assignment_association",
        "Association table that connects supervision periods with program assignments by their ids.",
        existing_comment=None,
        schema=None,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry",
        "supervision_violation_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) supervision violation, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision violation information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violated_condition_entry_history",
        "supervision_violation_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) supervision violation, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision violation information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_response_decision_agent_association",
        "agent_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) agent, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant agent information.",
        existing_nullable=True,
    )
    op.alter_column(
        "state_supervision_violation_response_decision_agent_association",
        "supervision_violation_response_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) violation response, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant violation response information.",
        existing_nullable=True,
    )
    op.create_table_comment(
        "state_supervision_violation_response_decision_agent_association",
        "Association table that connects supervision violation responses with agents by their ids.",
        existing_comment=None,
        schema=None,
    )
    op.alter_column(
        "state_supervision_violation_response_history",
        "supervision_violation_response_id",
        existing_type=sa.INTEGER(),
        comment=
        "Unique identifier for a(n) supervision violation response, generated automatically by the Recidiviz system. This identifier is not stable over time (it may change if historical data is re-ingested), but should be used within the context of a given dataset to connect this object to relevant supervision violation response information.",
        existing_nullable=False,
    )
def upgrade():
    # Rename current transaction.type enum
    op.execute("ALTER TYPE transaction_type RENAME TO tmp_transaction_type")
    # Create desired transaction.type enum
    desired_enum_type = postgresql.ENUM(*NEW_ENUM, name='transaction_type')
    connection = op.get_bind()
    desired_enum_type.create(connection, checkfirst=False)
    op.execute(ENUM_UPGRADE)
    # Alter transaction.type to use desired enum
    unwanted_enum_type = postgresql.ENUM(*OLD_ENUM,
                                         name='tmp_transaction_type')
    op.alter_column(
        'transaction',
        'type',
        existing_type=unwanted_enum_type,
        type_=desired_enum_type,
        postgresql_using="enum_upgrade(type::varchar)::transaction_type",
        comment=
        "One of ('RETURNCAP', 'SPLIT', 'SPINOFF', 'TRANSFER', 'TRADE', 'EXERCISE')"
    )
    # Clean up after ourselves
    unwanted_enum_type.drop(connection)
    op.execute("DROP FUNCTION enum_upgrade")

    op.alter_column(
        'transaction',
        'datetime',
        comment='Effective date/time: ex-date for reorgs, return of capital')
    op.alter_column(
        'transaction',
        'denominator',
        comment='For splits, spinoffs: normalized units of source security')
    op.alter_column('transaction',
                    'dtsettle',
                    comment='Settlement date: pay date for return of capital')
    op.alter_column(
        'transaction',
        'fiaccount_id',
        comment=
        'Financial institution account (for transfers, destination FI account) - FK fiaccount.id'
    )
    op.alter_column(
        'transaction',
        'fiaccountfrom_id',
        comment='For transfers: source FI account (FK fiaccount.id)')
    op.alter_column(
        'transaction',
        'numerator',
        comment='For splits, spinoffs: normalized units of destination security'
    )
    op.alter_column('transaction', 'security_id', comment='FK security.id')
    op.alter_column(
        'transaction',
        'securityfrom_id',
        comment=
        'For transfers, spinoffs, exercise: source security (FK security.id)')
    op.alter_column(
        'transaction',
        'securityfromprice',
        comment='For spinoffs: unit price used to fair-value source security')
    op.alter_column(
        'transaction',
        'securityprice',
        comment=
        'For spinoffs: unit price used to fair-value destination security')
    op.alter_column('transaction',
                    'sort',
                    comment='Sort algorithm for gain recognition')
    op.alter_column('transaction',
                    'uniqueid',
                    comment='FI transaction unique identifier')
    op.alter_column(
        'transaction',
        'units',
        comment=
        'Change in shares, contracts, etc. caused by Transaction (for splits, transfers, exercise: destination security change in units)'
    )
    op.alter_column(
        'transaction',
        'unitsfrom',
        comment=
        'For splits, transfers, exercise: source security change in units')
    op.create_table_comment('transaction', 'Securities Transactions')

    op.alter_column('currencyrate',
                    'fromcurrency',
                    comment='Currency of exchange rate denominator (ISO4217)')
    op.alter_column(
        'currencyrate',
        'rate',
        comment=
        'Multiply this rate by fromcurrency amount to yield tocurrency amount')
    op.alter_column('currencyrate',
                    'tocurrency',
                    comment='Currency of exchange rate numerator (ISO417)')
    op.create_table_comment('currencyrate',
                            'Exchange Rates for Currency Pairs')

    op.alter_column('fi',
                    'brokerid',
                    comment='OFX <INVACCTFROM><BROKERID> value')
    op.create_table_comment('fi', 'Financial Institution (e.g. Brokerage)')

    op.alter_column('fiaccount',
                    'fi_id',
                    comment='Financial institution (FK fi.id)')
    op.alter_column('fiaccount',
                    'number',
                    comment='account# (OFX <INVACCTFROM><ACCTID> value')
    op.create_table_comment('fiaccount',
                            'Financial Institution (e.g. Brokerage) Account')

    op.alter_column('securityid', 'security_id', comment='FK security.id')
    op.alter_column('securityid', 'uniqueid', comment='CUSIP, ISIN, etc.')
    op.alter_column('securityid', 'uniqueidtype', comment='CUSIP, ISIN, etc.')
    op.create_table_comment('securityid', 'Unique Identifiers for Securities')
Beispiel #21
0
 def test_create_table_comment(self):
     # this is handled by SQLAlchemy's compilers
     context = op_fixture("postgresql")
     op.create_table_comment("t2", comment="t2 table", schema="foo")
     context.assert_("COMMENT ON TABLE foo.t2 IS 't2 table'")
Beispiel #22
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('airflow_import_task_execution')
    op.drop_table('airflow_import_dag_execution')
    op.drop_table('airflow_execution_type')
    op.add_column(
        'airflow_custom_dags',
        sa.Column(
            'auto_regenerate_dag',
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'1'"),
            nullable=False,
            comment='1 = The DAG will be auto regenerated by manage command'))
    op.alter_column(
        'airflow_custom_dags',
        'operator_notes',
        existing_type=mysql.TEXT(),
        comment='Free text field to write a note about the custom DAG. ',
        existing_comment='Free text field to write a note about the import. ',
        existing_nullable=True)
    op.alter_column(
        'airflow_custom_dags',
        'retries',
        existing_type=mysql.INTEGER(display_width=11),
        comment=
        'How many retries should be Task do in Airflow before it failes',
        existing_nullable=False,
        existing_server_default=sa.text("'0'"))
    op.create_table_comment(
        'airflow_custom_dags',
        'Its possible to construct a DAG that have no import, export or ETL definitions in it, but instead just Tasks from the airflow_task table. That might nbe useful to for example run custom Hive Code after an import is completed as a separate DAG. Defining a DAG in here also requires you to have at least one task in airflow_tasks defined "in main"',
        existing_comment=None,
        schema=None)
    op.create_table_comment('airflow_dag_sensors',
                            'This table is used only in Legacy DBImport',
                            existing_comment=None,
                            schema=None)
    op.add_column(
        'airflow_etl_dags',
        sa.Column(
            'auto_regenerate_dag',
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'1'"),
            nullable=False,
            comment='1 = The DAG will be auto regenerated by manage command'))
    op.alter_column('airflow_etl_dags',
                    'filter_job',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='Filter string for JOB in etl_jobs table',
                    existing_nullable=False)
    op.alter_column('airflow_etl_dags',
                    'filter_source_db',
                    existing_type=mysql.VARCHAR(length=256),
                    comment='Filter string for SOURCE_DB in etl_jobs table',
                    existing_nullable=True)
    op.alter_column('airflow_etl_dags',
                    'filter_target_db',
                    existing_type=mysql.VARCHAR(length=256),
                    comment='Filter string for TARGET_DB in etl_jobs table',
                    existing_nullable=True)
    op.alter_column('airflow_etl_dags',
                    'filter_task',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='Filter string for TASK in etl_jobs table',
                    existing_nullable=True)
    op.alter_column(
        'airflow_etl_dags',
        'operator_notes',
        existing_type=mysql.TEXT(),
        comment='Free text field to write a note about the ETL job. ',
        existing_comment='Free text field to write a note about the import. ',
        existing_nullable=True)
    op.alter_column(
        'airflow_etl_dags',
        'retries',
        existing_type=mysql.TINYINT(display_width=4),
        comment=
        'How many retries should be Task do in Airflow before it failes',
        existing_nullable=True)
    op.alter_column('airflow_etl_dags',
                    'trigger_dag_on_success',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='<NOT USED>',
                    existing_nullable=True)
    op.create_table_comment(
        'airflow_etl_dags',
        'To create a DAG in Airflow for only ETL jobs, this is the table that holds all definitions of the DAG configuration, including the filter that defines what ETL jobs to run, schedules times, pool names and much more. ',
        existing_comment=None,
        schema=None)
    op.add_column(
        'airflow_export_dags',
        sa.Column(
            'auto_regenerate_dag',
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'1'"),
            nullable=False,
            comment='1 = The DAG will be auto regenerated by manage command'))
    op.alter_column(
        'airflow_export_dags',
        'operator_notes',
        existing_type=mysql.TEXT(),
        comment='Free text field to write a note about the export. ',
        existing_comment='Free text field to write a note about the import. ',
        existing_nullable=True)
    op.alter_column(
        'airflow_export_dags',
        'retries',
        existing_type=mysql.TINYINT(display_width=4),
        comment=
        'How many retries should be Task do in Airflow before it failes',
        existing_nullable=True)
    op.alter_column('airflow_export_dags',
                    'use_python_dbimport',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='Legacy use only. Always put this to 1',
                    existing_nullable=False,
                    existing_server_default=sa.text("'1'"))
    op.create_table_comment(
        'airflow_export_dags',
        'To create a DAG in Airflow for Exports, this is the table that holds all definitions of the DAG configuration, including the filter that defines what tables to export, schedules times, pool names and much more. ',
        existing_comment=None,
        schema=None)
    op.add_column(
        'airflow_import_dags',
        sa.Column(
            'auto_regenerate_dag',
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'1'"),
            nullable=False,
            comment='1 = The DAG will be auto regenerated by manage command'))
    op.add_column(
        'airflow_import_dags',
        sa.Column(
            'run_import_and_etl_separate',
            mysql.TINYINT(display_width=4),
            server_default=sa.text("'0'"),
            nullable=False,
            comment='1 = The Import and ETL phase will run in separate Tasks. '
        ))
    op.alter_column('airflow_import_dags',
                    'auto_table_discovery',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='<NOT USED>',
                    existing_nullable=False,
                    existing_server_default=sa.text("'1'"))
    op.alter_column(
        'airflow_import_dags',
        'finish_all_stage1_first',
        existing_type=mysql.TINYINT(display_width=4),
        comment=
        '1 = All Import phase jobs will be completed first, and when all is successfull, the ETL phase start',
        existing_nullable=False,
        existing_server_default=sa.text("'0'"))
    op.alter_column(
        'airflow_import_dags',
        'pool_stage1',
        existing_type=mysql.VARCHAR(length=256),
        comment=
        'Airflow pool used for stage1 tasks. NULL for the default Hostname pool',
        existing_comment=
        'Airflow pool used for stage1 tasks. NULL for default pool',
        existing_nullable=True)
    op.alter_column(
        'airflow_import_dags',
        'pool_stage2',
        existing_type=mysql.VARCHAR(length=256),
        comment=
        'Airflow pool used for stage2 tasks. NULL for the default DAG pool',
        existing_comment=
        'Airflow pool used for stage2 tasks. NULL for default pool',
        existing_nullable=True)
    op.alter_column(
        'airflow_import_dags',
        'retries',
        existing_type=mysql.TINYINT(display_width=4),
        comment=
        'How many retries should be Task do in Airflow before it failes',
        existing_nullable=False,
        existing_server_default=sa.text("'5'"))
    op.alter_column('airflow_import_dags',
                    'retries_stage1',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='Specific retries number for Import Phase',
                    existing_nullable=True)
    op.alter_column('airflow_import_dags',
                    'retries_stage2',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='Specific retries number for ETL Phase',
                    existing_nullable=True)
    op.alter_column('airflow_import_dags',
                    'use_python_dbimport',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='Legacy use only. Always put this to 1',
                    existing_nullable=False,
                    existing_server_default=sa.text("'1'"))
    op.create_table_comment(
        'airflow_import_dags',
        'To create a DAG in Airflow for Imports, this is the table that holds all definitions of the DAG configuration, including the filter that defines what tables to import, schedules times, pool names and much more.',
        existing_comment=None,
        schema=None)
    op.add_column(
        'airflow_tasks',
        sa.Column('sensor_connection',
                  sa.String(length=64),
                  nullable=True,
                  comment='Name of Connection in Airflow'))
    op.add_column(
        'airflow_tasks',
        sa.Column('sensor_poke_interval',
                  sa.Integer(),
                  nullable=True,
                  comment='Poke interval for sensors in seconds'))
    op.add_column(
        'airflow_tasks',
        sa.Column('sensor_timeout_minutes',
                  sa.Integer(),
                  nullable=True,
                  comment='Timeout for sensors in minutes'))
    op.alter_column('airflow_tasks',
                    'airflow_pool',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='Airflow Pool to use.',
                    existing_nullable=True)
    op.alter_column('airflow_tasks',
                    'airflow_priority',
                    existing_type=mysql.TINYINT(display_width=4),
                    comment='Airflow Priority. Higher number, higher priority',
                    existing_nullable=True)
    op.alter_column('airflow_tasks',
                    'dag_name',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='Name of DAG to add Tasks to',
                    existing_nullable=False)
    op.alter_column('airflow_tasks',
                    'hive_db',
                    existing_type=mysql.VARCHAR(length=256),
                    comment='<NOT USED>',
                    existing_nullable=True)
    op.alter_column(
        'airflow_tasks',
        'include_in_airflow',
        existing_type=mysql.TINYINT(display_width=4),
        comment=
        'Enable or disable the Task in the DAG during creation of DAG file.',
        existing_nullable=False,
        existing_server_default=sa.text("'1'"))
    op.alter_column('airflow_tasks',
                    'placement',
                    existing_type=mysql.ENUM('before main', 'after main',
                                             'in main'),
                    comment='Placement for the Task',
                    existing_nullable=False,
                    existing_server_default=sa.text("'after main'"))
    op.alter_column(
        'airflow_tasks',
        'task_config',
        existing_type=mysql.VARCHAR(length=256),
        comment=
        'The configuration for the Task. Depends on what Task type it is.',
        existing_nullable=True)
    op.alter_column(
        'airflow_tasks',
        'task_dependency_in_main',
        existing_type=mysql.VARCHAR(length=256),
        comment=
        'If placement is In Main, this defines a dependency for the Task. Comma separated list',
        existing_nullable=True)
    op.alter_column('airflow_tasks',
                    'task_name',
                    existing_type=mysql.VARCHAR(length=64),
                    comment='Name of the Task in Airflow',
                    existing_nullable=False)
    op.alter_column('airflow_tasks',
                    'task_type',
                    existing_type=mysql.ENUM('shell script', 'Hive SQL Script',
                                             'JDBC SQL'),
                    comment='The type of the Task',
                    existing_nullable=False,
                    existing_server_default=sa.text("'Hive SQL Script'"))
    op.create_table_comment(
        'airflow_tasks',
        'All DAGs can be customized by adding Tasks into the DAG. Depending on what placement and type of Tasks that is created, DBImport will add custom placeholders to keep the DAG separated in three different parts. Before, In and After Main. In main is where all regular Imports, export or ETL jobs are executed. If you want to execute something before these, you place it in Before Main. And if you want to execute something after, you place it in After main. Please check the Airflow Integration part of the documentation for more examples and better understanding of the data you can put into this table',
        existing_comment=None,
        schema=None)
    op.drop_constraint('airflow_tasks_ibfk_1',
                       'airflow_tasks',
                       type_='foreignkey')
    op.create_foreign_key('FK_airflow_tasks_jdbc_connections', 'airflow_tasks',
                          'jdbc_connections', ['jdbc_dbalias'], ['dbalias'])
    op.add_column(
        'export_tables',
        sa.Column('airflow_priority',
                  mysql.TINYINT(display_width=4),
                  nullable=True,
                  comment='This will set priority_weight in Airflow'))
    op.alter_column('export_tables',
                    'hive_javaheap',
                    existing_type=mysql.BIGINT(display_width=20),
                    comment='Heap size for Hive',
                    existing_nullable=True)
    op.alter_column('export_tables',
                    'table_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    comment='Unique identifier of the table',
                    existing_nullable=False,
                    autoincrement=True)
    op.alter_column('import_tables',
                    'table_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    comment='Unique identifier',
                    existing_nullable=False,
                    autoincrement=True)
Beispiel #23
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('voke', '??', existing_comment=None, schema=None)
    op.alter_column('voke',
                    'user_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=False)
    op.alter_column('voke',
                    'topic_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=False)
    op.create_table_comment('user',
                            '?????',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment('topic',
                            '????',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment('reply',
                            '????',
                            existing_comment=None,
                            schema=None)
    op.alter_column('reply',
                    'user_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=False)
    op.alter_column('reply',
                    'topic_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=False)
    op.create_table_comment('category',
                            '????',
                            existing_comment=None,
                            schema=None)
    op.create_table_comment('blogtype',
                            '???? - ????,????,????',
                            existing_comment=None,
                            schema=None)
Beispiel #24
0
 def test_create_table_comment(self):
     # this is handled by SQLAlchemy's compilers
     context = op_fixture("oracle")
     op.create_table_comment('t2', comment='t2 table', schema='foo')
     context.assert_("COMMENT ON TABLE foo.t2 IS 't2 table'")
Beispiel #25
0
    def test_create_table_comment_op(self):
        context = op_fixture()

        op.create_table_comment("some_table", "table comment")

        context.assert_("COMMENT ON TABLE some_table IS 'table comment'")
Beispiel #26
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table_comment('tickets',
                            'Tickets',
                            existing_comment=None,
                            schema=None)
    op.alter_column('tickets',
                    'ticket_no',
                    existing_type=sa.CHAR(length=13),
                    comment='Ticket number')
    op.alter_column('tickets',
                    'passenger_name',
                    existing_type=sa.TEXT(),
                    comment='Passenger name',
                    existing_nullable=False)
    op.alter_column('tickets',
                    'passenger_id',
                    existing_type=sa.VARCHAR(length=20),
                    comment='Passenger ID',
                    existing_nullable=False)
    op.alter_column('tickets',
                    'contact_data',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    comment='Passenger contact information',
                    existing_nullable=True)
    op.alter_column('tickets',
                    'book_ref',
                    existing_type=sa.CHAR(length=6),
                    comment='Booking number',
                    existing_nullable=False)
    op.create_table_comment('ticket_flights',
                            'Flight segment',
                            existing_comment=None,
                            schema=None)
    op.alter_column('ticket_flights',
                    'ticket_no',
                    existing_type=sa.CHAR(length=13),
                    comment='Ticket number')
    op.alter_column('ticket_flights',
                    'flight_id',
                    existing_type=sa.INTEGER(),
                    comment='Flight ID')
    op.alter_column('ticket_flights',
                    'fare_conditions',
                    existing_type=sa.VARCHAR(length=10),
                    comment='Travel class',
                    existing_nullable=False)
    op.alter_column('ticket_flights',
                    'amount',
                    existing_type=sa.NUMERIC(precision=10, scale=2),
                    comment='Travel cost',
                    existing_nullable=False)
    op.create_table_comment('seats',
                            'Seats',
                            existing_comment=None,
                            schema=None)
    op.drop_constraint('boarding_passes_ticket_no_fkey',
                       'seats',
                       type_='foreignkey')
    op.create_foreign_key('seats_aircraft_code_fkey',
                          'seats',
                          'aircrafts_data', ['aircraft_code'],
                          ['aircraft_code'],
                          ondelete='CASCADE')
    op.alter_column('seats',
                    'seat_no',
                    existing_type=sa.VARCHAR(length=4),
                    comment='Seat number')
    op.alter_column('seats',
                    'fare_conditions',
                    existing_type=sa.VARCHAR(length=10),
                    comment='Travel class',
                    existing_nullable=False)
    op.alter_column('seats',
                    'aircraft_code',
                    existing_type=sa.CHAR(length=3),
                    comment='Aircraft code, IATA')
    op.create_table_comment('flights',
                            'Flights',
                            existing_comment=None,
                            schema=None)
    op.alter_column('flights',
                    'status',
                    existing_type=sa.VARCHAR(length=20),
                    comment='Flight status',
                    existing_nullable=False)
    op.alter_column('flights',
                    'scheduled_departure',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    comment='Scheduled departure time',
                    existing_nullable=False)
    op.alter_column('flights',
                    'scheduled_arrival',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    comment='Scheduled arrival time',
                    existing_nullable=False)
    op.alter_column('flights',
                    'flight_no',
                    existing_type=sa.CHAR(length=6),
                    comment='Flight number',
                    existing_nullable=False)
    op.alter_column('flights',
                    'flight_id',
                    existing_type=sa.INTEGER(),
                    comment='Flight ID',
                    autoincrement=True)
    op.alter_column('flights',
                    'departure_airport',
                    existing_type=sa.CHAR(length=3),
                    comment='Airport of departure',
                    existing_nullable=False)
    op.alter_column('flights',
                    'arrival_airport',
                    existing_type=sa.CHAR(length=3),
                    comment='Airport of arrival',
                    existing_nullable=False)
    op.alter_column('flights',
                    'aircraft_code',
                    existing_type=sa.CHAR(length=3),
                    comment='Aircraft code, IATA',
                    existing_nullable=False)
    op.alter_column('flights',
                    'actual_departure',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    comment='Actual departure time',
                    existing_nullable=True)
    op.alter_column('flights',
                    'actual_arrival',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    comment='Actual arrival time',
                    existing_nullable=True)
    op.create_table_comment('bookings',
                            'Bookings',
                            existing_comment=None,
                            schema=None)
    op.alter_column('bookings',
                    'total_amount',
                    existing_type=sa.NUMERIC(precision=10, scale=2),
                    comment='Total booking cost',
                    existing_nullable=False)
    op.alter_column('bookings',
                    'book_ref',
                    existing_type=sa.CHAR(length=6),
                    comment='Booking number')
    op.alter_column('bookings',
                    'book_date',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    comment='Booking date',
                    existing_nullable=False)
    op.create_table_comment('boarding_passes',
                            'Boarding passes',
                            existing_comment=None,
                            schema=None)
    op.alter_column('boarding_passes',
                    'ticket_no',
                    existing_type=sa.CHAR(length=13),
                    comment='Ticket number')
    op.alter_column('boarding_passes',
                    'seat_no',
                    existing_type=sa.VARCHAR(length=4),
                    comment='Seat number',
                    existing_nullable=False)
    op.alter_column('boarding_passes',
                    'flight_id',
                    existing_type=sa.INTEGER(),
                    comment='Flight ID')
    op.alter_column('boarding_passes',
                    'boarding_no',
                    existing_type=sa.INTEGER(),
                    comment='Boarding pass number',
                    existing_nullable=False)
    op.create_table_comment('airports_data',
                            'Airports (internal data)',
                            existing_comment=None,
                            schema=None)
    op.alter_column('airports_data',
                    'timezone',
                    existing_type=sa.TEXT(),
                    comment='Airport time zone',
                    existing_nullable=False)
    op.alter_column('airports_data',
                    'coordinates',
                    existing_type=sa.NullType(),
                    comment='Airport coordinates (longitude and latitude)',
                    existing_nullable=False)
    op.alter_column('airports_data',
                    'city',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    comment='City',
                    existing_nullable=False)
    op.alter_column('airports_data',
                    'airport_name',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    comment='Airport name',
                    existing_nullable=False)
    op.alter_column('airports_data',
                    'airport_code',
                    existing_type=sa.CHAR(length=3),
                    comment='Airport code')
    op.create_table_comment('aircrafts_data',
                            'Aircrafts (internal data)',
                            existing_comment=None,
                            schema=None)
    op.alter_column('aircrafts_data',
                    'rrange',
                    existing_type=sa.INTEGER(),
                    comment='Maximal flying distance, km',
                    existing_nullable=False)
    op.alter_column('aircrafts_data',
                    'model',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    comment='Aircraft model',
                    existing_nullable=False)
    op.alter_column('aircrafts_data',
                    'aircraft_code',
                    existing_type=sa.CHAR(length=3),
                    comment='Aircraft code, IATA')