Python sqlalchemy.Column() Examples

The following are code examples for showing how to use sqlalchemy.Column(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: flasky   Author: RoseOu   File: 51f5ccfba190_comments.py    MIT License 7 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_comments_timestamp', 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ### 
Example 2
Project: flasky   Author: RoseOu   File: descriptor_props.py    MIT License 6 votes vote down vote up
def props(self):
        props = []
        for attr in self.attrs:
            if isinstance(attr, str):
                prop = self.parent.get_property(
                    attr, _configure_mappers=False)
            elif isinstance(attr, schema.Column):
                prop = self.parent._columntoproperty[attr]
            elif isinstance(attr, attributes.InstrumentedAttribute):
                prop = attr.property
            else:
                raise sa_exc.ArgumentError(
                    "Composite expects Column objects or mapped "
                    "attributes/attribute names as arguments, got: %r"
                    % (attr,))
            props.append(prop)
        return props 
Example 3
Project: comport   Author: codeforamerica   File: 875c52a485_.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('months',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('months_id_seq'::regclass)"), nullable=False),
    sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='months_department_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='months_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('serviceTypes',
    sa.Column('id', sa.INTEGER(), server_default=sa.text('nextval(\'"serviceTypes_id_seq"\'::regclass)'), nullable=False),
    sa.Column('month_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('service_type', sa.VARCHAR(length=36), autoincrement=False, nullable=False),
    sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['month_id'], ['months.id'], name='serviceTypes_month_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='serviceTypes_pkey')
    )
    op.drop_table('use_of_force_incidents')
    ### end Alembic commands ### 
Example 4
Project: comport   Author: codeforamerica   File: 33fcc9c4867_.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('citizen_complaint',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('opaque_id', sa.String(length=255), nullable=False),
    sa.Column('occured_date', sa.DateTime(), nullable=True),
    sa.Column('division', sa.String(length=255), nullable=True),
    sa.Column('precinct', sa.String(length=255), nullable=True),
    sa.Column('shift', sa.String(length=255), nullable=True),
    sa.Column('beat', sa.String(length=255), nullable=True),
    sa.Column('disposition', sa.String(length=255), nullable=True),
    sa.Column('census_tract', sa.String(length=255), nullable=True),
    sa.Column('resident_race', sa.String(length=255), nullable=True),
    sa.Column('officer_race', sa.String(length=255), nullable=True),
    sa.Column('resident_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_identifier', sa.String(length=255), nullable=True),
    sa.Column('officer_years_of_service', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('opaque_id')
    )
    ### end Alembic commands ### 
Example 5
Project: comport   Author: codeforamerica   File: 720df9948a25_.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def upgrade():
    op.create_table(
        'assaults_on_officers',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('department_id', sa.Integer(), nullable=False),
        sa.Column('opaque_id', sa.String(length=255), nullable=False),
        sa.Column('officer_identifier', sa.String(length=255), nullable=True),
        sa.Column('service_type', sa.String(length=255), nullable=True),
        sa.Column('force_type', sa.String(length=255), nullable=True),
        sa.Column('assignment', sa.String(length=255), nullable=True),
        sa.Column('arrest_made', sa.Boolean(), nullable=True),
        sa.Column('officer_injured', sa.Boolean(), nullable=True),
        sa.Column('officer_killed', sa.Boolean(), nullable=True),
        sa.Column('report_filed', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 6
Project: comport   Author: codeforamerica   File: 52979aa7977_.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=80), nullable=False),
    sa.Column('email', sa.String(length=80), nullable=False),
    sa.Column('password', sa.String(length=128), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 7
Project: flaskit   Author: elston   File: a2cd143eda28_.py    MIT License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('username', sa.String(length=80), nullable=False),
    sa.Column('password', sa.Binary(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('username')
    )
    # ### end Alembic commands ### 
Example 8
Project: flasky   Author: RoseOu   File: 198b0eebcf9_caching_of_avatar_hashes.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('avatar_hash', sa.String(length=32), nullable=True))
    ### end Alembic commands ### 
Example 9
Project: flasky   Author: RoseOu   File: 288cd3dc5a8_rich_text_posts.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('posts', sa.Column('body_html', sa.Text(), nullable=True))
    ### end Alembic commands ### 
Example 10
Project: flasky   Author: RoseOu   File: 456a945560f6_login_support.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('email', sa.String(length=64), nullable=True))
    op.add_column('users', sa.Column('password_hash', sa.String(length=128), nullable=True))
    op.create_index('ix_users_email', 'users', ['email'], unique=True)
    ### end Alembic commands ### 
Example 11
Project: flasky   Author: RoseOu   File: d66f086b258_user_information.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('about_me', sa.Text(), nullable=True))
    op.add_column('users', sa.Column('last_seen', sa.DateTime(), nullable=True))
    op.add_column('users', sa.Column('location', sa.String(length=64), nullable=True))
    op.add_column('users', sa.Column('member_since', sa.DateTime(), nullable=True))
    op.add_column('users', sa.Column('name', sa.String(length=64), nullable=True))
    ### end Alembic commands ### 
Example 12
Project: flasky   Author: RoseOu   File: 1b966e7f4b9e_post_model.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('posts',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_posts_timestamp', 'posts', ['timestamp'], unique=False)
    ### end Alembic commands ### 
Example 13
Project: flasky   Author: RoseOu   File: 2356a38169ea_followers.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('follows',
    sa.Column('follower_id', sa.Integer(), nullable=False),
    sa.Column('followed_id', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['followed_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['follower_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('follower_id', 'followed_id')
    )
    ### end Alembic commands ### 
Example 14
Project: flasky   Author: RoseOu   File: 38c4e85512a9_initial_migration.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_users_username', 'users', ['username'], unique=True)
    ### end Alembic commands ### 
Example 15
Project: flasky   Author: RoseOu   File: descriptor_props.py    MIT License 5 votes vote down vote up
def columns(self):
        return [a for a in self.attrs if isinstance(a, schema.Column)] 
Example 16
Project: flasky   Author: RoseOu   File: __init__.py    MIT License 5 votes vote down vote up
def _make_table(db):
    def _make_table(*args, **kwargs):
        if len(args) > 1 and isinstance(args[1], db.Column):
            args = (args[0], db.metadata) + args[1:]
        info = kwargs.pop('info', None) or {}
        info.setdefault('bind_key', None)
        kwargs['info'] = info
        return sqlalchemy.Table(*args, **kwargs)
    return _make_table 
Example 17
Project: comport   Author: codeforamerica   File: 0de6730e3d41_create_wpd_complaints_table.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.create_table(
        'citizen_complaints_wpd',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('department_id', sa.Integer(), sa.ForeignKey('departments.id'), nullable=False),
        sa.Column('opaque_id', sa.String(255), unique=False, nullable=True),
        sa.Column('received_date', sa.DateTime, unique=False, nullable=True),
        sa.Column('division', sa.String(255), unique=False, nullable=True),
        sa.Column('bureau', sa.String(255), unique=False, nullable=True),
        sa.Column('shift', sa.String(255), unique=False, nullable=True),
        sa.Column('service_type', sa.String(255), unique=False, nullable=True),
        sa.Column('source', sa.String(255), unique=False, nullable=True),
        sa.Column('incident_type', sa.String(255), unique=False, nullable=True),
        sa.Column('allegation', sa.String(255), unique=False, nullable=True),
        sa.Column('finding', sa.String(255), unique=False, nullable=True),
        sa.Column('disposition', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_id', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_race', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_sex', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_age', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_id', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_race', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_sex', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_age', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_years_of_service', sa.String(255), unique=False, nullable=True),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id']),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 18
Project: comport   Author: codeforamerica   File: 4ffa73ef2b8_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chart_block_defaults',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('caption', sa.String(length=255), nullable=True),
    sa.Column('slug', sa.String(length=255), nullable=False),
    sa.Column('dataset', sa.String(length=255), nullable=False),
    sa.Column('content', sa.Text(convert_unicode=True), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('chart_blocks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('caption', sa.String(length=255), nullable=True),
    sa.Column('slug', sa.String(length=255), nullable=False),
    sa.Column('dataset', sa.String(length=255), nullable=False),
    sa.Column('content', sa.Text(), nullable=True),
    sa.Column('date_updated', sa.DateTime(), nullable=True),
    sa.Column('date_edited', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('use_of_force_incidents', sa.Column('received_date', sa.DateTime(), nullable=True))
    ### end Alembic commands ### 
Example 19
Project: comport   Author: codeforamerica   File: 1392585412d_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('departments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_departments_id'), 'departments', ['id'], unique=False)
    ### end Alembic commands ### 
Example 20
Project: comport   Author: codeforamerica   File: ab97630e71ce_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('officer_involved_shootings_bpd', sa.Column('case_number', sa.String(length=255), nullable=True)) 
Example 21
Project: comport   Author: codeforamerica   File: 32d7cc46df4_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('demographic_values',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('race', sa.String(length=255), nullable=True),
    sa.Column('gender', sa.String(length=255), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.Column('department_value', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 22
Project: comport   Author: codeforamerica   File: 2de736b481_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('citizen_complaints', sa.Column('allegation', sa.String(length=255), nullable=True))
    op.add_column('citizen_complaints', sa.Column('allegation_type', sa.String(length=255), nullable=True))
    op.drop_column('citizen_complaints', 'category')
    ### end Alembic commands ### 
Example 23
Project: comport   Author: codeforamerica   File: 2de736b481_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('citizen_complaints', sa.Column('category', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.drop_column('citizen_complaints', 'allegation_type')
    op.drop_column('citizen_complaints', 'allegation')
    ### end Alembic commands ### 
Example 24
Project: comport   Author: codeforamerica   File: 507f3182b84_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('denominator_values', sa.Column('officers_out_on_service', sa.Integer(), nullable=True))
    op.drop_column('denominator_values', 'arrests')
    ### end Alembic commands ### 
Example 25
Project: comport   Author: codeforamerica   File: 507f3182b84_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('denominator_values', sa.Column('arrests', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_column('denominator_values', 'officers_out_on_service')
    ### end Alembic commands ### 
Example 26
Project: comport   Author: codeforamerica   File: 1c306b9d32_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('received_date', sa.DateTime(), nullable=True))
    ### end Alembic commands ### 
Example 27
Project: comport   Author: codeforamerica   File: 7f4ae427dcf6_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('officer_involved_shootings_bpd', sa.Column('disposition', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.drop_column('officer_involved_shootings_bpd', 'has_disposition') 
Example 28
Project: comport   Author: codeforamerica   File: 0d39b8d2c5ce_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('chart_blocks', sa.Column('order', sa.Integer(), server_default='0', nullable=True)) 
Example 29
Project: comport   Author: codeforamerica   File: 2357b6b3d76_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('citizen_complaints', sa.Column('service_type', sa.String(length=255), nullable=True))
    op.add_column('citizen_complaints', sa.Column('source', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 30
Project: comport   Author: codeforamerica   File: 77ad8047becf_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('use_of_force_incidents_bpd', sa.Column('case_number', sa.String(length=128), nullable=True))
    op.add_column('use_of_force_incidents_bpd', sa.Column('completed_date', sa.DateTime(), nullable=True))
    op.add_column('use_of_force_incidents_bpd', sa.Column('received_date', sa.DateTime(), nullable=True))

    op.drop_column('use_of_force_incidents_bpd', 'division')
    op.drop_column('use_of_force_incidents_bpd', 'bureau')
    op.drop_column('use_of_force_incidents_bpd', 'resident_weapon_used') 
Example 31
Project: comport   Author: codeforamerica   File: 77ad8047becf_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('use_of_force_incidents_bpd', sa.Column('resident_weapon_used', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents_bpd', sa.Column('bureau', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents_bpd', sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True))

    op.drop_column('use_of_force_incidents_bpd', 'received_date')
    op.drop_column('use_of_force_incidents_bpd', 'completed_date')
    op.drop_column('use_of_force_incidents_bpd', 'case_number') 
Example 32
Project: comport   Author: codeforamerica   File: 21dd34bbb19_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('status', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('day_of_week', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('received_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_injured', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_weapon', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_hospitalized', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('hour', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=True))
    op.alter_column('use_of_force_incidents', 'department_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_column('use_of_force_incidents', 'shift')
    op.drop_column('use_of_force_incidents', 'resident_weapon_used')
    op.drop_column('use_of_force_incidents', 'resident_resist_type')
    op.drop_column('use_of_force_incidents', 'resident_race')
    op.drop_column('use_of_force_incidents', 'resident_injured')
    op.drop_column('use_of_force_incidents', 'resident_hospitalized')
    op.drop_column('use_of_force_incidents', 'precinct')
    op.drop_column('use_of_force_incidents', 'officer_race')
    op.drop_column('use_of_force_incidents', 'officer_force_type')
    op.drop_column('use_of_force_incidents', 'office_weapon_used')
    op.drop_column('use_of_force_incidents', 'division')
    op.drop_column('use_of_force_incidents', 'beat')
    ### end Alembic commands ### 
Example 33
Project: comport   Author: codeforamerica   File: 3df24031e72_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('links',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('url', sa.String(length=2083), nullable=False),
    sa.Column('type', sa.String(length=255), nullable=False),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 34
Project: comport   Author: codeforamerica   File: cff7a8d7f106_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('officer_involved_shootings_bpd', sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('officer_involved_shootings_bpd', sa.Column('bureau', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) 
Example 35
Project: comport   Author: codeforamerica   File: 28296e3a641_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('department_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'users', 'departments', ['department_id'], ['id'])
    ### end Alembic commands ### 
Example 36
Project: comport   Author: codeforamerica   File: 529cc76baaa_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('what_this_is', sa.TEXT(), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
Example 37
Project: comport   Author: codeforamerica   File: 23353b28d77_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('demographic_values', sa.Column('gender', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
Example 38
Project: comport   Author: codeforamerica   File: 5cb851130ebb_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('citizen_complaints_srpd', sa.Column('officer_age', sa.String(length=255), nullable=True))
    op.add_column('citizen_complaints_srpd', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True))
    op.add_column('officer_involved_shootings_srpd', sa.Column('officer_age', sa.String(length=255), nullable=True))
    op.add_column('officer_involved_shootings_srpd', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True))
    op.add_column('pursuits_srpd', sa.Column('officer_age', sa.String(length=255), nullable=True))
    op.add_column('pursuits_srpd', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents_srpd', sa.Column('officer_age', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents_srpd', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True)) 
Example 39
Project: comport   Author: codeforamerica   File: 875c52a485_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('use_of_force_incidents',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('opaque_id', sa.String(length=255), nullable=False),
    sa.Column('month', sa.Integer(), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('department_id', sa.Integer(), nullable=True),
    sa.Column('status', sa.String(length=255), nullable=True),
    sa.Column('disposition', sa.String(length=255), nullable=True),
    sa.Column('service_type', sa.String(length=255), nullable=True),
    sa.Column('day_of_week', sa.String(length=255), nullable=True),
    sa.Column('hour', sa.Integer(), nullable=True),
    sa.Column('arrest_made', sa.Boolean(), nullable=True),
    sa.Column('arrest_charges', sa.String(length=255), nullable=True),
    sa.Column('citizen_hospitalized', sa.Boolean(), nullable=True),
    sa.Column('citizen_injured', sa.Boolean(), nullable=True),
    sa.Column('officer_injured', sa.Boolean(), nullable=True),
    sa.Column('officer_hospitalized', sa.Boolean(), nullable=True),
    sa.Column('use_of_force_reason', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('opaque_id')
    )
    op.drop_table('serviceTypes')
    op.drop_table('months')
    ### end Alembic commands ### 
Example 40
Project: comport   Author: codeforamerica   File: fecca96b9d_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('use_of_force_incidents', 'officer_years_of_service')
    op.add_column('use_of_force_incidents', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 41
Project: comport   Author: codeforamerica   File: f0526891fa_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('extractors', sa.Column('next_month', sa.Integer(), nullable=True))
    op.add_column('extractors', sa.Column('next_year', sa.Integer(), nullable=True))
    ### end Alembic commands ### 
Example 42
Project: comport   Author: codeforamerica   File: 32f2dcfc96d_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('denominator_values',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('month', sa.Integer(), nullable=False),
    sa.Column('year', sa.Integer(), nullable=False),
    sa.Column('arrests', sa.Integer(), nullable=True),
    sa.Column('calls_for_service', sa.Integer(), nullable=True),
    sa.Column('officer_initiated_calls', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 43
Project: comport   Author: codeforamerica   File: 38f457822b3_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('denominator_values', sa.Column('officer_initiated_calls', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('denominator_values', sa.Column('calls_for_service', sa.INTEGER(), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
Example 44
Project: comport   Author: codeforamerica   File: c21533f2fd07_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    # create the incidents_updated table
    op.create_table(
        'incidents_updated',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('department_id', sa.Integer(), nullable=False),
        sa.Column('opaque_id', sa.String(length=255), nullable=False),
        sa.Column('incident_type', sa.String(length=32), nullable=False),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_incidents_updated_opaque_id'), 'incidents_updated', ['opaque_id'], unique=False) 
Example 45
Project: comport   Author: codeforamerica   File: 56bb92fb8acc_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('citizen_complaints_bpd', sa.Column('case_number', sa.String(length=128), nullable=True))
    op.add_column('citizen_complaints_bpd', sa.Column('completed_date', sa.DateTime(), nullable=True))
    op.add_column('citizen_complaints_bpd', sa.Column('incident_type', sa.String(length=128), nullable=True))
    op.add_column('citizen_complaints_bpd', sa.Column('received_date', sa.DateTime(), nullable=True))
    op.add_column('citizen_complaints_bpd', sa.Column('resident_role', sa.String(length=128), nullable=True))
    op.drop_column('citizen_complaints_bpd', 'division')
    op.drop_column('citizen_complaints_bpd', 'bureau') 
Example 46
Project: comport   Author: codeforamerica   File: 56bb92fb8acc_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('citizen_complaints_bpd', sa.Column('bureau', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('citizen_complaints_bpd', sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.drop_column('citizen_complaints_bpd', 'resident_role')
    op.drop_column('citizen_complaints_bpd', 'received_date')
    op.drop_column('citizen_complaints_bpd', 'incident_type')
    op.drop_column('citizen_complaints_bpd', 'completed_date')
    op.drop_column('citizen_complaints_bpd', 'case_number') 
Example 47
Project: comport   Author: codeforamerica   File: 0d78d545906f_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('departments', sa.Column('is_public_assaults_on_officers', sa.Boolean(), server_default=sa.true(), nullable=False))
    op.add_column('departments', sa.Column('is_public_citizen_complaints', sa.Boolean(), server_default=sa.true(), nullable=False))
    op.add_column('departments', sa.Column('is_public_officer_involved_shootings', sa.Boolean(), server_default=sa.true(), nullable=False))
    op.add_column('departments', sa.Column('is_public_use_of_force_incidents', sa.Boolean(), server_default=sa.true(), nullable=False)) 
Example 48
Project: comport   Author: codeforamerica   File: 529d8396153_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('officer_identifier', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('officer_weapon_used', sa.String(length=255), nullable=True))
    op.drop_column('use_of_force_incidents', 'office_weapon_used')
    ### end Alembic commands ### 
Example 49
Project: comport   Author: codeforamerica   File: 58a10a2d8e4_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('occured_date', sa.DateTime(), nullable=True))
    ### end Alembic commands ### 
Example 50
Project: comport   Author: codeforamerica   File: 471223798fc_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('officer_sex', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_sex', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 51
Project: comport   Author: codeforamerica   File: 16b50a2c53b_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    connection = op.get_bind()

    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('short_name', sa.String(length=80), nullable=True))
    op.create_unique_constraint("dept_short_name", 'departments', ['short_name'])
    ### end Alembic commands ### 
Example 52
Project: comport   Author: codeforamerica   File: 17b38c3d5e7_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('serviceTypes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('month_id', sa.Integer(), nullable=True),
    sa.Column('service_type', sa.String(length=36), nullable=False),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['month_id'], ['months.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 53
Project: comport   Author: codeforamerica   File: 24987646046_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('officer_years_of_service', sa.Integer(), nullable=True))
    ### end Alembic commands ### 
Example 54
Project: comport   Author: codeforamerica   File: 4a7e5abdf57_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('officer_involved_shootings', sa.Column('officer_weapon_used', sa.String(length=255), nullable=True))
    op.drop_column('officer_involved_shootings', 'officer_force_type')
    ### end Alembic commands ### 
Example 55
Project: comport   Author: codeforamerica   File: 4a7e5abdf57_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('officer_involved_shootings', sa.Column('officer_force_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.drop_column('officer_involved_shootings', 'officer_weapon_used')
    ### end Alembic commands ### 
Example 56
Project: comport   Author: codeforamerica   File: 52887f8e06b_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('citizen_complaint', sa.Column('category', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 57
Project: comport   Author: codeforamerica   File: 3434f410ad7_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('extractors',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('users', sa.Column('type', sa.String(length=50), nullable=True))
    op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
    ### end Alembic commands ### 
Example 58
Project: comport   Author: codeforamerica   File: 513f93441476_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('use_of_force_incidents_lmpd', sa.Column('resident_weapon_used', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) 
Example 59
Project: comport   Author: codeforamerica   File: 52eaf89477f_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_department_relationship_table',
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('department_id', 'user_id')
    )
    ### end Alembic commands ### 
Example 60
Project: comport   Author: codeforamerica   File: 9d6a8b74b21a_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    op.add_column('use_of_force_incidents_srpd', sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('pursuits_srpd', sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('officer_involved_shootings_srpd', sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('citizen_complaints_srpd', sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) 
Example 61
Project: comport   Author: codeforamerica   File: 4f5fcadcf2d_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('links',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('url', sa.VARCHAR(length=2083), autoincrement=False, nullable=False),
    sa.Column('type', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='links_department_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='links_pkey')
    )
    ### end Alembic commands ### 
Example 62
Project: comport   Author: codeforamerica   File: 6d30846080b2_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('is_public', sa.Boolean(), server_default=sa.true(), nullable=False))
    ### end Alembic commands ### 
Example 63
Project: comport   Author: codeforamerica   File: 4e4710949dd_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chart_block_defaults',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('caption', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('slug', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='chart_block_defaults_pkey')
    )
    ### end Alembic commands ### 
Example 64
Project: comport   Author: codeforamerica   File: 331c513e8d4_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('months',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('month', sa.Integer(), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('department_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 65
Project: comport   Author: codeforamerica   File: 1a869ac514c_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('interesteds',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('agency', sa.String(length=255), nullable=False),
    sa.Column('location', sa.String(length=255), nullable=False),
    sa.Column('phone', sa.String(length=255), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('comments', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 66
Project: comport   Author: codeforamerica   File: 43fd1bb4848_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('census_tract', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_weapon', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 67
Project: comport   Author: codeforamerica   File: 30e29c63aa6_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('received_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
Example 68
Project: comport   Author: codeforamerica   File: 1d31622bbed_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('contact_us', sa.Text(convert_unicode=True), nullable=True))
    op.add_column('departments', sa.Column('how_you_can_use_this_data', sa.Text(convert_unicode=True), nullable=True))
    op.add_column('departments', sa.Column('what_this_is', sa.Text(convert_unicode=True), nullable=True))
    op.add_column('departments', sa.Column('why_we_are_doing_this', sa.Text(convert_unicode=True), nullable=True))
    ### end Alembic commands ### 
Example 69
Project: comport   Author: codeforamerica   File: b13e5a5233_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('extractors', sa.Column('last_contact', sa.DateTime(), nullable=True))
    ### end Alembic commands ### 
Example 70
Project: comport   Author: codeforamerica   File: 2f13ffb1ce60_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.add_column('pursuits_srpd', sa.Column('bureau', sa.String(length=255), nullable=True))
    op.add_column('pursuits_srpd', sa.Column('division', sa.String(length=255), nullable=True)) 
Example 71
Project: comport   Author: codeforamerica   File: 331a821cc4a_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('use_of_force_incidents', 'resident_condition')
    op.drop_column('use_of_force_incidents', 'officer_condition')
    op.create_table('citizen_complaint',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('opaque_id', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('occured_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('precinct', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('shift', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('beat', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('disposition', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('census_tract', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_identifier', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_years_of_service', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('category', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('resident_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='citizen_complaint_department_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='citizen_complaint_pkey')
    )
    op.drop_table('citizen_complaints')
    op.drop_table('officer_involved_shootings')
    ### end Alembic commands ### 
Example 72
Project: comport   Author: codeforamerica   File: 3bc88a29a22_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('citizen_complaints', 'officer_years_of_service')
    op.add_column('citizen_complaints', sa.Column('officer_years_of_service', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 73
Project: comport   Author: codeforamerica   File: 3bc88a29a22_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('citizen_complaints', 'officer_years_of_service')
    op.add_column('citizen_complaints', sa.Column('officer_years_of_service', sa.Integer(), nullable=True))
    ### end Alembic commands ### 
Example 74
Project: comport   Author: codeforamerica   File: 4d1cde26d807_create_wpd_uof_table.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.create_table(
        'use_of_force_incidents_wpd',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('department_id', sa.Integer(), sa.ForeignKey('departments.id'), nullable=False),
        sa.Column('opaque_id', sa.String(255), unique=False, nullable=True),
        sa.Column('received_date', sa.DateTime, unique=False, nullable=True),
        sa.Column('division', sa.String(255), unique=False, nullable=True),
        sa.Column('bureau', sa.String(255), unique=False, nullable=True),
        sa.Column('shift', sa.String(255), unique=False, nullable=True),
        sa.Column('use_of_force_reason', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_resist_type', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_resistance', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_force_type', sa.String(255), unique=False, nullable=True),
        sa.Column('arrest_charges', sa.String(255), unique=False, nullable=True),
        sa.Column('disposition', sa.String(255), unique=False, nullable=True),
        sa.Column('service_type', sa.String(255), unique=False, nullable=True),
        sa.Column('arrest_made', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_id', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_injured', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_hospitalized', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_condition', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_race', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_sex', sa.String(255), unique=False, nullable=True),
        sa.Column('citizen_age', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_id', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_injured', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_hospitalized', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_race', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_sex', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_age', sa.String(255), unique=False, nullable=True),
        sa.Column('officer_years_of_service', sa.String(255), unique=False, nullable=True),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id']),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 75
Project: Trusted-Platform-Module-nova   Author: BU-NU-CLOUD-SP16   File: 231_add_ephemeral_key_uuid.py    Apache License 2.0 5 votes vote down vote up
def upgrade(migrate_engine):
    """Function adds ephemeral storage encryption key uuid field."""
    meta = MetaData(bind=migrate_engine)

    instances = Table('instances', meta, autoload=True)
    shadow_instances = Table('shadow_instances', meta, autoload=True)

    ephemeral_key_uuid = Column('ephemeral_key_uuid', String(36))
    instances.create_column(ephemeral_key_uuid)
    shadow_instances.create_column(ephemeral_key_uuid.copy())

    migrate_engine.execute(instances.update().
                           values(ephemeral_key_uuid=None))
    migrate_engine.execute(shadow_instances.update().
                           values(ephemeral_key_uuid=None)) 
Example 76
Project: flasky   Author: RoseOu   File: 190163627111_account_confirmation.py    MIT License 4 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('confirmed', sa.Boolean(), nullable=True))
    ### end Alembic commands ### 
Example 77
Project: flasky   Author: RoseOu   File: base.py    MIT License 4 votes vote down vote up
def __init__(self, *enums, **kw):
        """Construct an ENUM.

        E.g.::

          Column('myenum', ENUM("foo", "bar", "baz"))

        :param enums: The range of valid values for this ENUM.  Values will be
          quoted when generating the schema according to the quoting flag (see
          below).

        :param strict: Defaults to False: ensure that a given value is in this
          ENUM's range of permissible values when inserting or updating rows.
          Note that MySQL will not raise a fatal error if you attempt to store
          an out of range value- an alternate value will be stored instead.
          (See MySQL ENUM documentation.)

        :param charset: Optional, a column-level character set for this string
          value.  Takes precedence to 'ascii' or 'unicode' short-hand.

        :param collation: Optional, a column-level collation for this string
          value.  Takes precedence to 'binary' short-hand.

        :param ascii: Defaults to False: short-hand for the ``latin1``
          character set, generates ASCII in schema.

        :param unicode: Defaults to False: short-hand for the ``ucs2``
          character set, generates UNICODE in schema.

        :param binary: Defaults to False: short-hand, pick the binary
          collation type that matches the column's character set.  Generates
          BINARY in schema.  This does not affect the type of data stored,
          only the collation of character data.

        :param quoting: Defaults to 'auto': automatically determine enum value
          quoting.  If all enum values are surrounded by the same quoting
          character, then use 'quoted' mode.  Otherwise, use 'unquoted' mode.

          'quoted': values in enums are already quoted, they will be used
          directly when generating the schema - this usage is deprecated.

          'unquoted': values in enums are not quoted, they will be escaped and
          surrounded by single quotes when generating the schema.

          Previous versions of this type always required manually quoted
          values to be supplied; future versions will always quote the string
          literals for you.  This is a transitional option.

        """
        values, length = self._init_values(enums, kw)
        self.strict = kw.pop('strict', False)
        kw.pop('metadata', None)
        kw.pop('schema', None)
        kw.pop('name', None)
        kw.pop('quote', None)
        kw.pop('native_enum', None)
        kw.pop('inherit_schema', None)
        _StringType.__init__(self, length=length, **kw)
        sqltypes.Enum.__init__(self, *values) 
Example 78
Project: flasky   Author: RoseOu   File: events.py    MIT License 4 votes vote down vote up
def column_reflect(self, inspector, table, column_info):
        """Called for each unit of 'column info' retrieved when
        a :class:`.Table` is being reflected.

        The dictionary of column information as returned by the
        dialect is passed, and can be modified.  The dictionary
        is that returned in each element of the list returned
        by :meth:`.reflection.Inspector.get_columns`.

        The event is called before any action is taken against
        this dictionary, and the contents can be modified.
        The :class:`.Column` specific arguments ``info``, ``key``,
        and ``quote`` can also be added to the dictionary and
        will be passed to the constructor of :class:`.Column`.

        Note that this event is only meaningful if either
        associated with the :class:`.Table` class across the
        board, e.g.::

            from sqlalchemy.schema import Table
            from sqlalchemy import event

            def listen_for_reflect(inspector, table, column_info):
                "receive a column_reflect event"
                # ...

            event.listen(
                    Table,
                    'column_reflect',
                    listen_for_reflect)

        ...or with a specific :class:`.Table` instance using
        the ``listeners`` argument::

            def listen_for_reflect(inspector, table, column_info):
                "receive a column_reflect event"
                # ...

            t = Table(
                'sometable',
                autoload=True,
                listeners=[
                    ('column_reflect', listen_for_reflect)
                ])

        This because the reflection process initiated by ``autoload=True``
        completes within the scope of the constructor for :class:`.Table`.

        """ 
Example 79
Project: flasky   Author: RoseOu   File: mutable.py    MIT License 4 votes vote down vote up
def as_mutable(cls, sqltype):
        """Associate a SQL type with this mutable Python type.

        This establishes listeners that will detect ORM mappings against
        the given type, adding mutation event trackers to those mappings.

        The type is returned, unconditionally as an instance, so that
        :meth:`.as_mutable` can be used inline::

            Table('mytable', metadata,
                Column('id', Integer, primary_key=True),
                Column('data', MyMutableType.as_mutable(PickleType))
            )

        Note that the returned type is always an instance, even if a class
        is given, and that only columns which are declared specifically with
        that type instance receive additional instrumentation.

        To associate a particular mutable type with all occurrences of a
        particular type, use the :meth:`.Mutable.associate_with` classmethod
        of the particular :class:`.Mutable` subclass to establish a global
        association.

        .. warning::

           The listeners established by this method are *global*
           to all mappers, and are *not* garbage collected.   Only use
           :meth:`.as_mutable` for types that are permanent to an application,
           not with ad-hoc types else this will cause unbounded growth
           in memory usage.

        """
        sqltype = types.to_instance(sqltype)

        def listen_for_type(mapper, class_):
            for prop in mapper.column_attrs:
                if prop.columns[0].type is sqltype:
                    cls.associate_with_attribute(getattr(class_, prop.key))

        event.listen(mapper, 'mapper_configured', listen_for_type)

        return sqltype 
Example 80
Project: comport   Author: codeforamerica   File: 331a821cc4a_.py    BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('officer_involved_shootings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('opaque_id', sa.String(length=255), nullable=False),
    sa.Column('occured_date', sa.DateTime(), nullable=True),
    sa.Column('division', sa.String(length=255), nullable=True),
    sa.Column('precinct', sa.String(length=255), nullable=True),
    sa.Column('shift', sa.String(length=255), nullable=True),
    sa.Column('beat', sa.String(length=255), nullable=True),
    sa.Column('disposition', sa.String(length=255), nullable=True),
    sa.Column('census_tract', sa.String(length=255), nullable=True),
    sa.Column('officer_force_type', sa.String(length=255), nullable=True),
    sa.Column('resident_weapon_used', sa.String(length=255), nullable=True),
    sa.Column('service_type', sa.String(length=255), nullable=True),
    sa.Column('resident_race', sa.String(length=255), nullable=True),
    sa.Column('officer_race', sa.String(length=255), nullable=True),
    sa.Column('resident_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_identifier', sa.String(length=255), nullable=True),
    sa.Column('officer_years_of_service', sa.Integer(), nullable=True),
    sa.Column('officer_age', sa.String(length=255), nullable=True),
    sa.Column('resident_age', sa.String(length=255), nullable=True),
    sa.Column('officer_condition', sa.String(length=255), nullable=True),
    sa.Column('resident_condition', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('citizen_complaints',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=False),
    sa.Column('opaque_id', sa.String(length=255), nullable=False),
    sa.Column('occured_date', sa.DateTime(), nullable=True),
    sa.Column('division', sa.String(length=255), nullable=True),
    sa.Column('precinct', sa.String(length=255), nullable=True),
    sa.Column('shift', sa.String(length=255), nullable=True),
    sa.Column('beat', sa.String(length=255), nullable=True),
    sa.Column('disposition', sa.String(length=255), nullable=True),
    sa.Column('category', sa.String(length=255), nullable=True),
    sa.Column('census_tract', sa.String(length=255), nullable=True),
    sa.Column('resident_race', sa.String(length=255), nullable=True),
    sa.Column('officer_race', sa.String(length=255), nullable=True),
    sa.Column('resident_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_sex', sa.String(length=255), nullable=True),
    sa.Column('officer_identifier', sa.String(length=255), nullable=True),
    sa.Column('officer_years_of_service', sa.Integer(), nullable=True),
    sa.Column('officer_age', sa.String(length=255), nullable=True),
    sa.Column('resident_age', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('citizen_complaint')
    op.add_column('use_of_force_incidents', sa.Column('officer_condition', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_condition', sa.String(length=255), nullable=True))
    ### end Alembic commands ###