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 ###
python类VARCHAR的实例源码
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('machine_statistic',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('type', sa.String(length=64), nullable=True),
sa.Column('timestamp', sa.String(length=64), nullable=True),
sa.Column('userid', sa.String(length=64), nullable=True),
sa.Column('netcode', sa.String(length=64), nullable=True),
sa.Column('login_time', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
op.create_index(op.f('ix_machine_statistic_login_time'), 'machine_statistic', ['login_time'], 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 ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('nuccore',
sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column('nuccore_uid', mysql.VARCHAR(length=50), nullable=True),
sa.Column('nuccore_link', mysql.TEXT(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_default_charset=u'utf8',
mysql_engine=u'InnoDB'
)
op.create_table('dataset_to_nuccore',
sa.Column('dataset_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.Column('nuccore_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['dataset_id'], [u'dataset.id'], name=u'dataset_to_nuccore_ibfk_1'),
sa.ForeignKeyConstraint(['nuccore_id'], [u'nuccore.id'], name=u'dataset_to_nuccore_ibfk_2'),
mysql_default_charset=u'utf8',
mysql_engine=u'InnoDB'
)
# ### end Alembic commands ###
c9b74509755e_add_created_and_modified_fields_to_.py 文件源码
项目:quilt
作者: quiltdata
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def upgrade():
op.add_column('instance', sa.Column('created_by', mysql.VARCHAR(collation='utf8_bin', length=64), nullable=False))
op.add_column('instance', sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('instance', sa.Column('updated_by', mysql.VARCHAR(collation='utf8_bin', length=64), nullable=False))
op.add_column('instance', sa.Column('updated_at', sa.DateTime(), nullable=False))
op.execute("""
UPDATE instance JOIN (
SELECT instance_id, min(created) min_created, max(created) max_created, author
FROM log
GROUP BY instance_id, author
) log
ON id = instance_id
SET created_at = min_created, created_by = author,
updated_at = max_created, updated_by = author
""")
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('roles',
sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column('name', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate=u'utf8_unicode_ci',
mysql_default_charset=u'utf8',
mysql_engine=u'InnoDB'
)
op.create_table('users',
sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column('username', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True),
sa.Column('role_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.Column('email', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True),
sa.Column('password_hash', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128), nullable=True),
sa.Column('confirmed', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['role_id'], [u'roles.id'], name=u'users_ibfk_1'),
sa.PrimaryKeyConstraint('id'),
mysql_collate=u'utf8_unicode_ci',
mysql_default_charset=u'utf8',
mysql_engine=u'InnoDB'
)
op.drop_table('context_show')
### end Alembic commands ###
51415576d3e9_org_metadata.py 文件源码
项目:raw-data-repository
作者: all-of-us
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
def downgrade_rdr():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(u'site', sa.Column('consortium_name', mysql.VARCHAR(length=255), nullable=False))
op.drop_constraint(None, 'site', type_='foreignkey')
op.alter_column(u'site', 'hpo_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=False)
op.drop_column(u'site', 'zip_code')
op.drop_column(u'site', 'state')
op.drop_column(u'site', 'site_status')
op.drop_column(u'site', 'physical_location_name')
op.drop_column(u'site', 'phone_number')
op.drop_column(u'site', 'organization_id')
op.drop_column(u'site', 'notes')
op.drop_column(u'site', 'longitude')
op.drop_column(u'site', 'link')
op.drop_column(u'site', 'launch_date')
op.drop_column(u'site', 'latitude')
op.drop_column(u'site', 'directions')
op.drop_column(u'site', 'city')
op.drop_column(u'site', 'admin_emails')
op.drop_column(u'site', 'address_2')
op.drop_column(u'site', 'address_1')
op.drop_table('organization')
# ### end Alembic commands ###
8d12872e0b77_add_short_value.py 文件源码
项目:raw-data-repository
作者: all-of-us
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def upgrade_rdr():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('code', sa.Column('short_value', sa.String(length=50), nullable=True))
op.add_column('code_history', sa.Column('short_value', sa.String(length=50), nullable=True))
op.alter_column('participant_summary', 'city',
existing_type=mysql.VARCHAR(length=80),
type_=sa.String(length=255),
existing_nullable=True)
op.alter_column('participant_summary', 'first_name',
existing_type=mysql.VARCHAR(length=80),
type_=sa.String(length=255),
existing_nullable=False)
op.alter_column('participant_summary', 'last_name',
existing_type=mysql.VARCHAR(length=80),
type_=sa.String(length=255),
existing_nullable=False)
op.alter_column('participant_summary', 'middle_name',
existing_type=mysql.VARCHAR(length=80),
type_=sa.String(length=255),
existing_nullable=True)
# ### end Alembic commands ###
8d12872e0b77_add_short_value.py 文件源码
项目:raw-data-repository
作者: all-of-us
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def downgrade_rdr():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('participant_summary', 'middle_name',
existing_type=sa.String(length=255),
type_=mysql.VARCHAR(length=80),
existing_nullable=True)
op.alter_column('participant_summary', 'last_name',
existing_type=sa.String(length=255),
type_=mysql.VARCHAR(length=80),
existing_nullable=False)
op.alter_column('participant_summary', 'first_name',
existing_type=sa.String(length=255),
type_=mysql.VARCHAR(length=80),
existing_nullable=False)
op.alter_column('participant_summary', 'city',
existing_type=sa.String(length=255),
type_=mysql.VARCHAR(length=80),
existing_nullable=True)
op.drop_column('code_history', 'short_value')
op.drop_column('code', 'short_value')
# ### end Alembic commands ###
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})
f4a5152337aa_reduce_size_of_email.py 文件源码
项目:BookCloud
作者: livro-aberto
项目源码
文件源码
阅读 31
收藏 0
点赞 0
评论 0
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('user', 'email',
existing_type=mysql.VARCHAR(length=255),
type_=sa.String(length=75),
existing_nullable=False)
# ### end Alembic commands ###
f4a5152337aa_reduce_size_of_email.py 文件源码
项目:BookCloud
作者: livro-aberto
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('user', 'email',
existing_type=sa.String(length=75),
type_=mysql.VARCHAR(length=255),
existing_nullable=False)
# ### end Alembic commands ###
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('Products',
sa.Column('maker', mysql.CHAR(collation=u'utf8_unicode_ci', length=2), nullable=True),
sa.Column('model', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
sa.Column('tyle', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=10), nullable=True),
mysql_collate=u'utf8_unicode_ci',
mysql_default_charset=u'utf8',
mysql_engine=u'InnoDB'
)
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.drop_table('users')
op.drop_table('roles')
### end Alembic commands ###
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`~sqlalchemy.types.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('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 ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False,
existing_server_default=sa.text(u"''"))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column(u'statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False,
existing_server_default=sa.text(u"''"))
op.drop_index(op.f('ix_comments_timestamp'), table_name='comments')
op.drop_table('comments')
### end Alembic commands ###
359a34011f5e_add_default_value_in_referred_row_in_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('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 ###
b2286df65ce6_change_referred_row_from_string_to_text_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=True)
### end Alembic commands ###
b2286df65ce6_change_referred_row_from_string_to_text_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False)
### end Alembic commands ###
e8b3861bce6b_add_some_columns_in_machine_statistic_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('machine_statistic', sa.Column('gateway', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('ip', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('localip', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('wlanmac', sa.String(length=64), nullable=True))
op.alter_column('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 ###
e8b3861bce6b_add_some_columns_in_machine_statistic_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False,
existing_server_default=sa.text(u"''"))
op.drop_column('machine_statistic', 'wlanmac')
op.drop_column('machine_statistic', 'localip')
op.drop_column('machine_statistic', 'ip')
op.drop_column('machine_statistic', 'gateway')
### end Alembic commands ###
1b8e4f2cb14e_add_post_body_abstract_row.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('posts', sa.Column('body_abtract', sa.Text(), nullable=True))
op.alter_column('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 ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column(u'statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False,
existing_server_default=sa.text(u"''"))
op.drop_index(op.f('ix_machine_statistic_login_time'), table_name='machine_statistic')
op.drop_table('machine_statistic')
### end Alembic commands ###
55c24cfaf201_add_table_machine_statistic.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('machine_statistic', sa.Column('version', sa.String(length=64), nullable=True))
op.alter_column('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 ###
55c24cfaf201_add_table_machine_statistic.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('statistic_visitor', 'referred',
existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
nullable=False,
existing_server_default=sa.text(u"''"))
op.drop_column('machine_statistic', 'version')
### end Alembic commands ###
b055a698c928_add_some_columns_in_machine_statistic_.py 文件源码
项目:chihu
作者: yelongyu
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('machine_statistic', sa.Column('company', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('openid', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('userpasswd', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('webkey', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('wlanpasswd', sa.String(length=64), nullable=True))
op.add_column('machine_statistic', sa.Column('wlanssid', sa.String(length=64), nullable=True))
op.alter_column('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 ###
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})
def with_variant(self, type_, dialect_name):
"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
from sqlalchemy.types import String
from sqlalchemy.dialects import mysql
s = String()
s = s.with_variant(mysql.VARCHAR(collation='foo'), 'mysql')
The construction of :meth:`.TypeEngine.with_variant` is always
from the "fallback" type to that which is dialect specific.
The returned type is an instance of :class:`.Variant`, which
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
:param type_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
this type. (i.e. ``'postgresql'``, ``'mysql'``, etc.)
.. versionadded:: 0.7.2
"""
return Variant(self, {dialect_name: to_instance(type_)})