def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chat',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=True),
    sa.Column('password', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('message',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('datetime', sa.DateTime(), nullable=True),
    sa.Column('chat', sa.Integer(), nullable=False),
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('message', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['chat'], ['chat.id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['user'], ['user.id'], initially='DEFERRED', deferrable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_chat',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('chat', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['chat'], ['chat.id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['user'], ['user.id'], initially='DEFERRED', deferrable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user', 'chat')
    )
    op.create_index(op.f('ix_user_chat_chat'), 'user_chat', ['chat'], unique=False)
    op.create_index(op.f('ix_user_chat_user'), 'user_chat', ['user'], unique=False)
def upgrade():
    for index in indexes:
        op.create_index(index[0], index[1], [index[2]])
    op.execute('alter table application_route add constraint uniq_app_route_appid_rule unique(application_id, rule)')
    op.execute('alter table application_static_content add constraint uniq_app_static_content_appid_resource_key unique(application_id, resource_key)')
    op.execute('alter table application_static_file add constraint uniq_app_static_file_appid_resource_key unique(application_id, resource_key)')
    op.execute('alter table application_template add constraint uniq_app_template_appid_key unique(application_id, key)')
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column(u'messages_drawing_move', sa.Column('special_message_finish_drawing_id', sa.String(length=2000), nullable=True))
    op.add_column(u'messages_drawing_move', sa.Column('special_message_start_drawing_id', sa.String(length=2000), nullable=True))
    op.drop_column(u'messages_drawing_move', 'special_message_id')
    op.create_index(op.f('ix_messages_drawing_move_special_message_finish_drawing_id'), 'messages_drawing_move', ['special_message_finish_drawing_id'], unique=False)
    op.create_index(op.f('ix_messages_drawing_move_special_message_start_drawing_id'), 'messages_drawing_move', ['special_message_start_drawing_id'], unique=False)
def upgrade():
    op.create_table('query',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('client_id',  sa.String(length=11), nullable=False),
        sa.Column('database_id', sa.Integer(), nullable=False),
        sa.Column('tmp_table_name', sa.String(length=256), nullable=True),
        sa.Column('tab_name', sa.String(length=256),nullable=True),
        sa.Column('sql_editor_id', sa.String(length=256), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('status', sa.String(length=16), nullable=True),
        sa.Column('name', sa.String(length=256), nullable=True),
        sa.Column('schema', sa.String(length=256), nullable=True),
        sa.Column('sql', sa.Text(), nullable=True),
        sa.Column('select_sql', sa.Text(), nullable=True),
        sa.Column('executed_sql', sa.Text(), nullable=True),
        sa.Column('limit', sa.Integer(), nullable=True),
        sa.Column('limit_used', sa.Boolean(), nullable=True),
        sa.Column('select_as_cta', sa.Boolean(), nullable=True),
        sa.Column('select_as_cta_used', sa.Boolean(), nullable=True),
        sa.Column('progress', sa.Integer(), nullable=True),
        sa.Column('rows', sa.Integer(), nullable=True),
        sa.Column('error_message', sa.Text(), nullable=True),
        sa.Column('start_time', sa.Numeric(precision=20, scale=6), nullable=True),
        sa.Column('changed_on', sa.DateTime(), nullable=True),
        sa.Column('end_time', sa.Numeric(precision=20, scale=6), nullable=True),
        sa.ForeignKeyConstraint(['database_id'], ['dbs.id'], ),
        sa.ForeignKeyConstraint(['user_id'], ['ab_user.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.add_column('dbs', sa.Column('select_as_create_table_as', sa.Boolean(),
                                   nullable=True))
    op.create_index(
        op.f('ti_user_id_changed_on'),
        'query', ['user_id', 'changed_on'], unique=False)
def upgrade():
    op.add_column('role', sa.Column('password_digest', sa.Unicode))
    op.add_column('role', sa.Column('reset_token', sa.Unicode))

    op.create_index(
        op.f('role_reset_token'), 'role', ['reset_token'], unique=True
    )
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('title_page_data',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('resource_id', sa.String(), nullable=False),
    sa.Column('title', sa.String(), nullable=True),
    sa.Column('authorOne', sa.String(), nullable=True),
    sa.Column('authorTwo', sa.String(), nullable=True),
    sa.Column('authorTwoChecked', sa.String(), nullable=True),
    sa.Column('authorThree', sa.String(), nullable=True),
    sa.Column('authorThreeChecked', sa.String(), nullable=True),
    sa.Column('based_on', sa.String(), nullable=True),
    sa.Column('based_onChecked', sa.String(), nullable=True),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('addressChecked', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('phoneChecked', sa.String(), nullable=True),
    sa.Column('cell', sa.String(), nullable=True),
    sa.Column('cellChecked', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('emailChecked', sa.String(), nullable=True),
    sa.Column('registered', sa.String(), nullable=True),
    sa.Column('registeredChecked', sa.String(), nullable=True),
    sa.Column('other', sa.String(), nullable=True),
    sa.Column('otherChecked', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('resource_id')
    )
    op.create_index('ix_title_page_data_resource_id', 'title_page_data', ['resource_id'], unique=False)
def upgrade():
    if skip_based_on_legacy_engine_version(op, __name__):
        return
    op.create_index(
        'idx_package_extra_package_id', 'package_extra_revision',
        ['package_id', 'current']
    )
def downgrade():
    op.add_column('thread',
                  sa.Column('receivedrecentdate', sa.DATETIME(),
                            server_default=sa.sql.null(),
                            nullable=True))
    op.create_index('ix_thread_namespace_id_receivedrecentdate', 'thread',
                    ['namespace_id', 'receivedrecentdate'], unique=False)
Exemplo n.º 9
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('offers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=True),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('venue', sa.String(), nullable=True),
    sa.Column('start_time', sa.DateTime(), nullable=True),
    sa.Column('end_time', sa.DateTime(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(), nullable=False),
    sa.Column('last_name', sa.String(), nullable=False),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('facebook_id', sa.String(), nullable=True),
    sa.Column('hash', sa.String(), nullable=True),
    sa.Column('type', sa.Enum('Customer', 'Staff', name='user_types'), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_table('user_offer_responses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('offer_id', sa.Integer(), nullable=True),
    sa.Column('response', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['offer_id'], ['offers.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
Exemplo n.º 10
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f('ix_games_api_key'), 'games', ['api_key'], unique=True)
    op.drop_constraint(u'games_api_key_key', 'games', type_='unique')
    op.alter_column('users', 'game_id',
               existing_type=sa.INTEGER(),
               nullable=True)
def upgrade():
    op.add_column('secrets', sa.Column('project_id', sa.String(length=36),
                  nullable=True))
    op.create_index(op.f('ix_secrets_project_id'), 'secrets', ['project_id'],
                    unique=False)
    op.create_foreign_key('secrets_project_fk', 'secrets', 'projects',
                          ['project_id'], ['id'])
Exemplo n.º 12
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('order_groups',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_type', sa.Integer(), nullable=True),
    sa.Column('area_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('no', sa.Integer(), nullable=True),
    sa.Column('target', sa.String(length=64), nullable=True),
    sa.Column('now_level', sa.Integer(), nullable=True),
    sa.Column('status_id', sa.Integer(), nullable=True),
    sa.Column('create_man', sa.Integer(), nullable=True),
    sa.Column('create_date', sa.DateTime(), nullable=True),
    sa.Column('update_man', sa.Integer(), nullable=True),
    sa.Column('update_date', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['area_id'], ['areas.id'], ),
    sa.ForeignKeyConstraint(['create_man'], ['users.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['order_status.id'], ),
    sa.ForeignKeyConstraint(['update_man'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_order_groups_create_date'), 'order_groups', ['create_date'], unique=False)
    op.create_table('order_group_process',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.Column('oper', sa.Integer(), nullable=True),
    sa.Column('oper_time', sa.DateTime(), nullable=True),
    sa.Column('remark', sa.String(length=128), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['order_groups.id'], ),
    sa.ForeignKeyConstraint(['oper'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column(u'orders', sa.Column('group_id', sa.Integer(), nullable=True))
def upgrade():
    """ Add next_check and last_check columns to the projects table. """
    op.add_column(
        "projects",
        sa.Column(
            "last_check",
            sa.TIMESTAMP(timezone=True),
            default=arrow.utcnow().datetime,
            server_default=sa.func.current_timestamp(),
        ),
    )

    op.add_column(
        "projects",
        sa.Column(
            "next_check",
            sa.TIMESTAMP(timezone=True),
            default=arrow.utcnow().datetime,
            server_default=sa.func.current_timestamp(),
        ),
    )
    op.create_index(
        op.f("ix_projects_last_check"), "projects", ["last_check"], unique=False
    )
    op.create_index(
        op.f("ix_projects_next_check"), "projects", ["next_check"], unique=False
    )
def upgrade():
    op.execute('ALTER TABLE roombooking.rooms ALTER COLUMN owner_id TYPE int USING owner_id::int')
    op.create_foreign_key(None,
                          'rooms', 'users',
                          ['owner_id'], ['id'],
                          source_schema='roombooking', referent_schema='users')
    op.create_index(None, 'rooms', ['owner_id'], unique=False, schema='roombooking')
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_segments_segment'), table_name='segments')
    op.drop_index(op.f('ix_segments_part_id'), table_name='segments')
    op.drop_index(op.f('ix_releases_unwanted'), table_name='releases')
    op.drop_index(op.f('ix_releases_tvshow_metablack_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_tvshow_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_search_name'), table_name='releases')
    op.drop_index(op.f('ix_releases_regex_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_rar_metablack_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_nzb_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_nfo_metablack_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_nfo_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_movie_metablack_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_movie_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_group_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_episode_id'), table_name='releases')
    op.drop_index(op.f('ix_releases_category_id'), table_name='releases')
    op.create_index('ix_parts_subject', 'parts', ['subject'], unique=False)
    op.drop_index(op.f('ix_parts_total_segments'), table_name='parts')
    op.drop_index(op.f('ix_parts_posted'), table_name='parts')
    op.drop_index(op.f('ix_parts_group_name'), table_name='parts')
    op.drop_index(op.f('ix_parts_binary_id'), table_name='parts')
    op.drop_index(op.f('ix_movies_name'), table_name='movies')
    op.drop_index(op.f('ix_groups_active'), table_name='groups')
    op.drop_index(op.f('ix_files_release_id'), table_name='files')
    op.drop_index(op.f('ix_episodes_tvshow_id'), table_name='episodes')
    op.drop_index(op.f('ix_categories_parent_id'), table_name='categories')
    op.drop_index(op.f('ix_binaries_regex_id'), table_name='binaries')
Exemplo n.º 16
0
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('passwordHash', 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('aboutMe', 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)
def upgrade():
    op.create_table('kaltura_media',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('service_url', sa.String(length=255), nullable=False),
        sa.Column('partner_id', sa.Integer(), nullable=False),
        sa.Column('player_id', sa.Integer(), nullable=False),
        sa.Column('upload_ks', sa.String(length=255), nullable=False),
        sa.Column('upload_token_id', sa.String(length=255), nullable=False),
        sa.Column('file_name', sa.String(length=255), nullable=True),
        sa.Column('entry_id', sa.String(length=255), nullable=True),
        sa.Column('download_url', sa.String(length=255), nullable=True),
        sa.Column('modified_user_id', sa.Integer(), nullable=True),
        sa.Column('modified', sa.DateTime(), nullable=False),
        sa.Column('created_user_id', sa.Integer(), nullable=True),
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['created_user_id'], ['user.id'], ondelete='SET NULL'),
        sa.ForeignKeyConstraint(['modified_user_id'], ['user.id'], ondelete='SET NULL'),
        sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8',
        mysql_collate='utf8_unicode_ci',
        mysql_engine='InnoDB'
    )
    op.create_index(op.f('ix_kaltura_media_upload_token_id'), 'kaltura_media', ['upload_token_id'], unique=False)

    with op.batch_alter_table('file', naming_convention=convention) as batch_op:
        batch_op.add_column(sa.Column('kaltura_media_id', sa.Integer(), nullable=True))
        batch_op.create_foreign_key('fk_file_kaltura_media_id_kaltura_media',
            'kaltura_media', ['kaltura_media_id'], ['id'], ondelete="SET NULL")
Exemplo n.º 18
0
def upgrade():
    op.drop_constraint('fk_organization_owners_id', 'organization', type_='foreignkey')
    op.create_foreign_key('organization_owners_id_fkey', 'organization', 'team', ['owners_id'], ['id'])
    op.add_column('organization', sa.Column('members_id', sa.Integer(), nullable=True))
    op.create_foreign_key('organization_members_id_fkey', 'organization', 'team', ['members_id'], ['id'])
    op.add_column('team', sa.Column('domain', sa.Unicode(length=253), nullable=True))
    op.create_index(op.f('ix_team_domain'), 'team', ['domain'], unique=False)
def downgrade():
	op.create_index('ix_tbt_book_course_code', 'tbt_book_course', ['code'], unique=False)
	op.drop_index('tbt_book_course_code_revidx', table_name='tbt_book_course')
	op.drop_index('tbt_book_course_code_idx', table_name='tbt_book_course')
	op.drop_index(op.f('ix_tbt_book_seller'), table_name='tbt_book')
	op.drop_index(op.f('ix_tbt_book_buyer'), table_name='tbt_book')
	op.drop_index('banner_time', table_name='banner')
Exemplo n.º 20
0
def upgrade():
    op.create_table(
        'ad',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('asin', sa.String(20), nullable=False),
        sa.Column('title', sa.String(128), nullable=False),
        sa.Column('url', sa.String(1024), nullable=False),
        sa.Column('description', sa.String(256), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('asin', name='ux_ad_asin'),
    )
    op.create_table(
        'link_ad',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('issue_id', sa.Integer(), nullable=False),
        sa.Column('link_id', sa.Integer(), nullable=False),
        sa.Column('ad_id', sa.Integer(), nullable=False),
        sa.Column('weight', sa.Numeric(5, 2), nullable=False, server_default='0'),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('link_id', 'ad_id', name='ux_link_ad'),
    )
    op.create_index('ix_link_weight', 'link_ad', ['link_id', 'weight'], unique=False)
    op.create_index('ix_issue_weight', 'link_ad', ['issue_id', 'weight'], unique=False)
Exemplo n.º 21
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('project',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=120), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_project_name'), 'project', ['name'], unique=False)
    op.create_table('story',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('text', sa.Text(), nullable=True),
    sa.Column('role', sa.Text(), nullable=True),
    sa.Column('means', sa.Text(), nullable=True),
    sa.Column('ends', sa.Text(), nullable=True),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('defect',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('highlight', sa.Text(), nullable=False),
    sa.Column('kind', sa.String(length=120), nullable=False),
    sa.Column('subkind', sa.String(length=120), nullable=False),
    sa.Column('severity', sa.String(length=120), nullable=False),
    sa.Column('story_id', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['story_id'], ['story.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_defect_kind'), 'defect', ['kind'], unique=False)
Exemplo n.º 22
0
def upgrade():
    for index_name, table_name, column_name in [
            ('ix_comment_post_id', 'comment', 'post_id'),
            ('ix_comment_user_id', 'comment', 'user_id'),
            ('ix_comment_score_user_id', 'comment_score', 'user_id'),
            ('ix_post_user_id', 'post', 'user_id'),
            ('ix_post_favorite_post_id', 'post_favorite', 'post_id'),
            ('ix_post_favorite_user_id', 'post_favorite', 'user_id'),
            ('ix_post_feature_post_id', 'post_feature', 'post_id'),
            ('ix_post_feature_user_id', 'post_feature', 'user_id'),
            ('ix_post_note_post_id', 'post_note', 'post_id'),
            ('ix_post_relation_child_id', 'post_relation', 'child_id'),
            ('ix_post_relation_parent_id', 'post_relation', 'parent_id'),
            ('ix_post_score_post_id', 'post_score', 'post_id'),
            ('ix_post_score_user_id', 'post_score', 'user_id'),
            ('ix_post_tag_post_id', 'post_tag', 'post_id'),
            ('ix_post_tag_tag_id', 'post_tag', 'tag_id'),
            ('ix_snapshot_resource_id', 'snapshot', 'resource_id'),
            ('ix_snapshot_resource_type', 'snapshot', 'resource_type'),
            ('ix_tag_category_id', 'tag', 'category_id'),
            ('ix_tag_implication_child_id', 'tag_implication', 'child_id'),
            ('ix_tag_implication_parent_id', 'tag_implication', 'parent_id'),
            ('ix_tag_name_tag_id', 'tag_name', 'tag_id'),
            ('ix_tag_suggestion_child_id', 'tag_suggestion', 'child_id'),
            ('ix_tag_suggestion_parent_id', 'tag_suggestion', 'parent_id')]:
        op.create_index(
            op.f(index_name), table_name, [column_name], unique=False)
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('offers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=True),
    sa.Column('country', sa.String(), nullable=True),
    sa.Column('city', sa.String(), nullable=True),
    sa.Column('start_date', sa.Date(), nullable=True),
    sa.Column('end_date', sa.Date(), nullable=True),
    sa.Column('duration_months', sa.Integer(), nullable=True),
    sa.Column('organization', sa.String(), nullable=True),
    sa.Column('salary', sa.Integer(), nullable=True),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('publication_date', sa.Date(), nullable=True),
    sa.Column('mission_type', sa.String(), nullable=True),
    sa.Column('jobs_availables', sa.Integer(), nullable=True),
    sa.Column('required_exerience_months', sa.Integer(), nullable=True),
    sa.Column('required_education_level', sa.String(), nullable=True),
    sa.Column('required_languages', sa.String(), nullable=True),
    sa.Column('required_skills', sa.String(), nullable=True),
    sa.Column('required_education_type', sa.String(), nullable=True),
    sa.Column('location', geoalchemy2.types.Geography(geometry_type='POINT', srid=4326), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('inserted_date', sa.DateTime(), nullable=True),
    sa.Column('updated_date', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_offers_location', 'offers', ['location'], unique=False)
Exemplo n.º 24
0
def downgrade():
    op.create_table('version')
    op.create_index('ix_user_user_id', 'user', ['_user_id'], unique=False)
    op.drop_index(op.f('ix_user__user_id'), table_name='user')
    op.add_column(
        'mailinglist',
        sa.Column('acceptable_aliases_id', sa.INTEGER(), nullable=True))
def index_cleanup(engine_names, table_name, uniq_name, columns, create,
                  unique, limited):
    bind = op.get_bind()
    engine = bind.engine
    if engine.name not in engine_names:
        return
    if create:
        if limited and engine.name == 'mysql':
            # For some versions of mysql we can get an error
            # "Specified key was too long; max key length is 1000 bytes".
            # We should create an index by hand in this case with limited
            # length of columns.
            meta = sa.MetaData()
            meta.bind = engine
            table = sa.Table(table_name, meta, autoload=True)
            columns_mysql = ",".join((c + "(100)" for c in columns))
            sql = ("create index %s ON %s (%s)" % (uniq_name, table,
                                                   columns_mysql))
            engine.execute(sql)
        else:
            op.create_index(uniq_name, table_name, columns, unique=unique)
    else:
        if unique:
            op.drop_constraint(uniq_name, table_name, type='unique')
        else:
            op.drop_index(uniq_name, table_name=table_name)
def upgrade():
    ctx = op.get_context()
    con = op.get_bind()
    table_exists = ctx.dialect.has_table(con.engine, 'project_quotas')
    if not table_exists:
        op.create_table(
            'project_quotas',
            sa.Column('id', sa.String(length=36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=False),
            sa.Column('updated_at', sa.DateTime(), nullable=False),
            sa.Column('deleted_at', sa.DateTime(), nullable=True),
            sa.Column('deleted', sa.Boolean(), nullable=False),
            sa.Column('status', sa.String(length=20), nullable=False),
            sa.Column('project_id', sa.String(length=36), nullable=False),
            sa.Column('secrets', sa.Integer(), nullable=True),
            sa.Column('orders', sa.Integer(), nullable=True),
            sa.Column('containers', sa.Integer(), nullable=True),
            sa.Column('transport_keys', sa.Integer(), nullable=True),
            sa.Column('consumers', sa.Integer(), nullable=True),
            sa.ForeignKeyConstraint(['project_id'],
                                    ['projects.id'],
                                    name='project_quotas_fk'),
            sa.PrimaryKeyConstraint('id'),
            mysql_engine='InnoDB')
        op.create_index(
            op.f('ix_project_quotas_project_id'),
            'project_quotas',
            ['project_id'],
            unique=False)
def upgrade():
    op.add_column('attributes',
                  sa.Column('node', sa.Integer, default=0))
    op.add_column('attributes',
                  sa.Column('is_latest', sa.Boolean, default=True))

    n = table('nodes',
              column('node', sa.Integer),
              column('latest_version', sa.Integer))
    v = table('versions',
              column('node', sa.Integer),
              column('serial', sa.Integer))
    a = table('attributes',
              column('serial', sa.Integer),
              column('node', sa.Integer),
              column('is_latest', sa.Boolean))

    s = sa.select([v.c.node]).where(v.c.serial == a.c.serial)
    u = a.update().values({'node': s})
    op.execute(u)

    s = sa.select([v.c.serial == n.c.latest_version],
                  and_(a.c.node == n.c.node, a.c.serial == v.c.serial))
    u = a.update().values({'is_latest': s})
    op.execute(u)

    op.alter_column('attributes', 'node', nullable=False)
    op.alter_column('attributes', 'is_latest', nullable=False)

    op.create_index('idx_attributes_serial_node', 'attributes',
                    ['serial', 'node'])
Exemplo n.º 28
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('tweet_by_tweet_id', table_name='tweet')
    op.create_index('tweet_by_tweet_id', 'tweet', ['tweet_id'], unique=False)
    op.drop_index('tweetentity_by_tweet_id', table_name='tweet_entity')
    op.drop_table('tweet_entity')
    op.drop_table('tuser_tuser')
Exemplo n.º 29
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('service_matching',
    sa.Column('headcode', sa.String(length=20), nullable=False),
    sa.Column('origin_location', sa.String(length=20), nullable=False),
    sa.Column('origin_departure', sa.DateTime(), nullable=False),
    sa.Column('gps_car_id', sa.String(length=20), nullable=False),
    sa.Column('total_matching', sa.Integer(), nullable=False),
    sa.Column('median_time_error', sa.Float(), nullable=False),
    sa.Column('variance_time_error', sa.Float(), nullable=False),
    sa.PrimaryKeyConstraint('headcode', 'origin_location', 'origin_departure', 'gps_car_id')
    )
    op.create_index('service_matching_service_lookup', 'service_matching', ['headcode', 'origin_location', 'origin_departure'], unique=False)
    op.create_index('service_matching_unit_lookup', 'service_matching', ['gps_car_id'], unique=False)
    op.alter_column(u'event_matching', 'time_error',
               existing_type=postgresql.DOUBLE_PRECISION(precision=53),
               nullable=False)
    op.alter_column(u'geographical_location', 'latitude',
               existing_type=postgresql.DOUBLE_PRECISION(precision=53),
               type_=sa.Float(precision=32),
               existing_nullable=True)
    op.alter_column(u'geographical_location', 'longitude',
               existing_type=postgresql.DOUBLE_PRECISION(precision=53),
               type_=sa.Float(precision=32),
               existing_nullable=True)
Exemplo n.º 30
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('publishers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', citext.CIText(), nullable=False),
    sa.Column('site', sa.Text(), nullable=True),
    sa.Column('series', sa.Integer(), nullable=True),
    sa.Column('changetime', sa.DateTime(), nullable=False),
    sa.Column('changeuser', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['changeuser'], ['users.id'], ),
    sa.ForeignKeyConstraint(['series'], ['series.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('series', 'name')
    )
    op.create_index(op.f('ix_publishers_changetime'), 'publishers', ['changetime'], unique=False)
    op.create_index(op.f('ix_publishers_changeuser'), 'publishers', ['changeuser'], unique=False)
    op.create_table('publisherschanges',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', citext.CIText(), nullable=False),
    sa.Column('site', sa.Text(), nullable=True),
    sa.Column('operation', sa.Text(), nullable=True),
    sa.Column('srccol', sa.Integer(), nullable=True),
    sa.Column('series', sa.Integer(), nullable=True),
    sa.Column('changetime', sa.DateTime(), nullable=False),
    sa.Column('changeuser', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['changeuser'], ['users.id'], ),
    sa.ForeignKeyConstraint(['series'], ['series.id'], ),
    sa.ForeignKeyConstraint(['srccol'], ['publishers.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id'),
    )
    op.create_index(op.f('ix_publisherschanges_changetime'), 'publisherschanges', ['changetime'], unique=False)
    op.create_index(op.f('ix_publisherschanges_changeuser'), 'publisherschanges', ['changeuser'], unique=False)
    op.create_index(op.f('ix_publisherschanges_srccol'), 'publisherschanges', ['srccol'], unique=False)
Exemplo n.º 31
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ih_area_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_facility_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_user_profile',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('mobile', sa.String(length=11), nullable=False),
    sa.Column('real_name', sa.String(length=20), nullable=True),
    sa.Column('id_card', sa.String(length=20), nullable=True),
    sa.Column('avatar_url', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('mobile'),
    sa.UniqueConstraint('name')
    )
    op.create_table('ih_house_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=64), nullable=False),
    sa.Column('price', sa.Integer(), nullable=True),
    sa.Column('address', sa.String(length=512), nullable=True),
    sa.Column('room_count', sa.Integer(), nullable=True),
    sa.Column('acreage', sa.Integer(), nullable=True),
    sa.Column('unit', sa.String(length=32), nullable=True),
    sa.Column('capacity', sa.Integer(), nullable=True),
    sa.Column('beds', sa.String(length=64), nullable=True),
    sa.Column('deposit', sa.Integer(), nullable=True),
    sa.Column('min_days', sa.Integer(), nullable=True),
    sa.Column('max_days', sa.Integer(), nullable=True),
    sa.Column('order_count', sa.Integer(), nullable=True),
    sa.Column('index_image_url', sa.String(length=256), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('area_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['area_id'], ['ih_area_info.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['ih_user_profile.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_house_facility',
    sa.Column('house_id', sa.Integer(), nullable=False),
    sa.Column('facility_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['facility_id'], ['ih_facility_info.id'], ),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.PrimaryKeyConstraint('house_id', 'facility_id')
    )
    op.create_table('ih_house_image',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('url', sa.String(length=256), nullable=False),
    sa.Column('house_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_order_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('begin_date', sa.DateTime(), nullable=False),
    sa.Column('end_date', sa.DateTime(), nullable=False),
    sa.Column('days', sa.Integer(), nullable=False),
    sa.Column('house_price', sa.Integer(), nullable=False),
    sa.Column('amount', sa.Integer(), nullable=False),
    sa.Column('status', sa.Enum('WAIT_ACCEPT', 'WAIT_PAYMENT', 'PAID', 'WAIT_COMMENT', 'COMPLETE', 'CANCELED', 'REJECTED'), nullable=True),
    sa.Column('comment', sa.Text(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('house_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['ih_user_profile.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ih_order_info_status'), 'ih_order_info', ['status'], unique=False)
Exemplo n.º 32
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('items', 'expiration_period')
    op.drop_column('inventory', 'expiration')
    op.create_index('name', 'cases', ['name'], unique=True)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sms_broadcast',
                    sa.Column('id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('date_created',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('last_modified',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('provider_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('name', sa.String(), nullable=False),
                    sa.Column('description', sa.String(), nullable=True),
                    sa.Column('is_published', sa.Boolean(), nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    schema='sms')
    op.create_table('sms_broadcast_message',
                    sa.Column('id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('date_created',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('last_modified',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('broadcast_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('subject', sa.String(), nullable=False),
                    sa.Column('message', sa.String(), nullable=False),
                    sa.Column('send_on_day_relative',
                              sa.Integer(),
                              nullable=True),
                    sa.Column('send_on_day_absolute',
                              sa.DateTime(),
                              nullable=True),
                    sa.ForeignKeyConstraint(['broadcast_id'],
                                            ['sms.sms_broadcast.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    schema='sms')
    op.create_index(op.f('ix_sms_sms_broadcast_message_broadcast_id'),
                    'sms_broadcast_message', ['broadcast_id'],
                    unique=False,
                    schema='sms')
    op.create_table('sms_message',
                    sa.Column('id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('date_created',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('last_modified',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('provider_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=True),
                    sa.Column('broadcast_message_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=True),
                    sa.Column('farmer_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=True),
                    sa.Column('phone', sa.String(), nullable=False),
                    sa.Column('send_at', sa.DateTime(), nullable=True),
                    sa.Column('sent', sa.Boolean(), nullable=False),
                    sa.Column('message', sa.String(), nullable=False),
                    sa.Column('africastalking_sms_id',
                              sa.String(),
                              nullable=True),
                    sa.Column('africastalking_sms_cost',
                              sa.String(),
                              nullable=True),
                    sa.ForeignKeyConstraint(['broadcast_message_id'],
                                            ['sms.sms_broadcast_message.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    schema='sms')
    op.create_index(op.f('ix_sms_sms_message_africastalking_sms_id'),
                    'sms_message', ['africastalking_sms_id'],
                    unique=True,
                    schema='sms')
    op.create_index(op.f('ix_sms_sms_message_broadcast_message_id'),
                    'sms_message', ['broadcast_message_id'],
                    unique=False,
                    schema='sms')
    op.create_index(op.f('ix_sms_sms_message_phone'),
                    'sms_message', ['phone'],
                    unique=False,
                    schema='sms')
    op.create_table('sms_log',
                    sa.Column('id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('date_created',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('last_modified',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('sms_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('status', sa.String(), nullable=False),
                    sa.Column('network_code', sa.String(), nullable=True),
                    sa.Column('failure_reason', sa.String(), nullable=True),
                    sa.ForeignKeyConstraint(['sms_id'], ['sms.sms_message.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    schema='sms')
    op.create_index(op.f('ix_sms_sms_log_sms_id'),
                    'sms_log', ['sms_id'],
                    unique=False,
                    schema='sms')
    op.create_table('sms_broadcast_subscription',
                    sa.Column('id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('date_created',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('last_modified',
                              sa.DateTime(timezone=True),
                              nullable=True),
                    sa.Column('broadcast_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('farmer_id',
                              postgresql.UUID(as_uuid=True),
                              nullable=False),
                    sa.Column('day_zero', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(['broadcast_id'],
                                            ['sms.sms_broadcast.id'],
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    schema='sms')
    op.create_index(op.f('ix_sms_broadcast_subscription_broadcast_id'),
                    'sms_broadcast_subscription', ['broadcast_id'],
                    unique=False,
                    schema='sms')
Exemplo n.º 34
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('email', sa.String(length=64), nullable=True))
    op.add_column('users', sa.Column('password_hash', sa.String(length=128), nullable=True))
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
Exemplo n.º 35
0
def upgrade():
    op.create_table(
        "forj_user",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('password', sa.String(128)),
        sa.Column('last_login', sa.DateTime(timezone=True), nullable=True),
        sa.Column('is_superuser', sa.Boolean),
        sa.Column('first_name', sa.String(30)),
        sa.Column('last_name', sa.String(150)),
        sa.Column('stripe_customer_id', sa.String(100), nullable=True),
        sa.Column('email', sa.String(254), unique=True),
        sa.Column('is_staff', sa.Boolean),
        sa.Column('is_active', sa.Boolean),
        sa.Column('date_joined', sa.DateTime(timezone=True)),
    )

    op.create_index('forj_user__email__idx', 'forj_user', ['email'])

    op.create_table(
        "forj_address",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('type', sa.SmallInteger, nullable=False),
        sa.Column('first_name', sa.String(250), nullable=True),
        sa.Column('last_name', sa.String(250), nullable=True),
        sa.Column('business_name', sa.String(250), nullable=True),
        sa.Column('line1', sa.Text, nullable=True),
        sa.Column('line2', sa.Text, nullable=True),
        sa.Column('postal_code', sa.String(140), nullable=True),
        sa.Column('city', sa.String(140), nullable=True),
        sa.Column('country', sa.String(2), nullable=True),
        sa.Column('phone_number', sa.String(20), nullable=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_address__user_id__idx', 'forj_address', ['user_id'])

    op.create_table(
        "forj_product",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(100)),
        sa.Column('reference', sa.String(100)),
        sa.Column('description', sa.Text, nullable=True),
        sa.Column('price', sa.Integer, nullable=True),
        sa.Column('condition', sa.String(100), nullable=True),
        sa.Column('formula', sa.String(100), nullable=True),
        sa.Column('currency', sa.String(3)),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_product__reference__idx', 'forj_product',
                    ['reference'])

    op.create_table(
        "forj_order",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('amount', sa.Integer),
        sa.Column('currency', sa.String(3)),
        sa.Column('reference', sa.String(30)),
        sa.Column('status', sa.SmallInteger, nullable=False),
        sa.Column('shipping_status', sa.SmallInteger, nullable=False),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('shipping_address_id',
                  sa.Integer,
                  sa.ForeignKey('forj_address.id'),
                  nullable=True),
        sa.Column('billing_address_id',
                  sa.Integer,
                  sa.ForeignKey('forj_address.id'),
                  nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('stripe_card_id', sa.String(100), nullable=True),
        sa.Column('stripe_source_id', sa.String(100), nullable=True),
        sa.Column('stripe_charge_id', sa.String(100), nullable=True),
    )

    op.create_index('forj_order__user_id__idx', 'forj_order', ['user_id'])

    op.create_table(
        "forj_orderitem",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('quantity', sa.Integer, server_default="0"),
        sa.Column('amount', sa.Integer),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('order_id', sa.Integer, sa.ForeignKey('forj_order.id')),
        sa.Column('product_id', sa.Integer, sa.ForeignKey('forj_product.id')),
        sa.Column('product_reference', sa.String(100)),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_orderitem__product_id__idx', 'forj_orderitem',
                    ['product_id'])

    op.create_table(
        "auth_group",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(80)),
    )

    op.create_index('auth_group__name__idx', 'auth_group', ['name'])

    op.create_table(
        "forj_user_groups",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('group_id', sa.Integer, sa.ForeignKey('auth_group.id')),
    )

    op.create_unique_constraint('forj_user_groups__user_id__group_id__uniq',
                                'forj_user_groups', ['user_id', 'group_id'])

    op.create_table(
        "django_session",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('session_key', sa.String(40)),
        sa.Column('session_data', sa.Text),
        sa.Column('expire_date', sa.DateTime(timezone=True)),
    )

    op.create_unique_constraint('django_session__expire_date__idx',
                                'django_session', ['expire_date'])

    op.create_table(
        "django_content_type",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('app_label', sa.String(100)),
        sa.Column('model', sa.String(100)),
    )

    op.create_unique_constraint('django_content_type__app_label__model__uniq',
                                'django_content_type', ['app_label', 'model'])

    op.create_table(
        "auth_permission",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(255)),
        sa.Column('content_type_id', sa.Integer,
                  sa.ForeignKey('django_content_type.id')),
        sa.Column('codename', sa.String(100)),
    )

    op.create_unique_constraint(
        'auth_permission__content_type_id__codename__uniq', 'auth_permission',
        ['content_type_id', 'codename'])
    op.create_index('auth_permission__content_type_id__idx', 'auth_permission',
                    ['content_type_id'])

    op.create_table(
        "forj_user_user_permissions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('permission_id', sa.Integer,
                  sa.ForeignKey('auth_permission.id')),
    )

    op.create_unique_constraint(
        'forj_user_user_permissions__user_id__permission_id__uniq',
        'forj_user_user_permissions', ['user_id', 'permission_id'])

    op.create_table(
        "auth_group_permissions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('group_id', sa.Integer, sa.ForeignKey('auth_group.id')),
        sa.Column('permission_id', sa.Integer,
                  sa.ForeignKey('auth_permission.id')),
    )

    op.create_unique_constraint(
        'auth_group_permissions__group_id__permission_id__uniq',
        'auth_group_permissions', ['group_id', 'permission_id'])
    op.create_index('auth_group_permissions__group_id__idx',
                    'auth_group_permissions', ['group_id'])
    op.create_index('auth_group_permissions__permission_id__idx',
                    'auth_group_permissions', ['permission_id'])

    op.create_table(
        "django_admin_log",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('action_time', sa.DateTime(timezone=True)),
        sa.Column('object_id', sa.Text, nullable=True),
        sa.Column('object_repr', sa.String(200)),
        sa.Column('action_flag', sa.SmallInteger),
        sa.Column('change_message', sa.Text),
        sa.Column('content_type_id',
                  sa.Integer,
                  sa.ForeignKey('django_content_type.id'),
                  nullable=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
    )

    op.create_index('django_admin_log__content_type_id__idx',
                    'django_admin_log', ['content_type_id'])
    op.create_index('django_admin_log__user_id__idx', 'django_admin_log',
                    ['user_id'])

    op.create_check_constraint("django_admin_log_action_flag_check",
                               "django_admin_log",
                               column('action_flag') >= 0)

    op.create_table(
        "easy_thumbnails_source",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('storage_hash', sa.String(40)),
        sa.Column('name', sa.String(255)),
        sa.Column('modified', sa.DateTime(timezone=True)),
    )

    op.create_unique_constraint(
        'easy_thumbnails_source__storage_hash__name__uniq',
        'easy_thumbnails_source', ['storage_hash', 'name'])
    op.create_index('easy_thumbnails_source__name__idx',
                    'easy_thumbnails_source', ['name'])
    op.create_index('easy_thumbnails_source__storage_hash__idx',
                    'easy_thumbnails_source', ['storage_hash'])

    op.create_table(
        "easy_thumbnails_thumbnail",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(255)),
        sa.Column('storage_hash', sa.String(40)),
        sa.Column('modified', sa.DateTime(timezone=True)),
        sa.Column('source_id', sa.Integer,
                  sa.ForeignKey('easy_thumbnails_source.id')),
    )

    op.create_unique_constraint(
        'easy_thumbnails_thumbnail__storage_hash__name__source_id__uniq',
        'easy_thumbnails_thumbnail', ['storage_hash', 'name', 'source_id'])
    op.create_index('easy_thumbnails_thumbnail__name__idx',
                    'easy_thumbnails_thumbnail', ['name'])
    op.create_index('easy_thumbnails_thumbnail__storage_hash__idx',
                    'easy_thumbnails_thumbnail', ['storage_hash'])
    op.create_index('easy_thumbnails_thumbnail__source_id__idx',
                    'easy_thumbnails_thumbnail', ['source_id'])

    op.create_table(
        "easy_thumbnails_thumbnaildimensions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('thumbnail_id', sa.Integer,
                  sa.ForeignKey('easy_thumbnails_thumbnail.id')),
        sa.Column('width', sa.Integer),
        sa.Column('height', sa.Integer),
    )

    op.create_check_constraint(
        "easy_thumbnails_thumbnaildimensions__width_check",
        "easy_thumbnails_thumbnaildimensions",
        column('width') >= 0)

    op.create_check_constraint(
        "easy_thumbnails_thumbnaildimensions__height_check",
        "easy_thumbnails_thumbnaildimensions",
        column('height') >= 0)
Exemplo n.º 36
0
def upgrade():
    op.create_index('blockheight', 'block', ['height'], unique=False)
Exemplo n.º 37
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('city',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_city_name'), 'city', ['name'], unique=False)
    op.create_table('collection',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('person',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.Column('born', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('publisher',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_publisher_name'), 'publisher', ['name'], unique=False)
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.Column('default', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_table('room',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('serie',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('publisher_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['publisher_id'], ['publisher.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_serie_name'), 'serie', ['name'], unique=False)
    op.create_table('shelf',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('room_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['room_id'], ['room.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('confirmed', sa.Boolean(), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('hashed_password', sa.String(length=128), nullable=True),
    sa.Column('first_name', sa.String(length=32), nullable=False),
    sa.Column('last_name', sa.String(length=32), nullable=False),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('book',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('isbn', sa.String(length=13), nullable=True),
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('origin_title', sa.String(length=255), nullable=True),
    sa.Column('first_print', sa.Boolean(), nullable=True),
    sa.Column('origin_language', sa.String(length=32), nullable=True),
    sa.Column('pub_year', sa.String(length=32), nullable=True),
    sa.Column('first_edition', sa.String(length=64), nullable=True),
    sa.Column('literary_form', sa.Enum('PO', 'PR', 'DR', name='formchoices'), nullable=True),
    sa.Column('genre', sa.String(length=64), nullable=True),
    sa.Column('fiction', sa.Boolean(), nullable=True),
    sa.Column('precision', sa.Text(), nullable=True),
    sa.Column('nukat', sa.Text(), nullable=True),
    sa.Column('publisher_id', sa.Integer(), nullable=True),
    sa.Column('city_id', sa.Integer(), nullable=True),
    sa.Column('serie_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['city_id'], ['city.id'], ),
    sa.ForeignKeyConstraint(['publisher_id'], ['publisher.id'], ),
    sa.ForeignKeyConstraint(['serie_id'], ['serie.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('copy',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('signature_mark', sa.String(length=32), nullable=True),
    sa.Column('on_shelf', sa.Boolean(), nullable=False),
    sa.Column('section', sa.String(length=255), nullable=True),
    sa.Column('ordering', sa.String(length=255), nullable=True),
    sa.Column('remarques', sa.String(length=255), nullable=True),
    sa.Column('collection_id', sa.Integer(), nullable=True),
    sa.Column('shelf_id', sa.Integer(), nullable=False),
    sa.Column('book_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['book_id'], ['book.id'], ),
    sa.ForeignKeyConstraint(['collection_id'], ['collection.id'], ),
    sa.ForeignKeyConstraint(['shelf_id'], ['shelf.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('creator',
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_modified', sa.DateTime(timezone=True), nullable=True),
    sa.Column('approuved', sa.Boolean(), nullable=True),
    sa.Column('incorrect', sa.Boolean(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('role', sa.Enum('A', 'T', 'R', 'I', name='bookroles'), nullable=True),
    sa.Column('book_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['book_id'], ['book.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['person.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
Exemplo n.º 38
0
def upgrade():
    op.create_index(op.f('ix_content_servers_created_at'),
                    'content_servers', ['created_at'],
                    unique=False)
    op.add_column('events', sa.Column('version', sa.String(), nullable=True))
def upgrade():
    # Must be superuser to create this extension.
    # op.execute('CREATE EXTENSION hstore')
    # op.execute('CREATE EXTENSION postgis')
    op.create_table(
        'vld_user', sa.Column('osm_uid', sa.Integer(), nullable=False),
        sa.Column('osm_user', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('osm_uid'))
    op.create_table(
        'vld_state',
        sa.Column('key',
                  sa.Enum('sequence_number', name='vld_statekey_enum'),
                  nullable=False), sa.Column('value', sa.JSON(),
                                             nullable=True),
        sa.PrimaryKeyConstraint('key'))
    op.create_table(
        'vld_feature', sa.Column('handle',
                                 sa.String(length=64),
                                 nullable=False),
        sa.Column('date_created',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=False), sa.PrimaryKeyConstraint('handle'))
    op.create_table(
        'vld_issue', sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('handle', sa.String(length=64), nullable=False),
        sa.Column('changeset_created', sa.BigInteger(), nullable=True),
        sa.Column('changeset_closed', sa.BigInteger(), nullable=True),
        sa.Column('user_created', sa.BigInteger(), nullable=True),
        sa.Column('user_closed', sa.BigInteger(), nullable=True),
        sa.Column('date_created',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=False),
        sa.Column('date_closed', sa.DateTime(), nullable=True),
        sa.Column('affected_nodes',
                  postgresql.ARRAY(sa.BigInteger()),
                  nullable=True),
        sa.Column('affected_ways',
                  postgresql.ARRAY(sa.BigInteger()),
                  nullable=True),
        sa.Column('affected_rels',
                  postgresql.ARRAY(sa.BigInteger()),
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['handle'],
            ['vld_feature.handle'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_index('ix_vld_issue_handle_affected_nodes',
                    'vld_issue', ['handle', 'affected_nodes'],
                    unique=False,
                    postgresql_where=sa.text('date_closed IS NOT NULL'))
    op.create_index('ix_vld_issue_handle_affected_rels',
                    'vld_issue', ['handle', 'affected_rels'],
                    unique=False,
                    postgresql_where=sa.text('date_closed IS NOT NULL'))
    op.create_index('ix_vld_issue_handle_affected_ways',
                    'vld_issue', ['handle', 'affected_ways'],
                    unique=False,
                    postgresql_where=sa.text('date_closed IS NOT NULL'))
    op.create_index(op.f('ix_vld_issue_user_closed'),
                    'vld_issue', ['user_closed'],
                    unique=False)
    op.create_index(op.f('ix_vld_issue_user_created'),
                    'vld_issue', ['user_created'],
                    unique=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "invoices",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("amount", sa.Numeric(precision=16, scale=8), nullable=False),
        sa.Column("status", sa.String(length=1000), nullable=False),
        sa.Column("date", sa.DateTime(timezone=True), nullable=False),
        sa.Column("buyer_email", sa.String(length=10000), nullable=True),
        sa.Column("discount", sa.Integer(), nullable=True),
        sa.Column("promocode", sa.Text(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_invoices_id"), "invoices", ["id"], unique=False)
    op.create_table(
        "stores",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=1000), nullable=True),
        sa.Column("domain", sa.String(length=1000), nullable=True),
        sa.Column("template", sa.String(length=1000), nullable=True),
        sa.Column("email", sa.String(length=1000), nullable=True),
        sa.Column("email_host", sa.String(length=1000), nullable=True),
        sa.Column("email_password", sa.String(length=1000), nullable=True),
        sa.Column("email_port", sa.Integer(), nullable=True),
        sa.Column("email_use_ssl", sa.Boolean(), nullable=True),
        sa.Column("email_user", sa.String(length=1000), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_stores_domain"), "stores", ["domain"], unique=False)
    op.create_index(op.f("ix_stores_email"), "stores", ["email"], unique=False)
    op.create_index(op.f("ix_stores_id"), "stores", ["id"], unique=False)
    op.create_index(op.f("ix_stores_name"), "stores", ["name"], unique=False)
    op.create_table(
        "users",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("email", sa.String(), nullable=True),
        sa.Column("hashed_password", sa.String(), nullable=True),
        sa.Column("is_superuser", sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True)
    op.create_index(op.f("ix_users_id"), "users", ["id"], unique=False)
    op.create_table(
        "discounts",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user_id", sa.Integer(), nullable=True),
        sa.Column("name", sa.String(length=1000), nullable=True),
        sa.Column("percent", sa.Integer(), nullable=True),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("promocode", sa.Text(), nullable=True),
        sa.Column("currencies", sa.String(length=10000), nullable=True),
        sa.Column("end_date", sa.DateTime(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="SET NULL"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_discounts_currencies"), "discounts", ["currencies"], unique=False)
    op.create_index(op.f("ix_discounts_description"), "discounts", ["description"], unique=False)
    op.create_index(op.f("ix_discounts_id"), "discounts", ["id"], unique=False)
    op.create_index(op.f("ix_discounts_name"), "discounts", ["name"], unique=False)
    op.create_table(
        "paymentmethods",
        sa.Column("invoice_id", sa.Integer(), nullable=True),
        sa.Column("amount", sa.Numeric(precision=16, scale=8), nullable=False),
        sa.Column("discount", sa.Integer(), nullable=True),
        sa.Column("currency", sa.String(length=1000), nullable=True),
        sa.Column("payment_address", sa.String(length=10000), nullable=False),
        sa.Column("payment_url", sa.String(length=10000), nullable=False),
        sa.ForeignKeyConstraint(["invoice_id"], ["invoices.id"], ondelete="SET NULL"),
    )
    op.create_index(op.f("ix_paymentmethods_currency"), "paymentmethods", ["currency"], unique=False)
    op.create_table(
        "products",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=1000), nullable=True),
        sa.Column("amount", sa.Numeric(precision=16, scale=8), nullable=False),
        sa.Column("quantity", sa.Numeric(precision=16, scale=8), nullable=False),
        sa.Column("download_url", sa.String(length=100000), nullable=True),
        sa.Column("date", sa.DateTime(timezone=True), nullable=False),
        sa.Column("category", sa.Text(), nullable=True),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("image", sa.String(length=100000), nullable=True),
        sa.Column("store_id", sa.Integer(), nullable=True),
        sa.Column("status", sa.String(length=1000), nullable=False),
        sa.ForeignKeyConstraint(
            ["store_id"],
            ["stores.id"],
            ondelete="SET NULL",
            initially="DEFERRED",
            deferrable=True,
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_products_id"), "products", ["id"], unique=False)
    op.create_index(op.f("ix_products_name"), "products", ["name"], unique=False)
    op.create_index(op.f("ix_products_store_id"), "products", ["store_id"], unique=False)
    op.create_table(
        "wallets",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=1000), nullable=True),
        sa.Column("xpub", sa.String(length=1000), nullable=True),
        sa.Column("currency", sa.String(length=1000), nullable=True),
        sa.Column("balance", sa.Numeric(precision=16, scale=8), nullable=True),
        sa.Column("user_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="SET NULL"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_wallets_currency"), "wallets", ["currency"], unique=False)
    op.create_index(op.f("ix_wallets_id"), "wallets", ["id"], unique=False)
    op.create_index(op.f("ix_wallets_name"), "wallets", ["name"], unique=False)
    op.create_index(op.f("ix_wallets_xpub"), "wallets", ["xpub"], unique=False)
    op.create_table(
        "discountsxproducts",
        sa.Column("discount_id", sa.Integer(), nullable=True),
        sa.Column("product_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["discount_id"], ["discounts.id"], ondelete="SET NULL"),
        sa.ForeignKeyConstraint(["product_id"], ["products.id"], ondelete="SET NULL"),
    )
    op.create_table(
        "productsxinvoices",
        sa.Column("product_id", sa.Integer(), nullable=True),
        sa.Column("invoice_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["invoice_id"], ["invoices.id"], ondelete="SET NULL"),
        sa.ForeignKeyConstraint(["product_id"], ["products.id"], ondelete="SET NULL"),
    )
    op.create_table(
        "walletsxstores",
        sa.Column("wallet_id", sa.Integer(), nullable=True),
        sa.Column("store_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["store_id"], ["stores.id"], ondelete="SET NULL"),
        sa.ForeignKeyConstraint(["wallet_id"], ["wallets.id"], ondelete="SET NULL"),
    )
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'knowledgeArea',
        sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.PrimaryKeyConstraint('area_cod'))
    op.create_index(op.f('ix_knowledgeArea_name'),
                    'knowledgeArea', ['name'],
                    unique=True)
    op.create_table(
        'universityDegree',
        sa.Column('university_cod', sa.String(length=64), nullable=False),
        sa.Column('acronym', sa.String(length=64), nullable=True),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('study_center', sa.String(length=64), nullable=True),
        sa.Column('plan_cod', sa.String(length=64), nullable=True),
        sa.Column('special_cod', sa.String(length=64), nullable=True),
        sa.PrimaryKeyConstraint('university_cod'))
    op.create_index(op.f('ix_universityDegree_acronym'),
                    'universityDegree', ['acronym'],
                    unique=True)
    op.create_index(op.f('ix_universityDegree_name'),
                    'universityDegree', ['name'],
                    unique=True)
    op.create_table(
        'teacher', sa.Column('dni', sa.String(length=64), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('surnames', sa.String(length=64), nullable=True),
        sa.Column('area_cod', sa.String(length=64), nullable=True),
        sa.Column('potential', sa.String(length=64), nullable=True),
        sa.Column('tutorial_hours', sa.String(length=64), nullable=True),
        sa.ForeignKeyConstraint(
            ['area_cod'],
            ['knowledgeArea.area_cod'],
        ), sa.PrimaryKeyConstraint('dni'))
    op.create_table(
        'subject',
        sa.Column('subject_cod', sa.String(length=64), nullable=False),
        sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('university_cod', sa.String(length=64), nullable=True),
        sa.Column('coordinator_dni', sa.String(length=64), nullable=True),
        sa.Column('responsible_dni', sa.String(length=64), nullable=True),
        sa.Column('academic_year', sa.String(length=64), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('course', sa.String(length=64), nullable=False),
        sa.Column('semester', sa.String(length=64), nullable=False),
        sa.Column('type', sa.String(length=64), nullable=False),
        sa.ForeignKeyConstraint(
            ['area_cod'],
            ['knowledgeArea.area_cod'],
        ), sa.ForeignKeyConstraint(
            ['coordinator_dni'],
            ['teacher.dni'],
        ), sa.ForeignKeyConstraint(
            ['responsible_dni'],
            ['teacher.dni'],
        ),
        sa.ForeignKeyConstraint(
            ['university_cod'],
            ['universityDegree.university_cod'],
        ), sa.PrimaryKeyConstraint('subject_cod', 'area_cod'))
    op.create_table(
        'tutorial',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('teacher_dni', sa.String(length=64), nullable=False),
        sa.Column('first_semester', sa.String(length=128), nullable=True),
        sa.Column('second_semester', sa.String(length=128), nullable=True),
        sa.Column('hours', sa.String(length=50), nullable=True),
        sa.ForeignKeyConstraint(
            ['teacher_dni'],
            ['teacher.dni'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_tutorial_teacher_dni'),
                    'tutorial', ['teacher_dni'],
                    unique=True)
    op.create_table(
        'user',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('username', sa.String(length=64), nullable=False),
        sa.Column('password', sa.String(length=128), nullable=False),
        sa.Column('teacher_dni', sa.String(length=64), nullable=True),
        sa.Column('isAdmin', sa.Boolean(), nullable=False),
        sa.Column('public_id', sa.String(length=50), nullable=True),
        sa.ForeignKeyConstraint(
            ['teacher_dni'],
            ['teacher.dni'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('public_id'))
    op.create_index(op.f('ix_user_teacher_dni'),
                    'user', ['teacher_dni'],
                    unique=True)
    op.create_index(op.f('ix_user_username'),
                    'user', ['username'],
                    unique=True)
    op.create_table(
        'veniaI', sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('teacher_dni', sa.String(length=64), nullable=False),
        sa.Column('approved', sa.Boolean(), nullable=True),
        sa.Column('rejected', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(
            ['area_cod'],
            ['knowledgeArea.area_cod'],
        ), sa.ForeignKeyConstraint(
            ['teacher_dni'],
            ['teacher.dni'],
        ), sa.PrimaryKeyConstraint('area_cod', 'teacher_dni'))
    op.create_table(
        'PDA', sa.Column('id',
                         sa.Integer(),
                         autoincrement=True,
                         nullable=False),
        sa.Column('subject_cod', sa.String(length=64), nullable=False),
        sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('status', sa.String(length=64), nullable=True),
        sa.Column('observations', sa.String(length=128), nullable=True),
        sa.ForeignKeyConstraint(
            ['subject_cod', 'area_cod'],
            ['subject.subject_cod', 'subject.area_cod'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'group', sa.Column('group_cod', sa.String(length=64), nullable=False),
        sa.Column('subject_cod', sa.String(length=64), nullable=False),
        sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('type', sa.String(length=64), nullable=True),
        sa.Column('hours', sa.String(length=64), nullable=True),
        sa.ForeignKeyConstraint(
            ['subject_cod', 'area_cod'],
            ['subject.subject_cod', 'subject.area_cod'],
        ), sa.PrimaryKeyConstraint('group_cod', 'subject_cod', 'area_cod'))
    op.create_table(
        'veniaII', sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('subject_cod', sa.String(length=64), nullable=False),
        sa.Column('teacher_dni', sa.String(length=64), nullable=False),
        sa.Column('approved', sa.Boolean(), nullable=True),
        sa.Column('rejected', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(
            ['subject_cod', 'area_cod'],
            ['subject.subject_cod', 'subject.area_cod'],
        ), sa.ForeignKeyConstraint(
            ['teacher_dni'],
            ['teacher.dni'],
        ), sa.PrimaryKeyConstraint('area_cod', 'subject_cod', 'teacher_dni'))
    op.create_table(
        'impart', sa.Column('group_cod', sa.String(length=64), nullable=False),
        sa.Column('subject_cod', sa.String(length=64), nullable=False),
        sa.Column('area_cod', sa.String(length=64), nullable=False),
        sa.Column('teacher_dni', sa.String(length=64), nullable=False),
        sa.Column('hours', sa.String(length=64), nullable=True),
        sa.Column('approved', sa.Boolean(), nullable=True),
        sa.Column('rejected', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(
            ['group_cod', 'subject_cod', 'area_cod'],
            ['group.group_cod', 'group.subject_cod', 'group.area_cod'],
        ), sa.ForeignKeyConstraint(
            ['teacher_dni'],
            ['teacher.dni'],
        ),
        sa.PrimaryKeyConstraint('group_cod', 'subject_cod', 'area_cod',
                                'teacher_dni'))
Exemplo n.º 42
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('roles', sa.Column('default', sa.Boolean(), nullable=True))
    op.add_column('roles', sa.Column('permissions', sa.Integer(), nullable=True))
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f('ix_user_token'), 'user', ['token'], unique=True)
Exemplo n.º 44
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.create_index('ix_users_username', 'users', ['username'], unique=False)
Exemplo n.º 45
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        op.f("is_current_blocks_idx"), "blocks", ["is_current"], unique=False
    )