Python alembic.op.create_table() Examples

The following are code examples for showing how to use alembic.op.create_table(). 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: 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 3
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 4
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 5
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 6
Project: call-forwarding-flask   Author: TwilioDevEd   File: 06a8443ce88f_.py    MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('states',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('zipcodes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('zipcode', sa.String(), nullable=False),
    sa.Column('state', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('senators',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('state_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('phone', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['state_id'], ['states.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 7
Project: vk-channelify   Author: reo7sp   File: f5f69376d382_.py    MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('channels',
    sa.Column('channel_id', sa.String(), nullable=False),
    sa.Column('vk_group_id', sa.String(), nullable=False),
    sa.Column('last_vk_post_id', sa.Integer(), server_default='0', nullable=False),
    sa.Column('owner_id', sa.String(), nullable=True),
    sa.Column('owner_username', sa.String(), nullable=True),
    sa.Column('hashtag_filter', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('channel_id')
    )
    op.create_table('disabled_channels',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('vk_group_id', sa.String(), nullable=True),
    sa.Column('last_vk_post_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.String(), nullable=True),
    sa.Column('owner_username', sa.String(), nullable=True),
    sa.Column('hashtag_filter', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 8
Project: zun   Author: openstack   File: 3298c6a5c3d9_create_network_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'network',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('network_id', sa.String(length=255), nullable=True),
        sa.Column('neutron_net_id', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_network0uuid'),
        sa.UniqueConstraint('neutron_net_id',
                            name='uniq_network0neutron_net_id'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
        ) 
Example 9
Project: zun   Author: openstack   File: cf46a28f46bc_add_container_actions_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container_actions',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=255), nullable=True),
        sa.Column('container_uuid', sa.String(length=36), nullable=False),
        sa.Column('request_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('message', sa.String(length=255), nullable=True),
        sa.Index('container_uuid_idx', 'container_uuid'),
        sa.Index('request_id_idx', 'request_id'),
        sa.ForeignKeyConstraint(['container_uuid'], ['container.uuid'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 10
Project: zun   Author: openstack   File: e4d145e195f4_create_allocation_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'allocation',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('resource_provider_id', sa.Integer(), nullable=False),
        sa.Column('consumer_id', sa.String(36), nullable=False),
        sa.Column('resource_class_id', sa.Integer(), nullable=False),
        sa.Column('used', sa.Integer(), nullable=False),
        sa.Column('is_nested', sa.Integer(), nullable=False),
        sa.Column('blob', zun.db.sqlalchemy.models.JSONEncodedList(),
                  nullable=True),
        sa.Index('allocation_resource_provider_class_used_idx',
                 'resource_provider_id', 'resource_class_id', 'used'),
        sa.Index('allocation_consumer_id_idx', 'consumer_id'),
        sa.Index('allocation_resource_class_id_idx', 'resource_class_id'),
        sa.PrimaryKeyConstraint('id'),
    ) 
Example 11
Project: zun   Author: openstack   File: 9fe371393a24_create_table_container.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('image', sa.String(length=255), nullable=True),
        sa.Column('command', sa.String(length=255), nullable=True),
        sa.Column('status', sa.String(length=20), nullable=True),
        sa.Column('environment', zun.db.sqlalchemy.models.JSONEncodedDict(),
                  nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_container0uuid')
    ) 
Example 12
Project: zun   Author: openstack   File: 26896d5f9053_create_exec_instance_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'exec_instance',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), primary_key=True, nullable=False),
        sa.Column('container_id', sa.Integer(), nullable=False),
        sa.Column('exec_id', sa.String(255), nullable=False),
        sa.Column('token', sa.String(255), nullable=True),
        sa.Column('url', sa.String(255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['container_id'], ['container.id'],
                                ondelete='CASCADE'),
        sa.UniqueConstraint('container_id', 'exec_id',
                            name='uniq_exec_instance0container_id_exec_id'),
    ) 
Example 13
Project: zun   Author: openstack   File: b6bfca998431_add_container_actions_events_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container_actions_events',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('event', sa.String(length=255), nullable=True),
        sa.Column('action_id', sa.Integer(), nullable=False),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('result', sa.String(length=255), nullable=True),
        sa.Column('traceback', sa.Text(), nullable=True),
        sa.Column('details', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['action_id'], ['container_actions.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 14
Project: zun   Author: openstack   File: 10d65e285a59_create_volume_mapping_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'volume_mapping',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(36), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('volume_id', sa.String(36), nullable=False),
        sa.Column('volume_provider', sa.String(36), nullable=False),
        sa.Column('container_uuid', sa.String(36), nullable=False),
        sa.Column('container_path', sa.String(length=255), nullable=True),
        sa.Column('connection_info', MediumText(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_volume0uuid'),
    ) 
Example 15
Project: zun   Author: openstack   File: 5ffc1cabe6b4_add_registry_table.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'registry',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('domain', sa.String(length=255), nullable=False),
        sa.Column('username', sa.String(length=255), nullable=True),
        sa.Column('password', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_registry0uuid'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
    ) 
Example 16
Project: zun   Author: openstack   File: a9a92eebd9a8_create_table_zun_service.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'zun_service',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('report_count', sa.Integer(), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=True),
        sa.Column('binary', sa.String(length=255), nullable=True),
        sa.Column('disabled', sa.Boolean(), nullable=True),
        sa.Column('disabled_reason', sa.String(length=255), nullable=True),
        sa.Column('last_seen_up', sa.DateTime(), nullable=True),
        sa.Column('forced_down', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('host', 'binary',
                            name='uniq_zun_service0host0binary')
    ) 
Example 17
Project: gitlab-tools   Author: Salamek   File: 56189bfb2c5f_.py    GNU General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fingerprint',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('hostname', sa.String(length=255), nullable=True),
    sa.Column('sha256_fingerprint', sa.String(length=255), nullable=True),
    sa.Column('hashed_hostname', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'hashed_hostname', name='_user_id_hashed_hostname_uc')
    )
    op.create_index(op.f('ix_fingerprint_hashed_hostname'), 'fingerprint', ['hashed_hostname'], unique=False)
    op.create_index(op.f('ix_fingerprint_user_id'), 'fingerprint', ['user_id'], unique=False)
    # ### end Alembic commands ### 
Example 18
Project: gitlab-tools   Author: Salamek   File: 20bcb4b2673c_.py    GNU General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('task_result',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pull_mirror_id', sa.Integer(), nullable=True),
    sa.Column('push_mirror_id', sa.Integer(), nullable=True),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('task_name', sa.String(length=255), nullable=True),
    sa.Column('invoked_by', sa.Integer(), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['pull_mirror_id'], ['pull_mirror.id'], ),
    sa.ForeignKeyConstraint(['push_mirror_id'], ['push_mirror.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id')
    )
    op.create_index(op.f('ix_task_result_pull_mirror_id'), 'task_result', ['pull_mirror_id'], unique=False)
    op.create_index(op.f('ix_task_result_push_mirror_id'), 'task_result', ['push_mirror_id'], unique=False)
    # ### end Alembic commands ### 
Example 19
Project: snet-marketplace-service   Author: singnet   File: 15908b8d7b1d_baseline.py    MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('order',
    sa.Column('id', sa.VARCHAR(length=255), nullable=False),
    sa.Column('amount', mysql.JSON(), nullable=False),
    sa.Column('username', sa.VARCHAR(length=225), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), nullable=True),
    sa.Column('item_details', mysql.JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('payment',
    sa.Column('payment_id', sa.VARCHAR(length=255), nullable=False),
    sa.Column('amount', mysql.JSON(), nullable=False),
    sa.Column('order_id', sa.VARCHAR(length=255), nullable=False),
    sa.Column('payment_details', mysql.JSON(), nullable=False),
    sa.Column('payment_status', sa.VARCHAR(length=225), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), nullable=True),
    sa.ForeignKeyConstraint(['order_id'], ['order.id'], onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('payment_id')
    )
    # ### end Alembic commands ### 
Example 20
Project: maubot   Author: maubot   File: d295f8dcfa64_initial_revision.py    GNU Affero General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('client',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('homeserver', sa.String(length=255), nullable=False),
    sa.Column('access_token', sa.Text(), nullable=False),
    sa.Column('enabled', sa.Boolean(), nullable=False),
    sa.Column('next_batch', sa.String(length=255), nullable=False),
    sa.Column('filter_id', sa.String(length=255), nullable=False),
    sa.Column('sync', sa.Boolean(), nullable=False),
    sa.Column('autojoin', sa.Boolean(), nullable=False),
    sa.Column('displayname', sa.String(length=255), nullable=False),
    sa.Column('avatar_url', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plugin',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('type', sa.String(length=255), nullable=False),
    sa.Column('enabled', sa.Boolean(), nullable=False),
    sa.Column('primary_user', sa.String(length=255), nullable=False),
    sa.Column('config', sa.Text(), nullable=False),
    sa.ForeignKeyConstraint(['primary_user'], ['client.id'], onupdate='CASCADE', ondelete='RESTRICT'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 21
Project: SUMSarizer   Author: SUMSarizer   File: 46ae5e506646_.py    MIT License 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
    )
    op.add_column(u'users', sa.Column('active', sa.Boolean(), nullable=True))
    op.add_column(u'users', sa.Column('confirmed_at', sa.DateTime(), nullable=True))
    op.add_column(u'users', sa.Column('password', sa.String(length=255), nullable=True))
    ### end Alembic commands ### 
Example 22
Project: SUMSarizer   Author: SUMSarizer   File: 56c689702a23_.py    MIT License 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('resultdatapoints',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('value', sa.Float(), nullable=True),
    sa.Column('prediction', sa.Float(), nullable=True),
    sa.Column('job_id', sa.Integer(), nullable=True),
    sa.Column('datapoint_id', sa.Integer(), nullable=True),
    sa.Column('dataset_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['datapoint_id'], ['datapoints.id'], ),
    sa.ForeignKeyConstraint(['dataset_id'], ['datasets.id'], ),
    sa.ForeignKeyConstraint(['job_id'], ['sz_job.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_resultdatapoints_datapoint_id'), 'resultdatapoints', ['datapoint_id'], unique=False)
    op.create_index(op.f('ix_resultdatapoints_dataset_id'), 'resultdatapoints', ['dataset_id'], unique=False)
    op.create_index(op.f('ix_resultdatapoints_timestamp'), 'resultdatapoints', ['timestamp'], unique=False)
    ### end Alembic commands ### 
Example 23
Project: networking-sfc   Author: openstack   File: fa75d46a7f11_add_port_pair_group_params.py    Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table('sfc_port_pair_group_params',
                    sa.Column('keyword', sa.String(length=255),
                              nullable=False),
                    sa.Column('value', sa.String(length=255),
                              nullable=True),
                    sa.Column('pair_group_id', sa.String(length=36),
                              nullable=False),
                    sa.ForeignKeyConstraint(['pair_group_id'],
                                            ['sfc_port_pair_groups.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('keyword', 'pair_group_id'),
                    mysql_engine='InnoDB'
                    )
    op.add_column('sfc_port_chains', sa.Column('chain_id',
                  sa.Integer(), nullable=False))
    op.create_unique_constraint(None, 'sfc_port_chains', ['chain_id'])
    op.add_column('sfc_port_pair_groups', sa.Column('group_id',
                  sa.Integer(), nullable=False))
    op.create_unique_constraint(None, 'sfc_port_pair_groups', ['group_id']) 
Example 24
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 25
Project: drydock   Author: airshipit   File: 9593a123e7c5_create_base_database_tables.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(tables.Tasks.__tablename__, *tables.Tasks.__baseschema__)
    op.create_table(tables.ResultMessage.__tablename__,
                    *tables.ResultMessage.__baseschema__)
    op.create_table(tables.ActiveInstance.__tablename__,
                    *tables.ActiveInstance.__baseschema__)
    op.create_table(tables.BootAction.__tablename__,
                    *tables.BootAction.__baseschema__)
    op.create_table(tables.BootActionStatus.__tablename__,
                    *tables.BootActionStatus.__baseschema__) 
Example 26
Project: drydock   Author: airshipit   File: 4a5bef3702b_create_build_data_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(tables.BuildData.__tablename__,
                    *tables.BuildData.__baseschema__) 
Example 27
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 28
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 29
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 30
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 31
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 32
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 33
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 34
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 35
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 36
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 37
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 38
Project: comport   Author: codeforamerica   File: 43bdec0aeb4_.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('invite_codes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('department_id', sa.Integer(), nullable=True),
    sa.Column('code', sa.String(length=36), nullable=False),
    sa.Column('used', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('code')
    )
    op.create_index(op.f('ix_invite_codes_id'), 'invite_codes', ['id'], unique=False)
    ### end Alembic commands ### 
Example 39
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 40
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 41
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 42
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 43
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 44
Project: comport   Author: codeforamerica   File: 1826863c726a_.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    op.create_table(
        'use_of_force_incidents_lmpd',
        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('bureau', sa.String(length=255), nullable=True),
        sa.Column('division', sa.String(length=255), nullable=True),
        sa.Column('unit', sa.String(length=255), nullable=True),
        sa.Column('platoon', sa.String(length=255), nullable=True),
        sa.Column('disposition', sa.String(length=255), nullable=True),
        sa.Column('use_of_force_reason', sa.String(length=255), nullable=True),
        sa.Column('officer_force_type', sa.String(length=255), nullable=True),
        sa.Column('service_type', sa.String(length=255), nullable=True),
        sa.Column('arrest_made', sa.Boolean(), nullable=True),
        sa.Column('arrest_charges', sa.String(length=255), nullable=True),
        sa.Column('resident_injured', sa.Boolean(), nullable=True),
        sa.Column('resident_hospitalized', sa.Boolean(), nullable=True),
        sa.Column('resident_condition', sa.String(length=255), nullable=True),
        sa.Column('officer_injured', sa.Boolean(), nullable=True),
        sa.Column('officer_hospitalized', sa.Boolean(), nullable=True),
        sa.Column('officer_condition', sa.String(length=255), nullable=True),
        sa.Column('resident_identifier', sa.String(length=255), nullable=True),
        sa.Column('resident_weapon_used', sa.String(length=255), nullable=True),
        sa.Column('resident_race', sa.String(length=255), nullable=True),
        sa.Column('resident_sex', sa.String(length=255), nullable=True),
        sa.Column('resident_age', sa.String(length=255), nullable=True),
        sa.Column('officer_race', sa.String(length=255), nullable=True),
        sa.Column('officer_sex', sa.String(length=255), nullable=True),
        sa.Column('officer_age', sa.String(length=255), nullable=True),
        sa.Column('officer_years_of_service', sa.String(length=255), nullable=True),
        sa.Column('officer_identifier', sa.String(length=255), nullable=True),
        sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 45
Project: url-shortener   Author: piotr-rusin   File: f819f3f77f30_.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('shortenedURL',
    sa.Column('alias', sa.Integer(), nullable=False),
    sa.Column('target', sa.String(length=2083), nullable=True),
    sa.PrimaryKeyConstraint('alias'),
    sa.UniqueConstraint('target')
    )
    ### end Alembic commands ### 
Example 46
Project: pornote   Author: haltode   File: 04ef75b50778_.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('member',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(length=64), nullable=True),
    sa.Column('last_name', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=128), nullable=True),
    sa.Column('password', sa.String(length=64), nullable=True),
    sa.Column('points', sa.Integer(), nullable=True),
    sa.Column('class_nb', sa.Integer(), nullable=True),
    sa.Column('section', sa.String(length=64), nullable=True),
    sa.Column('second_lang', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('homework',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('member_id', sa.Integer(), nullable=False),
    sa.Column('subject', sa.String(length=128), nullable=True),
    sa.Column('section', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=256), nullable=True),
    sa.Column('end_date', sa.Date(), nullable=True),
    sa.Column('filename', sa.String(length=128), nullable=True),
    sa.Column('class_nb', sa.Integer(), nullable=True),
    sa.Column('is_public', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['member_id'], ['member.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('filename')
    )
    ### end Alembic commands ### 
Example 47
Project: gnocchi   Author: gnocchixyz   File: 828c16f70cce_create_resource_type_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    resource_type = op.create_table(
        'resource_type',
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('name'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
    )

    resource = sa.Table('resource', sa.MetaData(),
                        type_string_col("type", "resource"))
    op.execute(resource_type.insert().from_select(
        ['name'], sa.select([resource.c.type]).distinct()))

    for table in ["resource", "resource_history"]:
        op.alter_column(table, "type", new_column_name="old_type",
                        existing_type=type_enum)
        op.add_column(table, type_string_col("type", table))
        sa_table = sa.Table(table, sa.MetaData(),
                            type_string_col("type", table),
                            type_enum_col('old_type'))
        op.execute(sa_table.update().values(
            {sa_table.c.type: sa_table.c.old_type}))
        op.drop_column(table, "old_type")
        op.alter_column(table, "type", nullable=False,
                        existing_type=type_string) 
Example 48
Project: mtanchor_demo   Author: forest-snow   File: 293c8607996c_.py    MIT License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('start',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('anchors1', sa.String(), nullable=True),
    sa.Column('topics1', sa.String(), nullable=True),
    sa.Column('Q1', sa.String(), nullable=True),
    sa.Column('vocab1', sa.String(), nullable=True),
    sa.Column('index1', sa.String(), nullable=True),
    sa.Column('dict1', sa.String(), nullable=True),
    sa.Column('anchors2', sa.String(), nullable=True),
    sa.Column('topics2', sa.String(), nullable=True),
    sa.Column('Q2', sa.String(), nullable=True),
    sa.Column('vocab2', sa.String(), nullable=True),
    sa.Column('index2', sa.String(), nullable=True),
    sa.Column('dict2', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('update',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('anchors1', sa.String(), nullable=True),
    sa.Column('anchors2', sa.String(), nullable=True),
    sa.Column('topics1', sa.String(), nullable=True),
    sa.Column('topics2', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 49
Project: neutron   Author: kaloom   File: 37b8cbf74944_create_kaloom_x_s_lock.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'kaloom_x_s_lock',
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('name')
    )
    op.execute(
        "insert into kaloom_x_s_lock(name) values('" + kconst.L3_LOCK_NAME + "')"
    ) 
Example 50
Project: neutron   Author: kaloom   File: 37b8cbf74943_create_kaloom_tables.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'kaloom_ml2_knid_mapping',
        sa.Column('kaloom_knid', sa.BigInteger(), nullable=False),
        sa.Column('network_id', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('kaloom_knid')
    )

    op.create_table(
        'kaloom_ml2_vlan_host_mapping',
        sa.Column('vlan_id', sa.Integer(), nullable=False),
        sa.Column('network_id', sa.String(length=255), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=False),
        sa.Column('segment_id', sa.String(length=255), nullable=False),
        sa.Column('network_name', sa.String(length=255), nullable=False),
        sa.Column('state', sa.Enum('CREATING', 'CREATED', 'DELETING'), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('network_id', 'host')
    )

    
    op.create_table(
        'kaloom_ml2_vlan_reservation',
        sa.Column('host', sa.String(length=255), nullable=False),
        sa.Column('vlan_id', sa.Integer(), nullable=False),
        sa.Column('network_id', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('host', 'vlan_id')
    )

    op.create_table(
        'kaloom_ml2_tp_operation',
        sa.Column('network_id', sa.String(length=255), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('network_id', 'host')
    ) 
Example 51
Project: zun   Author: openstack   File: 37bce72463e3_add_pci_device.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'pci_device',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36)),
        sa.Column('compute_node_uuid', sa.String(length=36), nullable=False),
        sa.Column('address', sa.String(length=12), nullable=False),
        sa.Column('vendor_id', sa.String(length=4), nullable=False),
        sa.Column('product_id', sa.String(length=4), nullable=False),
        sa.Column('dev_type', sa.String(length=8), nullable=False),
        sa.Column('dev_id', sa.String(255)),
        sa.Column('label', sa.String(255), nullable=False),
        sa.Column('status', sa.String(36), nullable=False),
        sa.Column('request_id', sa.String(36), nullable=False),
        sa.Column('extra_info', sa.Text()),
        sa.Column('container_uuid', sa.String(36)),
        sa.Column('numa_node', sa.Integer(), nullable=True),
        sa.Column('parent_addr', sa.String(12), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('compute_node_uuid', 'address',
                            name='uniq_pci_device0compute_node_uuid0address'),
        sa.Index('ix_pci_device_compute_node_uuid', 'compute_node_uuid'),
        sa.Index('ix_pci_device_container_uuid', 'container_uuid'),
        sa.Index('ix_pci_device_compute_node_uuid_parent_addr',
                 'compute_node_uuid', 'parent_addr'),
    ) 
Example 52
Project: zun   Author: openstack   File: 012a730926e8_add_quota_usage.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'quota_usages',
        sa.Column('created_at', sa.DateTime()),
        sa.Column('updated_at', sa.DateTime()),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), index=True),
        sa.Column('resource', sa.String(length=255), nullable=False),
        sa.Column('in_use', sa.Integer, nullable=False),
        sa.Column('reserved', sa.Integer, nullable=False),
        sa.Column('until_refresh', sa.Integer),
        mysql_engine='InnoDB'
    ) 
Example 53
Project: zun   Author: openstack   File: 7975b7f0f792_add_resource_class_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'resource_class',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name', name='uniq_container0name')
    ) 
Example 54
Project: zun   Author: openstack   File: 09f196622a3f_create_inventory_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'inventory',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('resource_provider_id', sa.Integer(), nullable=False),
        sa.Column('resource_class_id', sa.Integer(), nullable=False),
        sa.Column('total', sa.Integer(), nullable=False),
        sa.Column('reserved', sa.Integer(), nullable=False),
        sa.Column('min_unit', sa.Integer(), nullable=False),
        sa.Column('max_unit', sa.Integer(), nullable=False),
        sa.Column('step_size', sa.Integer(), nullable=False),
        sa.Column('allocation_ratio', sa.Float(), nullable=False),
        sa.Column('is_nested', sa.Integer(), nullable=False),
        sa.Column('blob', zun.db.sqlalchemy.models.JSONEncodedList(),
                  nullable=True),
        sa.Index('inventory_resource_provider_id_idx',
                 'resource_provider_id'),
        sa.Index('inventory_resource_provider_resource_class_idx',
                 'resource_provider_id', 'resource_class_id'),
        sa.Index('inventory_resource_class_id_idx',
                 'resource_class_id'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint(
            'resource_provider_id', 'resource_class_id',
            name='uniq_inventory0resource_provider_resource_class'),
    ) 
Example 55
Project: zun   Author: openstack   File: 6fd4f7582eb0_add_resource_provider_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'resource_provider',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('root_provider', sa.String(length=36), nullable=False),
        sa.Column('parent_provider', sa.String(length=36), nullable=True),
        sa.Column('can_host', sa.Integer(), default=0),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_resource_provider0uuid')
    ) 
Example 56
Project: zun   Author: openstack   File: 2b045cb595db_create_quota_quota_class_tables.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'quotas',
        sa.Column('created_at', sa.DateTime()),
        sa.Column('updated_at', sa.DateTime()),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), index=True),
        sa.Column('resource', sa.String(length=255), nullable=False),
        sa.Column('hard_limit', sa.Integer()),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
    )

    op.create_table(
        'quota_classes',
        sa.Column('created_at', sa.DateTime()),
        sa.Column('updated_at', sa.DateTime()),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('class_name', sa.String(length=255)),
        sa.Column('resource', sa.String(length=255)),
        sa.Column('hard_limit', sa.Integer()),
        sa.Index('quota_classes_class_name_idx', 'class_name'),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
    )
    # ### end Alembic commands ### 
Example 57
Project: zun   Author: openstack   File: eeac0d191f5a_add_compute_node_table.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'compute_node',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('hostname', sa.String(length=255), nullable=False),
        sa.Column('numa_topology', models.JSONEncodedDict(), nullable=True),
        sa.PrimaryKeyConstraint('uuid'),
    ) 
Example 58
Project: flask-s3-save-example   Author: Jaza   File: 83da20f4d7a_.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('thingy',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('image', sa.String(length=255), nullable=False),
    sa.Column('image_storage_type', sa.String(length=255), nullable=False),
    sa.Column('image_storage_bucket_name', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('password', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    ### end Alembic commands ### 
Example 59
Project: gitlab-tools   Author: Salamek   File: d4841aeeb072_.py    GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('celery_taskmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id'),
    sqlite_autoincrement=True
    )
    op.create_table('celery_tasksetmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('taskset_id', sa.String(length=155), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('taskset_id'),
    sqlite_autoincrement=True
    )
    op.add_column('task_result', sa.Column('celery_taskmeta_id', sa.Integer(), nullable=False))
    op.create_index(op.f('ix_task_result_celery_taskmeta_id'), 'task_result', ['celery_taskmeta_id'], unique=False)
    op.drop_constraint('task_result_task_id_key', 'task_result', type_='unique')
    op.create_foreign_key(None, 'task_result', 'celery_taskmeta', ['celery_taskmeta_id'], ['id'])
    op.drop_column('task_result', 'result')
    op.drop_column('task_result', 'status')
    op.drop_column('task_result', 'date_done')
    op.drop_column('task_result', 'task_id')
    op.drop_column('task_result', 'traceback')
    # ### end Alembic commands ### 
Example 60
Project: beavy   Author: beavyHQ   File: 15c488d628b_.py    Mozilla Public License 2.0 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('private_message_participants',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('pm_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['pm_id'], ['objects.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    op.add_column('objects', sa.Column('title', sa.String(length=255), nullable=False))
    ### end Alembic commands ### 
Example 61
Project: orcid-service   Author: adsabs   File: 51f3b3b5cd5d_creating_basic_db_structure.py    MIT License 5 votes vote down vote up
def upgrade():
    op.create_table('users',
        sa.Column('orcid_id', sa.String(length=255), nullable=False),
        sa.Column('access_token', sa.String(length=255), nullable=True),
        sa.Column('created', sa.DateTime(), nullable=True, default=datetime.datetime.utcnow),
        sa.Column('updated', sa.DateTime(), nullable=True, default=datetime.datetime.utcnow),
        sa.Column('profile', sa.Text, nullable=True),
        sa.PrimaryKeyConstraint('orcid_id')
    ) 
Example 62
Project: orcid-service   Author: adsabs   File: 07c3fe07309c_create_profile_table.py    MIT License 5 votes vote down vote up
def upgrade():
    #with app.app_context() as c:
    #   db.session.add(Model())
    #   db.session.commit()

    op.create_table('profile',
                    sa.Column('orcid_id', sa.String(length=255), nullable=False),
                    sa.Column('created', UTCDateTime, nullable=True, default=get_date),
                    sa.Column('updated', UTCDateTime, nullable=True, default=get_date),
                    sa.Column('bibcode', postgresql.JSON(), nullable=True),
                    sa.PrimaryKeyConstraint('orcid_id')
                    ) 
Example 63
Project: invenio-userprofiles   Author: inveniosoftware   File: c25ef2c50ffa_create_userprofiles_tables.py    MIT License 5 votes vote down vote up
def upgrade():
    """Upgrade database."""
    op.create_table(
        'userprofiles_userprofile',
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=255), nullable=True),
        sa.Column('displayname', sa.String(length=255), nullable=True),
        sa.Column('full_name', sa.String(length=255), nullable=False),
        sa.ForeignKeyConstraint(['user_id'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('user_id'),
        sa.UniqueConstraint('username')
    ) 
Example 64
Project: lando-api   Author: mozilla-conduit   File: 77c763c1cf82_remove_landings.py    Mozilla Public License 2.0 5 votes vote down vote up
def downgrade():
    op.create_table(
        "landings",
        sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column("request_id", sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column("revision_id", sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column("diff_id", sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column("active_diff_id", sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column(
            "status",
            postgresql.ENUM(
                "aborted", "submitted", "landed", "failed", name="landingstatus"
            ),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column("error", sa.TEXT(), autoincrement=False, nullable=True),
        sa.Column("result", sa.TEXT(), autoincrement=False, nullable=True),
        sa.Column(
            "requester_email",
            sa.VARCHAR(length=254),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column("tree", sa.VARCHAR(length=128), autoincrement=False, nullable=True),
        sa.Column(
            "created_at",
            postgresql.TIMESTAMP(timezone=True),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column(
            "updated_at",
            postgresql.TIMESTAMP(timezone=True),
            autoincrement=False,
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("id", name="landings_pkey"),
        sa.UniqueConstraint("request_id", name="landings_request_id_key"),
    ) 
Example 65
Project: lando-api   Author: mozilla-conduit   File: 79cefec5be09_add_sec_approval_tables.py    Mozilla Public License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        "secapproval_requests",
        sa.Column("id", sa.Integer(), primary_key=True),
        sa.Column("revision_id", sa.Integer(), nullable=False, index=True),
        sa.Column("diff_phid", sa.Text(), nullable=False),
        sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
        sa.Column(
            "comment_candidates",
            postgresql.JSONB(astext_type=sa.Text()),
            nullable=False,
        ),
    ) 
Example 66
Project: SUMSarizer   Author: SUMSarizer   File: 2289e585ec7b_.py    MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sz_job',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('study_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('state', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['study_id'], ['studies.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_sz_job_study_id'), 'sz_job', ['study_id'], unique=False)
    ### end Alembic commands ### 
Example 67
Project: backend.ai-manager   Author: lablup   File: 7ea324d0535b_vfolder_and_kernel.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kernels', sa.Column('agent_id', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.drop_constraint(op.f('fk_kernels_agent_agents'), 'kernels', type_='foreignkey')
    op.drop_index(op.f('ix_kernels_terminated_at'), table_name='kernels')
    op.drop_index(op.f('ix_kernels_status'), table_name='kernels')
    op.drop_index(op.f('ix_kernels_created_at'), table_name='kernels')
    op.drop_column('kernels', 'status_info')
    op.drop_column('kernels', 'num_queries')
    op.drop_column('kernels', 'net_tx_bytes')
    op.drop_column('kernels', 'net_rx_bytes')
    op.drop_column('kernels', 'max_mem_bytes')
    op.drop_column('kernels', 'io_write_bytes')
    op.drop_column('kernels', 'io_read_bytes')
    op.drop_column('kernels', 'cur_mem_bytes')
    op.drop_column('kernels', 'cpu_used')
    op.drop_column('kernels', 'allocated_cores')
    op.drop_column('kernels', 'agent')
    op.create_table(
        'usage',
        sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=False),
        sa.Column('access_key_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True),
        sa.Column('kernel_type', sa.VARCHAR(), autoincrement=False, nullable=True),
        sa.Column('kernel_id', sa.VARCHAR(), autoincrement=False, nullable=True),
        sa.Column('started_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
        sa.Column('terminated_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
        sa.Column('cpu_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True),
        sa.Column('mem_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True),
        sa.Column('io_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True),
        sa.Column('net_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True),
        sa.ForeignKeyConstraint(['access_key_id'], ['keypairs.access_key'], name='fk_usage_access_key_id_keypairs'),
        sa.PrimaryKeyConstraint('id', name='pk_usage')
    )
    op.drop_table('vfolder_attachment')
    op.drop_table('vfolders')
    op.drop_table('agents')
    # ### end Alembic commands ### 
Example 68
Project: backend.ai-manager   Author: lablup   File: 185852ff9872_add_vfolder_permissions_table.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'vfolder_permissions',
        sa.Column('permission', sa.String(length=2), nullable=True),
        sa.Column('vfolder', GUID(), nullable=False),
        sa.Column('access_key', sa.String(length=20), nullable=False),
        sa.ForeignKeyConstraint(['access_key'], ['keypairs.access_key'],
                                name=op.f('fk_vfolder_permissions_access_key_keypairs')),
        sa.ForeignKeyConstraint(['vfolder'], ['vfolders.id'],
                                name=op.f('fk_vfolder_permissions_vfolder_vfolders'),
                                onupdate='CASCADE', ondelete='CASCADE')
    )
    # ### end Alembic commands ### 
Example 69
Project: backend.ai-manager   Author: lablup   File: 26d0c387e764_create_vfolder_invitations_table.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'vfolder_invitations',
        sa.Column('id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
        sa.Column('permission', sa.String(length=2), nullable=True),
        sa.Column('invitee', sa.String(length=256), nullable=False),
        sa.Column('vfolder', GUID(), nullable=False),
        sa.ForeignKeyConstraint(['vfolder'], ['vfolders.id'],
                                name=op.f('fk_vfolder_invitations_vfolder_vfolders'),
                                onupdate='CASCADE', ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_vfolder_invitations'))
    )
    # ### end Alembic commands ### 
Example 70
Project: networking-sfc   Author: openstack   File: 9768e6a66c9_flowclassifier_data_model.py    Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'sfc_flow_classifiers',
        sa.Column('tenant_id', sa.String(length=255),
                  nullable=True, index=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('ethertype', sa.String(length=40), nullable=True),
        sa.Column('protocol', sa.String(length=40), nullable=True),
        sa.Column('description', sa.String(length=255),
                  nullable=True),
        sa.Column('source_port_range_min', sa.Integer(), nullable=True),
        sa.Column('source_port_range_max', sa.Integer(), nullable=True),
        sa.Column('destination_port_range_min', sa.Integer(), nullable=True),
        sa.Column('destination_port_range_max', sa.Integer(), nullable=True),
        sa.Column('source_ip_prefix', sa.String(length=255), nullable=True),
        sa.Column('destination_ip_prefix', sa.String(length=255),
                  nullable=True),
        sa.Column('logical_source_port', sa.String(length=36),
                  nullable=False),
        sa.Column('logical_destination_port', sa.String(length=36),
                  nullable=True),
        sa.ForeignKeyConstraint(['logical_source_port'], ['ports.id'],
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['logical_destination_port'], ['ports.id'],
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('id')
    )

    op.create_table(
        'sfc_flow_classifier_l7_parameters',
        sa.Column('keyword', sa.String(length=255), nullable=False),
        sa.Column('value', sa.String(length=255), nullable=True),
        sa.Column('classifier_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['classifier_id'],
                                ['sfc_flow_classifiers.id'], ),
        sa.PrimaryKeyConstraint('keyword', 'classifier_id')
    ) 
Example 71
Project: flasky   Author: RoseOu   File: operations.py    MIT License 4 votes vote down vote up
def create_table(self, name, *columns, **kw):
        """Issue a "create table" instruction using the current migration context.

        This directive receives an argument list similar to that of the
        traditional :class:`sqlalchemy.schema.Table` construct, but without the
        metadata::

            from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Column
            from alembic import op

            op.create_table(
                'account',
                Column('id', INTEGER, primary_key=True),
                Column('name', VARCHAR(50), nullable=False),
                Column('description', NVARCHAR(200))
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        Note that :meth:`.create_table` accepts :class:`~sqlalchemy.schema.Column`
        constructs directly from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the "timestamp" column
            op.create_table('account',
                Column('id', INTEGER, primary_key=True),
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param name: Name of the table
        :param \*columns: collection of :class:`~sqlalchemy.schema.Column`
         objects within
         the table, as well as optional :class:`~sqlalchemy.schema.Constraint`
         objects
         and :class:`~.sqlalchemy.schema.Index` objects.
        :param schema: Optional schema name to operate within.
        :param \**kw: Other keyword arguments are passed to the underlying
         :class:`sqlalchemy.schema.Table` object created for the command.

        """
        self.impl.create_table(
            self._table(name, *columns, **kw)
        ) 
Example 72
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 ### 
Example 73
Project: circleci-demo-python-flask   Author: CircleCI-Public   File: 7257da855061_.py    MIT License 4 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.Column('default', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('confirmed', sa.Boolean(), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('location', sa.String(length=64), nullable=True),
    sa.Column('about_me', sa.Text(), nullable=True),
    sa.Column('member_since', sa.DateTime(), nullable=True),
    sa.Column('last_seen', sa.DateTime(), nullable=True),
    sa.Column('avatar_hash', sa.String(length=32), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    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')
    )
    op.create_table('posts',
    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('author_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_posts_timestamp'), 'posts', ['timestamp'], unique=False)
    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(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    # ### end Alembic commands ### 
Example 74
Project: gitlab-tools   Author: Salamek   File: 19e8725e0581_.py    GNU General Public License v3.0 4 votes vote down vote up
def upgrade():
    bind = op.get_bind()
    session = Session(bind=bind)

    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('project',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('gitlab_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=255), nullable=True),
    sa.Column('name_with_namespace', sa.String(length=255), nullable=True),
    sa.Column('web_url', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('gitlab_id')
    )
    op.create_table('push_mirror',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('source', sa.String(length=255), nullable=True),
    sa.Column('target', sa.String(length=255), nullable=True),
    sa.Column('foreign_vcs_type', sa.Integer(), nullable=True),
    sa.Column('last_sync', sa.DateTime(), nullable=True),
    sa.Column('note', sa.String(length=255), nullable=True),
    sa.Column('hook_token', sa.String(length=255), nullable=True),
    sa.Column('is_force_update', sa.Boolean(), nullable=True),
    sa.Column('is_prune_mirrors', sa.Boolean(), nullable=True),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('project_mirror', sa.String(length=255), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('project_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_push_mirror_project_id'), 'push_mirror', ['project_id'], unique=False)
    op.create_index(op.f('ix_push_mirror_user_id'), 'push_mirror', ['user_id'], unique=False)
    op.add_column('pull_mirror', sa.Column('project_id', sa.Integer(), nullable=True))
    op.create_index(op.f('ix_pull_mirror_project_id'), 'pull_mirror', ['project_id'], unique=False)
    op.create_foreign_key(None, 'pull_mirror', 'project', ['project_id'], ['id'])

    # Migrate dropped gitlab_id to project_id

    for pull_mirror in session.query(PullMirror):
        found_project = session.query(Project).filter_by(gitlab_id=pull_mirror.gitlab_id).first()
        if not found_project:
            found_project = Project()
            found_project.gitlab_id = pull_mirror.gitlab_id
            found_project.name = pull_mirror.project_name
            session.add(found_project)
            session.commit()

        pull_mirror.project_id = found_project.id

        session.add(pull_mirror)
    session.commit()

    op.drop_column('pull_mirror', 'gitlab_id')
    # ### end Alembic commands ### 
Example 75
Project: gitlab-tools   Author: Salamek   File: 6ea24c49b7a1_.py    GNU General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('crontab_schedule',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('minute', sa.String(length=120), nullable=True),
    sa.Column('hour', sa.String(length=120), nullable=True),
    sa.Column('day_of_week', sa.String(length=120), nullable=True),
    sa.Column('day_of_month', sa.String(length=120), nullable=True),
    sa.Column('month_of_year', sa.String(length=120), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('interval_schedule',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('every', sa.Integer(), nullable=False),
    sa.Column('period', sa.Unicode(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('periodic_tasks',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('ident', sa.Integer(), nullable=True),
    sa.Column('last_update', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_periodic_tasks_ident'), 'periodic_tasks', ['ident'], unique=False)
    op.create_table('periodic_task',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=120), nullable=True),
    sa.Column('task', sa.String(length=120), nullable=True),
    sa.Column('crontab_id', sa.Integer(), nullable=True),
    sa.Column('interval_id', sa.Integer(), nullable=True),
    sa.Column('args', sa.String(length=120), nullable=True),
    sa.Column('kwargs', sa.String(length=120), nullable=True),
    sa.Column('last_run_at', sa.DateTime(), nullable=True),
    sa.Column('total_run_count', sa.Integer(), nullable=True),
    sa.Column('enabled', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['crontab_id'], ['crontab_schedule.id'], ),
    sa.ForeignKeyConstraint(['interval_id'], ['interval_schedule.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    # ### end Alembic commands ### 
Example 76
Project: quiz-extensions   Author: ucfopen   File: 203dd50e5775_.py    MIT License 4 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('course',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('canvas_id', sa.Integer(), nullable=True),
    sa.Column('course_name', sa.String(length=250), nullable=True),
    sa.Column('created_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('last_updated_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('canvas_id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('canvas_id', sa.Integer(), nullable=True),
    sa.Column('created_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('last_updated_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('sis_id', sa.String(length=50), nullable=True),
    sa.Column('sortable_name', sa.String(length=250), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('canvas_id')
    )
    op.create_table('extension',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('course_id', sa.Integer(), nullable=True),
    sa.Column('created_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('last_updated_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('percent', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.CheckConstraint(u'percent >= 100', name='check_percent_greater_than_100'),
    sa.ForeignKeyConstraint(['course_id'], ['course.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('quiz',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('canvas_id', sa.Integer(), nullable=True),
    sa.Column('course_id', sa.Integer(), nullable=True),
    sa.Column('created_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('last_updated_date', sa.DateTime(), server_default=sa.text(u'now()'), nullable=True),
    sa.Column('title', sa.String(length=250), nullable=True),
    sa.ForeignKeyConstraint(['course_id'], ['course.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('canvas_id')
    )
    ### end Alembic commands ### 
Example 77
Project: backend.ai-manager   Author: lablup   File: bae1a7326e8a_add_domain_model.py    GNU Lesser General Public License v3.0 4 votes vote down vote up
def upgrade():
    metadata = sa.MetaData(naming_convention=convention)

    # partial table to insert "default" domain
    domains = sa.Table(
        'domains', metadata,
        sa.Column('name', sa.String(length=64), primary_key=True),
        sa.Column('description', sa.String(length=512)),
        sa.Column('is_active', sa.Boolean, default=True),
        sa.Column('total_resource_slots', ResourceSlotColumn(), nullable=False),
    )

    op.create_table(
        'domains',
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('description', sa.String(length=512), nullable=True),
        sa.Column('is_active', sa.Boolean(), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.text('now()'), nullable=True),
        sa.Column('modified_at', sa.DateTime(timezone=True),
                  server_default=sa.text('now()'), nullable=True),
        sa.Column('total_resource_slots',
                  postgresql.JSONB(astext_type=sa.Text()), nullable=False),
        sa.PrimaryKeyConstraint('name', name=op.f('pk_domains'))
    )
    op.add_column('users', sa.Column('domain_name', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_users_domain_name'), 'users', ['domain_name'], unique=False)
    op.create_foreign_key(op.f('fk_users_domain_name_domains'),
                          'users', 'domains', ['domain_name'], ['name'])

    # Fill in users' domain_name column with default domain.
    # Create default domain if not exist.
    connection = op.get_bind()
    query = sa.select([domains]).select_from(domains).where(domains.c.name == 'default')
    results = connection.execute(query).fetchone()
    if results is None:
        query = (sa.insert(domains)
                   .values(name='default',
                           description='Default domain',
                           is_active=True,
                           total_resource_slots='{}'))
        query = textwrap.dedent('''\
            INSERT INTO domains (name, description, is_active, total_resource_slots)
            VALUES ('default', 'Default domain', True, '{}'::jsonb);''')
        connection.execute(query)

    # Fill in users' domain_name field.
    query = "UPDATE users SET domain_name = 'default' WHERE email != '[email protected]';"
    connection.execute(query) 
Example 78
Project: backend.ai-manager   Author: lablup   File: 7ea324d0535b_vfolder_and_kernel.py    GNU Lesser General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'agents',
        sa.Column('id', sa.String(length=64), nullable=False),
        sa.Column('mem_slots', sa.Integer(), nullable=False),
        sa.Column('cpu_slots', sa.Integer(), nullable=False),
        sa.Column('gpu_slots', sa.Integer(), nullable=False),
        sa.Column('used_mem_slots', sa.Integer(), nullable=False),
        sa.Column('used_cpu_slots', sa.Integer(), nullable=False),
        sa.Column('used_gpu_slots', sa.Integer(), nullable=False),
        sa.Column('addr', sa.String(length=128), nullable=False),
        sa.Column('first_contact', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_agents'))
    )
    op.create_table(
        'vfolders',
        sa.Column('id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
        sa.Column('host', sa.String(length=128), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('max_files', sa.Integer(), nullable=True),
        sa.Column('max_size', sa.Integer(), nullable=True),
        sa.Column('num_files', sa.Integer(), nullable=True),
        sa.Column('cur_size', sa.Integer(), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
        sa.Column('last_used', sa.DateTime(timezone=True), nullable=True),
        sa.Column('belongs_to', sa.String(length=20), nullable=False),
        sa.ForeignKeyConstraint(['belongs_to'], ['keypairs.access_key'], name=op.f('fk_vfolders_belongs_to_keypairs')),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_vfolders'))
    )
    op.create_table(
        'vfolder_attachment',
        sa.Column('vfolder', GUID(), nullable=False),
        sa.Column('kernel', GUID(), nullable=False),
        sa.ForeignKeyConstraint(['kernel'], ['kernels.sess_id'], name=op.f('fk_vfolder_attachment_kernel_kernels')),
        sa.ForeignKeyConstraint(['vfolder'], ['vfolders.id'], name=op.f('fk_vfolder_attachment_vfolder_vfolders')),
        sa.PrimaryKeyConstraint('vfolder', 'kernel', name=op.f('pk_vfolder_attachment'))
    )
    op.drop_table('usage')
    op.add_column('kernels', sa.Column('agent', sa.String(length=64), nullable=True))
    op.add_column('kernels', sa.Column('allocated_cores', sa.ARRAY(sa.Integer()), nullable=True))
    op.add_column('kernels', sa.Column('cpu_used', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('cur_mem_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('io_read_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('io_write_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('max_mem_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('net_rx_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('net_tx_bytes', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('num_queries', sa.BigInteger(), nullable=True))
    op.add_column('kernels', sa.Column('status_info', sa.Unicode(), nullable=True))
    op.create_index(op.f('ix_kernels_created_at'), 'kernels', ['created_at'], unique=False)
    op.create_index(op.f('ix_kernels_status'), 'kernels', ['status'], unique=False)
    op.create_index(op.f('ix_kernels_terminated_at'), 'kernels', ['terminated_at'], unique=False)
    op.create_foreign_key(op.f('fk_kernels_agent_agents'), 'kernels', 'agents', ['agent'], ['id'])
    op.drop_column('kernels', 'agent_id')
    # ### end Alembic commands ### 
Example 79
Project: backend.ai-manager   Author: lablup   File: dbc1e053b880_add_keypair_resource_policy.py    GNU Lesser General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'keypair_resource_policies',
        sa.Column('name', sa.String(length=256), nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.text('now()'),
                  nullable=True),
        sa.Column('default_for_unspecified',
                  type_=sa.Enum(*default_for_unspecified_choices,
                                name='default_for_unspecified'),
                  nullable=False),
        sa.Column('total_resource_slots',
                  postgresql.JSONB(astext_type=sa.Text()), nullable=False),
        sa.Column('max_concurrent_sessions', sa.Integer(), nullable=False),
        sa.Column('max_containers_per_session', sa.Integer(), nullable=False),
        sa.Column('max_vfolder_count', sa.Integer(), nullable=False),
        sa.Column('max_vfolder_size', sa.BigInteger(), nullable=False),
        sa.Column('allowed_vfolder_hosts',
                  postgresql.ARRAY(sa.String()), nullable=False),
        sa.PrimaryKeyConstraint('name', name=op.f('pk_keypair_resource_policies'))
    )
    # Create a default resource policy
    query = '''
    INSERT INTO keypair_resource_policies
    VALUES (
        'default',
        now(),
        'UNLIMITED',
        '{}'::jsonb,
        30,
        1,
        10,
        0,
        array['local']
    );
    UPDATE keypairs
    SET resource_policy = 'default';
    '''
    connection = op.get_bind()
    connection.execute(query)
    print('\n!!! NOTICE !!!\n')
    print('Created a default resource policy and linked all keypairs to it.')
    print('Please inspect and adjust it!\n')
    op.alter_column('keypairs', 'resource_policy',
                    existing_type=sa.VARCHAR(),
                    type_=sa.String(length=256),
                    nullable=False)
    op.create_foreign_key(
        op.f('fk_keypairs_resource_policy_keypair_resource_policies'),
        'keypairs', 'keypair_resource_policies',
        ['resource_policy'], ['name'])
    op.drop_column('keypairs', 'concurrency_limit')
    # ### end Alembic commands ### 
Example 80
Project: backend.ai-manager   Author: lablup   File: 5de06da3c2b5_init.py    GNU Lesser General Public License v3.0 4 votes vote down vote up
def upgrade():
    op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'keypairs',
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('access_key', sa.String(length=20), nullable=False),
        sa.Column('secret_key', sa.String(length=40), nullable=True),
        sa.Column('is_active', sa.Boolean(), nullable=True),
        sa.Column('billing_plan', sa.String(), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.text('now()'), nullable=True),
        sa.Column('last_used', sa.DateTime(timezone=True), nullable=True),
        sa.Column('concurrency_limit', sa.Integer(), nullable=True),
        sa.Column('concurrency_used', sa.Integer(), nullable=True),
        sa.Column('rate_limit', sa.Integer(), nullable=True),
        sa.Column('num_queries', sa.Integer(), server_default='0', nullable=True),
        sa.PrimaryKeyConstraint('access_key')
    )
    op.create_table(
        'kernels',
        sa.Column('sess_id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
        sa.Column('lang', sa.String(length=64), nullable=True),
        sa.Column('access_key', sa.String(length=20), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.text('now()'), nullable=True),
        sa.Column('terminated_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('status', sa.String(), nullable=True),
        sa.Column('agent_id', sa.String(), nullable=True),
        sa.Column('container_id', sa.String(), nullable=True),
        sa.ForeignKeyConstraint(['access_key'], ['keypairs.access_key'], ),
        sa.PrimaryKeyConstraint('sess_id')
    )
    op.create_table(
        'usage',
        sa.Column('id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
        sa.Column('access_key_id', sa.String(length=20), nullable=True),
        sa.Column('kernel_type', sa.String(), nullable=True),
        sa.Column('kernel_id', sa.String(), nullable=True),
        sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('terminated_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('cpu_used', sa.Integer(), server_default='0', nullable=True),
        sa.Column('mem_used', sa.Integer(), server_default='0', nullable=True),
        sa.Column('io_used', sa.Integer(), server_default='0', nullable=True),
        sa.Column('net_used', sa.Integer(), server_default='0', nullable=True),
        sa.ForeignKeyConstraint(['access_key_id'], ['keypairs.access_key'], ),
        sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###