Python sqlalchemy 模块,Text() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.Text()

项目:zipline-chinese    作者:zhanghan1990    | 项目源码 | 文件源码
def _equities_table_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'equities',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('symbol', sa.Text),
        sa.Column('company_symbol', sa.Text, index=True),
        sa.Column('share_class_symbol', sa.Text),
        sa.Column('fuzzy_symbol', sa.Text, index=True),
        sa.Column('asset_name', sa.Text),
        sa.Column('start_date', sa.Integer, default=0, nullable=False),
        sa.Column('end_date', sa.Integer, nullable=False),
        sa.Column('first_traded', sa.Integer, nullable=False),
        sa.Column('auto_close_date', sa.Integer),
        sa.Column('exchange', sa.Text),
    )
项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topic_suggestion',
    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('title', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('is_recorded', sa.Boolean(), nullable=False),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_topic_suggestion_id'), 'topic_suggestion', ['id'], unique=False)
    op.create_index(op.f('ix_topic_suggestion_title'), 'topic_suggestion', ['title'], unique=False)
    op.create_index(op.f('ix_episode_id'), 'episode', ['id'], unique=False)
    op.create_index(op.f('ix_podcast_id'), 'podcast', ['id'], unique=False)
    op.create_index(op.f('ix_popular_term_id'), 'popular_term', ['id'], unique=False)
    op.create_index(op.f('ix_tag_id'), 'tag', ['id'], unique=False)
    ### end Alembic commands ###
项目:kuberdock-platform    作者:cloudlinux    | 项目源码 | 文件源码
def upgrade():
    op.execute(sa.schema.CreateSequence(sa.Sequence('pod_states_id_seq')))
    op.add_column('pod_states', sa.Column('id', sa.Integer(), nullable=False,
                  server_default=sa.text("nextval('pod_states_id_seq'::regclass)")))
    op.execute("ALTER TABLE pod_states DROP CONSTRAINT pod_states_pkey, "
               "ADD CONSTRAINT pod_states_pkey PRIMARY KEY (id);")

    op.add_column('container_states', sa.Column('exit_code', sa.Integer(), nullable=True))
    op.add_column('container_states', sa.Column('pod_state_id', sa.Integer(), nullable=True))
    op.add_column('container_states', sa.Column('reason', sa.Text(), nullable=True))
    op.create_index('ix_pod_id_start_time', 'pod_states', ['pod_id', 'start_time'], unique=True)
    op.create_foreign_key('container_states_pod_state_id_fkey', 'container_states',
                          'pod_states', ['pod_state_id'], ['id'])

    upgrade_data()

    op.alter_column('container_states', 'pod_state_id',
                    existing_type=sa.INTEGER(), nullable=False)
    op.drop_constraint(u'container_states_pod_id_fkey', 'container_states',
                       type_='foreignkey')
    op.drop_column('container_states', 'pod_id')
项目:flask-react-redux-demo    作者:eddowh    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('restaurants_restaurant',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=250), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('restaurants_menuitem',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('price', sa.Numeric(precision=2), nullable=False),
    sa.Column('course', sa.String(length=250), nullable=True),
    sa.Column('restaurant_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['restaurant_id'], ['restaurants_restaurant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
项目:zipline-chinese    作者:zhanghan1990    | 项目源码 | 文件源码
def _futures_root_symbols_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'futures_root_symbols',
        metadata,
        sa.Column(
            'root_symbol',
            sa.Text,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('root_symbol_id', sa.Integer),
        sa.Column('sector', sa.Text),
        sa.Column('description', sa.Text),
        sa.Column(
            'exchange',
            sa.Text,
            sa.ForeignKey('futures_exchanges.exchange'),
        ),
    )
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'project_stats',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('project_id', sa.Integer, sa.ForeignKey('project.id',
                                                          ondelete='CASCADE')),
        sa.Column('n_tasks', sa.Integer, default=0),
        sa.Column('n_task_runs', sa.Integer, default=0),
        sa.Column('n_results', sa.Integer, default=0),
        sa.Column('n_volunteers', sa.Integer, default=0),
        sa.Column('n_completed_tasks', sa.Integer, default=0),
        sa.Column('overall_progress', sa.Integer, default=0),
        sa.Column('average_time', sa.Float, default=0),
        sa.Column('n_blogposts', sa.Integer, default=0),
        sa.Column('last_activity', sa.Text, default=make_timestamp),
        sa.Column('info', JSON, nullable=False)
    )
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('app', sa.Column('updated', sa.Text, default=make_timestamp))
    op.add_column('app', sa.Column('contacted', sa.Boolean, default=False))
    op.add_column('app', sa.Column('completed', sa.Boolean, default=False))
    # Update all projects to the day the migration is run
    query = "UPDATE app SET updated='%s'" % make_timestamp()
    op.execute(query)
    # Update the state of the projects
    # Put all of them to false
    query = 'UPDATE app SET completed=false'
    op.execute(query)
    # Update to completed those that are not included in the set
    query = "UPDATE app SET completed=true WHERE id NOT IN (SELECT app_id FROM task WHERE state!='completed' OR state IS NULL GROUP BY app_id)"
    op.execute(query)
    # Update to not completed those that do not have any task
    query = "UPDATE app SET completed=false WHERE id NOT IN (SELECT app_id FROM task group by app_id)"
    op.execute(query)
项目:cyborg    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'accelerators',
        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('description', sa.Text(), nullable=True),
        sa.Column('project_id', sa.String(length=36), nullable=True),
        sa.Column('user_id', sa.String(length=36), nullable=True),
        sa.Column('device_type', sa.Text(), nullable=False),
        sa.Column('acc_type', sa.Text(), nullable=False),
        sa.Column('acc_capability', sa.Text(), nullable=False),
        sa.Column('vendor_id', sa.Text(), nullable=False),
        sa.Column('product_id', sa.Text(), nullable=False),
        sa.Column('remotable', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_ENGINE='InnoDB',
        mysql_DEFAULT_CHARSET='UTF8'
    )
项目:trio2o    作者:openstack    | 项目源码 | 文件源码
def _get_field_value(column):
    """Get field value for resource creating

    returning None indicates that not setting this field in resource dict
    """
    if column.nullable:
        # just skip nullable column
        return None
    if isinstance(column.type, sql.Text):
        return 'fake_text'
    elif isinstance(column.type, sql.Enum):
        return column.type.enums[0]
    elif isinstance(column.type, sql.String):
        return 'fake_str'
    elif isinstance(column.type, sql.Integer):
        return 1
    elif isinstance(column.type, sql.Float):
        return 1.0
    elif isinstance(column.type, sql.Boolean):
        return True
    elif isinstance(column.type, sql.DateTime):
        return datetime.datetime.utcnow()
    else:
        return None
项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('episode',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('link', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('published', sa.DateTime(), nullable=True),
    sa.Column('enclosure', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('link'),
    sa.UniqueConstraint('title')
    )
    op.create_index(op.f('ix_podcast_feed'), 'podcast', ['feed'], unique=True)
    op.create_index(op.f('ix_podcast_name'), 'podcast', ['name'], unique=True)
    ### end Alembic commands ###
项目:1ibrary-gzhu    作者:1ibrary    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('hot_books',
    sa.Column('book_id', sa.Integer(), nullable=False),
    sa.Column('book_author', sa.Text(), nullable=True),
    sa.Column('book_cover', sa.Text(), nullable=True),
    sa.Column('book_rate', sa.Integer(), nullable=True),
    sa.Column('book_content', sa.Text(), nullable=True),
    sa.Column('book_publish', sa.Text(), nullable=True),
    sa.Column('book_last_number', sa.Integer(), nullable=True),
    sa.Column('book_key', sa.String(length=13), nullable=True),
    sa.Column('book_db_id', sa.Integer(), nullable=True),
    sa.Column('book_title', sa.Text(), nullable=True),
    sa.Column('book_place', sa.Text(), nullable=True),
    sa.Column('detail_data', sa.Text(), nullable=True),
    sa.Column('hot_id', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('book_id'),
    sa.UniqueConstraint('book_db_id')
    )
    op.create_index(op.f('ix_hot_books_book_key'), 'hot_books', ['book_key'], unique=False)
    # ### end Alembic commands ###
项目:zun    作者:openstack    | 项目源码 | 文件源码
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')
    )
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
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 ###
项目:dati-ckan-docker    作者:italia    | 项目源码 | 文件源码
def setup_db(pycsw_config):
    """Setup database tables and indexes"""

    from sqlalchemy import Column, Text

    database = pycsw_config.get('repository', 'database')
    table_name = pycsw_config.get('repository', 'table', 'records')

    ckan_columns = [
        Column('ckan_id', Text, index=True),
        Column('ckan_modified', Text),
    ]

    pycsw.admin.setup_db(database,
        table_name, '',
        create_plpythonu_functions=False,
        extra_columns=ckan_columns)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
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(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ###
项目:aiorchestra-persistence    作者:aiorchestra    | 项目源码 | 文件源码
def upgrade():

    op.create_table(
        'context',
        sa.Column('name', sa.String(), nullable=False, unique=True, primary_key=True),
        sa.Column('status', sa.String(), nullable=False),
        sa.Column('template_path', sa.String(), nullable=False),
        sa.Column('inputs', sa.Text(), nullable=False),
    )
    op.create_table(
        'node',
        sa.Column('context', sa.String(), sa.ForeignKey('context.name'), ),
        sa.Column('name', sa.String(), nullable=False, unique=True),
        sa.Column('is_provisioned', sa.Boolean(), nullable=False),
        sa.Column('properties', sa.Text(), nullable=True),
        sa.Column('attributes', sa.Text(), nullable=True),
        sa.Column('runtime_properties', sa.Text(), nullable=True),
    )
项目:Adventure-Insecure    作者:colinnewell    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('order_header',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.Column('title', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('order_line',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.Column('request', sa.Text(), nullable=False),
    sa.Column('order_id', sa.Integer(), nullable=True),
    sa.Column('order_for', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['order_for'], ['users.id'], ),
    sa.ForeignKeyConstraint(['order_id'], ['order_header.id'], name='order_id_fkey'),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
项目:GenomicsSampleAPIs    作者:Intel-HLS    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'reference',
        sa.Column('id', sa.BigInteger, primary_key=True),
        sa.Column('guid', sa.String(36), nullable=False, unique=True),
        sa.Column('length', sa.BigInteger),
        sa.Column('reference_set_id', sa.BigInteger,
                  sa.ForeignKey('reference_set.id'), nullable=False),
        sa.Column('md5_checksum', sa.String(32)),
        sa.Column('name', sa.Text),
        sa.Column('source_uri', sa.Text),
        sa.Column('is_derived', sa.Boolean),
        sa.Column('source_divergence', sa.Float),
        sa.Column('ncbi_taxon_id', sa.Integer),
        sa.Column('offset', sa.BigInteger)
    )
项目:cookiecutter-graphene-flask    作者:karec    | 项目源码 | 文件源码
def upgrade():
    """Insert fixtures for models, tests purpose only"""
    users = [generate_users(i) for i in range(1, 52)]
    articles = [generate_articles(i, 50) for i in range(1, 200)]

    article = table(
        'article',
        sa.Column('id', sa.Integer(), nullable=False, primary_key=True, autoincrement=True),
        sa.Column('title', sa.String(length=100), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
    )

    user = table(
        'user',
        sa.Column('id', sa.Integer(), nullable=False, primary_key=True, autoincrement=True),
        sa.Column('username', sa.String(length=80), nullable=False),
        sa.Column('email', sa.String(length=120), nullable=False),
    )

    op.bulk_insert(user, users)
    op.bulk_insert(article, articles)
项目:aiohttp_admin    作者:aio-libs    | 项目源码 | 文件源码
def sa_table():
    choices = ['a', 'b', 'c']
    meta = sa.MetaData()
    post = sa.Table(
        'test_post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('category', sa.String(200), nullable=True),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        # sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.DateTime, nullable=False),
        # sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='{}'),
        sa.Column('status',
                  sa.Enum(*choices, name="enum_name", native_enum=False),
                  server_default="a", nullable=False),
        sa.Column('visible', sa.Boolean, nullable=False),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post
项目:aiohttp_admin    作者:aio-libs    | 项目源码 | 文件源码
def table():

    meta = sa.MetaData()
    post = sa.Table(
        'post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.Date, nullable=False),
        sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='[]'),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post
项目:zual    作者:ninadmhatre    | 项目源码 | 文件源码
def _create_post_table(self):
        """
        Creates the table to store the blog posts.
        :return:
        """
        with self._engine.begin() as conn:
            post_table_name = self._table_name("post")
            if not conn.dialect.has_table(conn, post_table_name):
                self._post_table = sqla.Table(
                    post_table_name, self._metadata,
                    sqla.Column("id", sqla.Integer, primary_key=True),
                    sqla.Column("title", sqla.String(256)),
                    sqla.Column("text", sqla.Text),
                    sqla.Column("post_date", sqla.DateTime),
                    sqla.Column("last_modified_date", sqla.DateTime),
                    # if 1 then make it a draft
                    sqla.Column("draft", sqla.SmallInteger, default=0)

                )
                self._logger.debug("Created table with table name %s" %
                                   post_table_name)
            else:
                self._post_table = self._metadata.tables[post_table_name]
                self._logger.debug("Reflecting to table with table name %s" %
                                   post_table_name)
项目:zual    作者:ninadmhatre    | 项目源码 | 文件源码
def _create_post_table(self):
        """
        Creates the table to store the blog posts.
        :return:
        """
        with self._engine.begin() as conn:
            post_table_name = self._table_name("post")
            if not conn.dialect.has_table(conn, post_table_name):
                self._post_table = sqla.Table(
                    post_table_name, self._metadata,
                    sqla.Column("id", sqla.Integer, primary_key=True),
                    sqla.Column("title", sqla.String(256)),
                    sqla.Column("text", sqla.Text),
                    sqla.Column("post_date", sqla.DateTime),
                    sqla.Column("last_modified_date", sqla.DateTime),
                    # if 1 then make it a draft
                    sqla.Column("draft", sqla.SmallInteger, default=0)

                )
                self._logger.debug("Created table with table name %s" %
                                   post_table_name)
            else:
                self._post_table = self._metadata.tables[post_table_name]
                self._logger.debug("Reflecting to table with table name %s" %
                                   post_table_name)
项目:zual    作者:ninadmhatre    | 项目源码 | 文件源码
def _create_post_table(self):
        """
        Creates the table to store the blog posts.
        :return:
        """
        with self._engine.begin() as conn:
            post_table_name = self._table_name("post")
            if not conn.dialect.has_table(conn, post_table_name):
                self._post_table = sqla.Table(
                    post_table_name, self._metadata,
                    sqla.Column("id", sqla.Integer, primary_key=True),
                    sqla.Column("title", sqla.String(256)),
                    sqla.Column("text", sqla.Text),
                    sqla.Column("post_date", sqla.DateTime),
                    sqla.Column("last_modified_date", sqla.DateTime),
                    # if 1 then make it a draft
                    sqla.Column("draft", sqla.SmallInteger, default=0)

                )
                self._logger.debug("Created table with table name %s" %
                                   post_table_name)
            else:
                self._post_table = self._metadata.tables[post_table_name]
                self._logger.debug("Reflecting to table with table name %s" %
                                   post_table_name)
项目:fabric8-analytics-server    作者:fabric8-analytics    | 项目源码 | 文件源码
def upgrade():
    """Upgrade the database to a newer revision."""
    # commands auto generated by Alembic - please adjust! ###
    op.create_table('batch',
                    sa.Column('token', sa.Integer(), nullable=False),
                    sa.Column('started_at', sa.DateTime(), nullable=True),
                    sa.Column('epvs', postgresql.JSONB(), nullable=True),
                    sa.PrimaryKeyConstraint('token'))
    op.create_table('review',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('approved', sa.Boolean(), nullable=True),
                    sa.Column('user', sa.Integer(), nullable=True),
                    sa.Column('timestamp', sa.DateTime(), nullable=True),
                    sa.Column('comment', sa.Text(), nullable=True),
                    sa.Column('epv', sa.String(length=255), nullable=True),
                    sa.ForeignKeyConstraint(['user'], ['user.id'], ),
                    sa.PrimaryKeyConstraint('id'))
    # end Alembic commands ###
项目:centr    作者:ibiBgOR    | 项目源码 | 文件源码
def upgrade():
    op.create_table("db_log_item",
        sa.Column("id", sa.Integer, primary_key = True),
        sa.Column("message", sa.Text),
        sa.Column("time", sa.DateTime),
        sa.Column("level", sa.String(5)),
        sa.Column("trace", sa.Text),
    )
    op.create_table("db_feed_item",
        sa.Column("id", sa.Integer, primary_key = True),
        sa.Column("content", sa.Text),
        sa.Column("type", sa.String(20)),
        sa.Column("source", sa.String(125)),
        sa.Column("time", sa.DateTime),
        sa.UniqueConstraint('content', 'source', name = 'uk_content_source'),
    )
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('publication',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pubmed_uid', sa.String(length=30), nullable=True),
    sa.Column('pubmed_link', sa.Text(), nullable=True),
    sa.Column('pub_publication_date', sa.DateTime(), nullable=True),
    sa.Column('pub_authors', sa.Text(), nullable=True),
    sa.Column('pub_title', sa.Text(), nullable=True),
    sa.Column('pub_volume', sa.String(length=20), nullable=True),
    sa.Column('pub_issue', sa.String(length=20), nullable=True),
    sa.Column('pub_pages', sa.String(length=30), nullable=True),
    sa.Column('pub_journal', sa.Text(), nullable=True),
    sa.Column('pub_doi', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('dataset_to_publication',
    sa.Column('dataset_id', sa.Integer(), nullable=True),
    sa.Column('publication_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['dataset_id'], ['dataset.id'], ),
    sa.ForeignKeyConstraint(['publication_id'], ['publication.id'], )
    )
    # ### end Alembic commands ###
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('run',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('run_id', sa.String(length=30), nullable=True),
    sa.Column('library_reads_sequenced', sa.BIGINT(), nullable=True),
    sa.Column('total_num_bases', sa.BIGINT(), nullable=True),
    sa.Column('download_size', sa.BIGINT(), nullable=True),
    sa.Column('avg_read_length', sa.Float(), nullable=True),
    sa.Column('baseA_count', sa.BIGINT(), nullable=True),
    sa.Column('baseC_count', sa.BIGINT(), nullable=True),
    sa.Column('baseG_count', sa.BIGINT(), nullable=True),
    sa.Column('baseT_count', sa.BIGINT(), nullable=True),
    sa.Column('baseN_count', sa.BIGINT(), nullable=True),
    sa.Column('gc_percent', sa.Float(), nullable=True),
    sa.Column('run_quality_counts', sa.Text(), nullable=True),
    sa.Column('dataset_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['dataset_id'], ['dataset.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_unique_constraint(None, 'dataset', ['db_source_uid'])
    # ### end Alembic commands ###
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('dataset', 'collection_date',
               existing_type=mysql.DATETIME(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('user', 'admin',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'admin',
               existing_type=sa.Boolean(),
               type_=mysql.TINYINT(display_width=1),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'collection_date',
               existing_type=sa.Text(),
               type_=mysql.DATETIME(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
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(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ###
项目:contactista    作者:singingwolfboy    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tag',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.Column('color', ColorType(length=20), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'name')
    )
    op.create_table('contact_tag',
    sa.Column('contact_id', sa.Integer(), nullable=False),
    sa.Column('tag_id', sa.Integer(), nullable=False),
    sa.Column('position', sa.Integer(), nullable=False),
    sa.Column('note', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['contact_id'], ['contact.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
    sa.PrimaryKeyConstraint('contact_id', 'tag_id')
    )
    # ### end Alembic commands ###
    op.execute(CreateSequence(Sequence('contact_tag_position')))
项目:fabric8-analytics-worker    作者:fabric8-analytics    | 项目源码 | 文件源码
def upgrade():
    """Upgrade the database to a newer revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('api_requests',
                    sa.Column('id', sa.String(length=64), nullable=False),
                    sa.Column('api_name', sa.String(length=256), nullable=True),
                    sa.Column('submit_time', sa.DateTime(), nullable=False),
                    sa.Column('user_email', sa.String(length=256), nullable=True),
                    sa.Column('user_profile_digest', sa.String(length=128), nullable=True),
                    sa.Column('origin', sa.String(length=64), nullable=True),
                    sa.Column('team', sa.String(length=64), nullable=True),
                    sa.Column('recommendation', postgresql.JSON(astext_type=sa.Text()),
                              nullable=True),
                    sa.Column('request_digest', sa.String(length=128), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    # ### end Alembic commands ###
项目:fabric8-analytics-worker    作者:fabric8-analytics    | 项目源码 | 文件源码
def upgrade():
    """Upgrade the database to a newer revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('batch',
                    sa.Column('token', sa.Integer(), nullable=False),
                    sa.Column('started_at', sa.DateTime(), nullable=True),
                    sa.Column('epvs', postgresql.JSONB(), nullable=True),
                    sa.PrimaryKeyConstraint('token'))
    op.create_table('review',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('approved', sa.Boolean(), nullable=True),
                    sa.Column('user', sa.Integer(), nullable=True),
                    sa.Column('timestamp', sa.DateTime(), nullable=True),
                    sa.Column('comment', sa.Text(), nullable=True),
                    sa.Column('epv', sa.String(length=255), nullable=True),
                    sa.ForeignKeyConstraint(['user'], ['user.id'], ),
                    sa.PrimaryKeyConstraint('id'))
    # ### end Alembic commands ###
项目:cs373-idb    作者:cedricgc    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'pokemon',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.Text, unique=True, nullable=False),
        sa.Column('flavor_text', sa.Text, nullable=False),
        sa.Column('habitat', sa.Text, nullable=True, default=None),
        sa.Column('color', sa.Text, nullable=False),
        sa.Column('shape', sa.Text, nullable=False),

        sa.Column('search_vector', TSVectorType(searchable)),

        sa.Column('inserted_at', sa.DateTime,
                  default=sa.func.current_timestamp(), nullable=False),
        sa.Column('updated_at', sa.DateTime,
                  default=sa.func.current_timestamp(),
                  onupdate=sa.func.current_timestamp(), nullable=False)
    )

    conn = op.get_bind()
    sync_trigger(conn, 'pokemon', 'search_vector', searchable)
项目:cs373-idb    作者:cedricgc    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'pokedexes',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.Text, unique=True, nullable=False),
        sa.Column('official_name', sa.Text, unique=True, nullable=False),
        sa.Column('region', sa.Text, nullable=True, default=None),
        sa.Column('description', sa.Text, nullable=True, default=None),

        sa.Column('search_vector', TSVectorType(searchable)),

        sa.Column('inserted_at', sa.DateTime,
                  default=sa.func.current_timestamp(), nullable=False),
        sa.Column('updated_at', sa.DateTime,
                  default=sa.func.current_timestamp(),
                  onupdate=sa.func.current_timestamp(), nullable=False)
    )

    conn = op.get_bind()
    sync_trigger(conn, 'pokedexes', 'search_vector', searchable)
项目:cs373-idb    作者:cedricgc    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'moves',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.Text, unique=True, nullable=False),
        sa.Column('flavor_text', sa.Text, nullable=True, default=None),
        sa.Column('short_effect', sa.Text, nullable=False),
        sa.Column('effect', sa.Text, nullable=False),
        sa.Column('damage_class', sa.Text, nullable=True, default=None),
        sa.Column('power_points', sa.Integer, nullable=True, default=None),
        sa.Column('power', sa.Integer, nullable=True, default=None),
        sa.Column('accuracy', sa.Integer, nullable=True, default=None),

        sa.Column('search_vector', TSVectorType(searchable)),

        sa.Column('inserted_at', sa.DateTime,
                  default=sa.func.current_timestamp(), nullable=False),
        sa.Column('updated_at', sa.DateTime,
                  default=sa.func.current_timestamp(),
                  onupdate=sa.func.current_timestamp(), nullable=False)
    )

    conn = op.get_bind()
    sync_trigger(conn, 'moves', 'search_vector', searchable)
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
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(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ###
项目:zipline-chinese    作者:zhanghan1990    | 项目源码 | 文件源码
def _futures_exchanges_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'futures_exchanges',
        metadata,
        sa.Column(
            'exchange',
            sa.Text,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('timezone', sa.Text),
    )
项目:zipline-chinese    作者:zhanghan1990    | 项目源码 | 文件源码
def _futures_contracts_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'futures_contracts',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('symbol', sa.Text, unique=True, index=True),
        sa.Column(
            'root_symbol',
            sa.Text,
            sa.ForeignKey('futures_root_symbols.root_symbol'),
            index=True
        ),
        sa.Column('asset_name', sa.Text),
        sa.Column('start_date', sa.Integer, default=0, nullable=False),
        sa.Column('end_date', sa.Integer, nullable=False),
        sa.Column('first_traded', sa.Integer, nullable=False),
        sa.Column(
            'exchange',
            sa.Text,
            sa.ForeignKey('futures_exchanges.exchange'),
        ),
        sa.Column('notice_date', sa.Integer, nullable=False),
        sa.Column('expiration_date', sa.Integer, nullable=False),
        sa.Column('auto_close_date', sa.Integer, nullable=False),
        sa.Column('multiplier', sa.Float),
        sa.Column('tick_size', sa.Float),
    )
项目:zipline-chinese    作者:zhanghan1990    | 项目源码 | 文件源码
def _asset_router_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'asset_router',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True),
        sa.Column('asset_type', sa.Text),
    )
项目:zlktqa    作者:NunchakusHuang    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.String(length=100), nullable=False),
    sa.Column('username', sa.String(length=100), nullable=False),
    sa.Column('telephone', sa.String(length=11), nullable=False),
    sa.Column('_password', sa.String(length=100), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('questions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=100), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('author_id', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('answers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('question_id', sa.Integer(), nullable=True),
    sa.Column('author_id', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('blogpost', sa.Column('published', sa.Boolean, default=False))
    op.add_column('blogpost', sa.Column('updated', sa.Text,
                                       default=make_timestamp))
    sql = 'update blogpost set published=true'
    op.execute(sql)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'announcement',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('title', sa.Unicode(length=255), nullable=False),
        sa.Column('body', sa.UnicodeText, nullable=False),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('user.id')),
        sa.Column('created', sa.Text, default=make_timestamp),
    )
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def downgrade():
    op.create_table(
        'featured',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('created', sa.Text, default=make_timestamp),
        sa.Column('app_id', sa.Integer, sa.ForeignKey('app.id'), unique=True)
    )
    query = 'INSERT INTO "featured" (app_id) SELECT id FROM "app" WHERE featured=true;'
    op.execute(query)
    op.drop_column('app', 'featured')
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'featured',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('created', sa.Text, default=make_timestamp),
        sa.Column('app_id', sa.Integer, ForeignKey('app.id'), unique=True)
    )
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('app', sa.Column('webhook', sa.Text))
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'result',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('created', sa.Text, default=make_timestamp),
        sa.Column('project_id', sa.Integer, sa.ForeignKey('project.id'), nullable=False),
        sa.Column('task_id', sa.Integer, sa.ForeignKey('task.id'), nullable=False),
        sa.Column('task_run_ids', ARRAY(sa.Integer), nullable=False),
        sa.Column('last_version', sa.Boolean, default=True),
        sa.Column('info', JSON)
    )
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
        'category',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.Text, nullable=False, unique=True),
        sa.Column('short_name', sa.Text, nullable=False, unique=True),
        sa.Column('description', sa.Text, nullable=False),
        sa.Column('created', sa.Text, default=make_timestamp),
    )

    # Add two categories
    query = 'INSERT INTO category (name, short_name, description) VALUES (\'Thinking\', \'thinking\', \'Applications where you can help using your skills\')'
    op.execute(query)
    query = 'INSERT INTO category  (name, short_name, description) VALUES (\'Sensing\', \'sensing\', \'Applications where you can help gathering data\')'
    op.execute(query)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.create_table(
    'blogpost',
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('title', sa.Unicode(length=255), nullable=False),
    sa.Column('body', sa.UnicodeText, nullable=False),
    sa.Column('app_id', sa.Integer, sa.ForeignKey('app.id', ondelete='CASCADE'), nullable=False),
    sa.Column('user_id', sa.Integer, sa.ForeignKey('user.id')),
    sa.Column('created', sa.Text, default=make_timestamp),
    )