コード例 #1
0
class ChildModel(Base):
    __tablename__ = 'child'
    id = Column('id', INTEGER(display_width=11), primary_key=True, nullable=False)
    id_card_no = Column('id_card_no', VARCHAR(length=18))
    realname = Column('realname', VARCHAR(length=16))
    nickname = Column('nickname', VARCHAR(length=16))
    birth_ts = Column('birth_ts', INTEGER(display_width=10))
    gender = Column('gender', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    status = Column('status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    create_ts = Column('create_ts', INTEGER(display_width=10))
    update_ts = Column('update_ts', INTEGER(display_width=10))
コード例 #2
0
class UserInfoModel(Base):
    __tablename__ = 'user_info'
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False, autoincrement=False)
    id_card_no = Column('id_card_no', VARCHAR(length=18))
    realname = Column('realname', VARCHAR(length=16))
    mobile = Column('mobile', VARCHAR(length=11))
    child_relation = Column('child_relation', TINYINT(display_width=4))
    degree = Column('degree', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    nickname = Column('nickname', VARCHAR(length=32))
    country = Column('country', SMALLINT(display_width=6), server_default=DefaultClause(TextClause('1')))
    status = Column('status', TINYINT(display_width=4), server_default=DefaultClause(TextClause('0')))
    update_ts = Column('update_ts', INTEGER(display_width=10))
    avatar_oss = Column('avatar_oss', VARCHAR(length=255))
    born = Column('born', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
コード例 #3
0
ファイル: migrator.py プロジェクト: stjordanis/cbl_migrator
    def __copy_schema(self):
        """        
        Copies the schema to dest db.
        Copies all constraints in sqlite, only pk in mysql and postgres.
        """
        o_engine = create_engine(self.o_engine_conn)
        d_engine = create_engine(self.d_engine_conn)
        metadata = MetaData()
        metadata.reflect(o_engine)
        insp = inspect(o_engine)

        new_metadata_tables = {}
        tables = filter(
            lambda x: x[0] not in self.exclude, metadata.tables.items())
        for table_name, table in tables:
            # Keep everything for sqlite. SQLite cant alter table ADD CONSTRAINT.
            # Only 1 simultaneous process can write to it.
            # Keep only PKs for PostreSQL and MySQL.
            # Restoring them after all data is copied.
            keep_constraints = list(
                filter(
                    lambda cons: isinstance(cons, PrimaryKeyConstraint),
                    table.constraints,
                )
            )
            if d_engine.name == "sqlite":
                uks = insp.get_unique_constraints(table_name)
                for uk in uks:
                    uk_cols = filter(
                        lambda c: c.name in uk["column_names"], table._columns
                    )
                    keep_constraints.append(
                        UniqueConstraint(*uk_cols, name=uk["name"]))
                for fk in filter(
                    lambda cons: isinstance(cons, ForeignKeyConstraint),
                    table.constraints,
                ):
                    keep_constraints.append(fk)
                for cc in filter(
                    lambda cons: isinstance(
                        cons, CheckConstraint), table.constraints
                ):
                    cc.sqltext = TextClause(str(cc.sqltext).replace('"', ""))
                    keep_constraints.append(cc)
                table.constraints = set(keep_constraints)
            else:
                table.constraints = set(keep_constraints)

            table.indexes = set()

            new_metadata_cols = ColumnCollection()
            for col in table._columns:
                col = self.__fix_column_type(col, d_engine.name)
                col.autoincrement = False
                new_metadata_cols.add(col)
            table.columns = new_metadata_cols.as_immutable()
            new_metadata_tables[table_name] = table
        metadata.tables = immutabledict(new_metadata_tables)
        metadata.create_all(d_engine)
コード例 #4
0
class UserLikeModel(Base):
    __tablename__ = 'user_like'
    id = Column('id', INTEGER(display_width=10, unsigned=True), primary_key=True, nullable=False)
    from_user_id = Column('from_user_id', INTEGER(display_width=11), nullable=False)
    to_user_id = Column('to_user_id', INTEGER(display_width=11), nullable=False)
    city_id = Column('city_id', INTEGER(display_width=11))
    status = Column('status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    update_ts = Column('update_ts', INTEGER(display_width=11), server_default=DefaultClause(TextClause('0')))
コード例 #5
0
    def count(self,**kwargs):

        db = dataset.connect(settings.db_url,engine_kwargs={'connect_args':{'check_same_thread':False}})
        if self.name in db.tables:
            table = db.get_table(self.name)
            result = table.count(TextClause(util.text_type(" AND ".join(["{}={}".format(i,kwargs[i]) if isinstance(kwargs[i],(int,float)) else '{}="{}"'.format(i,kwargs[i])  for i in kwargs ]))))
            return result
        else:
            return False
コード例 #6
0
class TimeSharingModel(Base):
    __tablename__ = 'time_sharing'
    id = Column('id', INTEGER(display_width=11), primary_key=True, nullable=False)
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), nullable=False)
    child_age_min = Column('child_age_min', INTEGER(display_width=11), nullable=False, comment='接待孩子最小年龄')
    child_age_max = Column('child_age_max', INTEGER(display_width=11), nullable=False, comment='接待孩子最大年龄')
    child_count_max = Column('child_count_max', INTEGER(display_width=11), nullable=False, comment='最多接待多少孩子')
    address_id = Column('address_id', INTEGER(display_width=11, unsigned=True), nullable=False, comment='活动地址 id')
    city_id = Column('city_id', INTEGER(display_width=11))
    start_ts = Column('start_ts', INTEGER(display_width=10), nullable=False)
    end_ts = Column('end_ts', INTEGER(display_width=10), nullable=False)
    price = Column('price', INTEGER(display_width=11), nullable=False)
    activity = Column('activity', VARCHAR(length=64), server_default=DefaultClause(TextClause("''")), comment='活动内容标签')
    description = Column('description', VARCHAR(length=128), server_default=DefaultClause(TextClause("''")), comment='详细描述')
    accompany_required = Column('accompany_required', TINYINT(display_width=4), nullable=False, server_default=DefaultClause(TextClause('1')), comment='是否必须家人陪同')
    child_count = Column('child_count', INTEGER(display_width=11), nullable=False, comment='已报名孩子数量')
    status = Column('status', TINYINT(display_width=4), server_default=DefaultClause(TextClause('0')), comment='0 正常 -1 删除')
    create_ts = Column('create_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
コード例 #7
0
class UserChildModel(Base):
    __tablename__ = 'user_child'
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), primary_key=True)
    child_id = Column('child_id', INTEGER(display_width=11, unsigned=True), primary_key=True)
    create_ts = Column('create_ts', INTEGER(display_width=10))
    status = Column('status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    __table_args__ = (
        Index('user_child_user_id_child_id_status_uindex', Column('user_id', INTEGER(display_width=11)), Column('child_id', INTEGER(display_width=11)), Column('status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0'))), unique=True),
    )
コード例 #8
0
    def test_reflect_subquery(self):
        table_node_sql = (
            '(select arrayJoin([1, 2]) as a, arrayJoin([3, 4]) as b)')
        table_node = TextClause(table_node_sql)

        metadata = self.metadata()
        # Cannot use `Table` as it only works with a simple string.
        columns = inspect(metadata.bind).get_columns(table_node)
        self.assertListEqual(sorted([col['name'] for col in columns]),
                             ['a', 'b'])
コード例 #9
0
class MidModel(Base):
    __tablename__ = 'mid'
    auto = Column('auto', INTEGER(display_width=11), autoincrement=True, primary_key=True, nullable=False)
    base = Column('base', INTEGER(display_width=11), primary_key=True)
    random = Column('random', INTEGER(display_width=11), primary_key=True)
    tag = Column('tag', VARCHAR(length=16))
    create_ts = Column('create_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    ts = Column('ts', TIMESTAMP(), server_default=DefaultClause(TextClause('CURRENT_TIMESTAMP')))
    __table_args__ = (
        Index('mid_auto_base_random', 'auto', 'base', 'random', unique=True),
    )
コード例 #10
0
ファイル: migrator.py プロジェクト: stjordanis/cbl_migrator
    def __copy_constraints(self):
        """
        Migrates constraints, UKs, CCs and FKs.
        """
        o_engine = create_engine(self.o_engine_conn)
        d_engine = create_engine(self.d_engine_conn)
        metadata = MetaData()
        metadata.reflect(o_engine)

        insp = inspect(o_engine)

        tables = filter(
            lambda x: x[0] not in self.exclude, metadata.tables.items())
        for table_name, table in tables:
            constraints_to_keep = []
            # keep unique constraints
            uks = insp.get_unique_constraints(table_name)
            for uk in uks:
                uk_cols = filter(
                    lambda c: c.name in uk["column_names"], table._columns)
                uuk = UniqueConstraint(*uk_cols, name=uk["name"])
                uuk._set_parent(table)
                constraints_to_keep.append(uuk)

            # keep check constraints
            ccs = filter(
                lambda cons: isinstance(
                    cons, CheckConstraint), table.constraints
            )
            for cc in ccs:
                cc.sqltext = TextClause(str(cc.sqltext).replace('"', ""))
                constraints_to_keep.append(cc)

            # keep fks
            for fk in filter(
                lambda cons: isinstance(
                    cons, ForeignKeyConstraint), table.constraints
            ):
                constraints_to_keep.append(fk)

            # create all constraints
            for cons in constraints_to_keep:
                try:
                    d_engine.execute(AddConstraint(cons))
                except Exception as e:
                    logger.warning(e)
コード例 #11
0
class CarerApplicationModel(Base):
    __tablename__ = 'carer_application'
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), primary_key=True, autoincrement=False)
    intro_video_id = Column('intro_video_id', INTEGER(display_width=11, unsigned=True), nullable=False, comment='个人视频 id')
    playground_video_id = Column('playground_video_id', INTEGER(display_width=11, unsigned=True), comment='场地视频 id')
    extra_video_ids = Column('extra_video_ids', VARCHAR(length=64), server_default=DefaultClause(TextClause("''")), comment='其他视频 id 逗号分割的字符列表 如 1,2,3')
    address_id = Column('address_id', INTEGER(display_width=11, unsigned=True), comment='地址 id')
    birth_certificate_oss = Column('birth_certificate_oss', VARCHAR(length=255), comment='出生证明文件 OSS 路径')
    care_exp = Column('care_exp', INTEGER(display_width=11), server_default=DefaultClause(TextClause('0')), comment='带娃经验(年)')
    degree = Column('degree', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='学历 0 无 1 专科 2 本科 3 硕士 4 博士')
    child_count_max = Column('child_count_max', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='最多接待多少孩子')
    child_age_min = Column('child_age_min', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='接待孩子最小年龄')
    child_age_max = Column('child_age_max', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='接待孩子最大年龄')
    result = Column('result', TINYINT(display_width=1), nullable=False, comment='不通过原因 | 0 审核通过 | 1 视频涉黄 | 2 视频涉政 | 3 视频涉暴恐 | 4 经验认证未通过 | 5 介绍视频没有看护人 | 6 介绍内容不符合要求 | 7 场地不符合要求')
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')), comment='-1 删除 0 审核中 1 通过 2 拒绝 3 失效')
    create_ts = Column('create_ts', INTEGER(display_width=10))
    update_ts = Column('update_ts', INTEGER(display_width=10))
コード例 #12
0
class UserCarerInfoModel(Base):
    __tablename__ = 'user_carer_info'
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False, autoincrement=False)
    intro_video_id = Column('intro_video_id', INTEGER(display_width=11, unsigned=True), nullable=False, comment='个人视频 id')
    playground_video_id = Column('playground_video_id', INTEGER(display_width=11, unsigned=True), nullable=False, comment='场地视频 id')
    extra_video_ids = Column('extra_video_ids', VARCHAR(length=64), server_default=DefaultClause(TextClause("''")), nullable=False, comment='其他视频 id 逗号分割的字符列表 如 1,2,3')
    address_id = Column('address_id', INTEGER(display_width=11, unsigned=True), comment='地址 id')
    city_id = Column('city_id', INTEGER(display_width=11))
    lat = Column('lat', DECIMAL(precision=10, scale=6), comment='纬度')
    lng = Column('lng', DECIMAL(precision=10, scale=6), comment='经度')
    birth_certificate_oss = Column('birth_certificate_oss', VARCHAR(length=255), comment='出生证明文件 OSS 路径')
    degree = Column('degree', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='学历 0 无 1 专科 2 本科 3 硕士 4 博士')
    care_exp = Column('care_exp', INTEGER(display_width=11), server_default=DefaultClause(TextClause('0')), comment='带娃经验(年)')
    child_count_max = Column('child_count_max', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='最多接待多少孩子')
    child_age_min = Column('child_age_min', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='接待孩子最小年龄')
    child_age_max = Column('child_age_max', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='接待孩子最大年龄')
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')), comment='0 正常 -1 删除')
    update_ts = Column('update_ts', INTEGER(display_width=10))
コード例 #13
0
class UserAddressModel(Base):
    __tablename__ = 'user_address'
    id = Column('id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False)
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), comment='用户 id')
    lat = Column('lat', DECIMAL(precision=10, scale=6), comment='纬度')
    lng = Column('lng', DECIMAL(precision=10, scale=6), comment='经度')
    province = Column('province', VARCHAR(length=8), DefaultClause(TextClause("''")), comment='省/直辖市 如:北京市')
    city = Column('city', VARCHAR(length=12), DefaultClause(TextClause("''")), comment='城市 如:北京市')
    city_id = Column('city_id', INTEGER(display_width=11))
    district = Column('district', VARCHAR(length=8), DefaultClause(TextClause("''")), comment='区 如:海淀区')
    address = Column('address', VARCHAR(length=64), comment='街道地址 如:亮马桥路27号院1903号')
    name = Column('name', VARCHAR(length=32), DefaultClause(TextClause("''")), comment='住宅、建筑、公司等名称 如:大鱼公司')
    room = Column('room', VARCHAR(length=32), DefaultClause(TextClause("''")), comment='用户填写的房间号 如:2楼2018室')
    poi = Column('poi', VARCHAR(length=40), DefaultClause(TextClause("''")), comment='第三方 SDK 给的 Point of Interest')
    status = Column('status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')))
    create_ts = Column('create_ts', INTEGER(display_width=10))
    __table_args__ = (
        Index('user_address_user_id_city_district_address_name_room', 'user_id', 'city', 'district', 'address', 'name', 'room', unique=True),
    )
コード例 #14
0
class UserModel(Base):
    __tablename__ = 'user'
    id = Column('id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False)
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    code = Column('code', VARCHAR(length=8), nullable=False)
    mobile = Column('mobile', VARCHAR(length=11), nullable=False, server_default=DefaultClause(TextClause('0')))
    password = Column('password', VARCHAR(length=64), nullable=False, server_default=DefaultClause(TextClause('0')))
    create_ts = Column('create_ts', INTEGER(display_width=11, unsigned=True), nullable=False, server_default=DefaultClause(TextClause('0')))
    __table_args__ = (
        Index('create_ts_status', Column('create_ts', INTEGER(display_width=11, unsigned=True), nullable=False, server_default=DefaultClause(TextClause('0'))), Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))),
        Index('mobile_UNIQUE', Column('mobile', VARCHAR(length=11), nullable=False, server_default=DefaultClause(TextClause('0'))), Column('code', VARCHAR(length=8), nullable=False), unique=True),
    )
コード例 #15
0
class TimeSharingOrderModel(Base):
    __tablename__ = 'time_sharing_order'
    id = Column('id', INTEGER(display_width=10, unsigned=True), primary_key=True, nullable=False)
    order_no = Column('order_no', INTEGER(display_width=10), comment='订单号')
    buyer_id = Column('buyer_id', INTEGER(display_width=11), nullable=False, comment='下单user_id')
    guardian_id = Column('guardian_id', INTEGER(display_width=11), comment='guardian的 user_id')
    guardian_name = Column('guardian_name', VARCHAR(length=16), nullable=False)
    guardian_id_card_no = Column('guardian_id_card_no', VARCHAR(length=18), nullable=False)
    guardian_mobile = Column('guardian_mobile', VARCHAR(length=11), nullable=False)
    child_id = Column('child_id', INTEGER(display_width=11), comment='参加活动的child_id')
    child_nickname = Column('child_nickname', VARCHAR(length=16), nullable=False)
    child_name = Column('child_name', VARCHAR(length=16), nullable=False)
    child_id_card_no = Column('child_id_card_no', VARCHAR(length=18), nullable=False)
    time_sharing_id = Column('time_sharing_id', INTEGER(display_width=20), nullable=False)
    start_ts = Column('start_ts', INTEGER(display_width=10), nullable=False, comment='活动开始ts')
    end_ts = Column('end_ts', INTEGER(display_width=10), nullable=False, comment='活动结束ts')
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')), comment='订单状态 1 待支付 2 进行中(已支付) 3 已取消 4 已完成 5 已关闭 ')
    refund_status = Column('refund_status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='退款状态 0 无退款 1 退款中 2 已退款 ')
    fund_status = Column('fund_status', TINYINT(display_width=1), server_default=DefaultClause(TextClause('0')), comment='退款状态 0 无放款 1放款中 2 已放款')
    seller_id = Column('seller_id', INTEGER(display_width=11), nullable=False)
    address_id = Column('address_id', INTEGER(display_width=11), nullable=False)
    city_id = Column('city_id', INTEGER(display_width=11))
    insurance_id = Column('insurance_id', INTEGER(display_width=11))
    remark = Column('remark', VARCHAR(length=100))
    cancel_reason = Column('cancel_reason', TINYINT(display_width=3), server_default=DefaultClause(TextClause('0')), comment='取消原因 家长:100 订单有误 101 已和看护人沟通 102 计划有变 103 其他 看护人:200')
    create_ts = Column('create_ts', INTEGER(display_width=10), nullable=False, server_default=DefaultClause(TextClause('0')))
    payment_ts = Column('payment_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    update_ts = Column('update_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    finish_ts = Column('finish_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    close_ts = Column('close_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    __table_args__ = (
        Index('order_no', Column('order_no', INTEGER(display_width=10), comment='订单号'), unique=True),
    )
コード例 #16
0
class VideoModel(Base):
    __tablename__ = 'video'
    id = Column('id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False)
    cloud = Column('cloud', VARCHAR(length=16), nullable=False)
    bucket = Column('bucket', VARCHAR(length=64), nullable=False)
    key = Column('key', VARCHAR(length=128), nullable=False)
    etag = Column('etag', VARCHAR(length=32))
    mime_type = Column('mime_type', VARCHAR(length=16))
    size = Column('size', INTEGER(display_width=10, unsigned=True))
    duration = Column('duration', INTEGER(display_width=10, unsigned=True), server_default=DefaultClause(TextClause('0')))
    width = Column('width', INTEGER(display_width=10, unsigned=True), server_default=DefaultClause(TextClause('0')))
    height = Column('height', INTEGER(display_width=10, unsigned=True), server_default=DefaultClause(TextClause('0')))
    persistent_id = Column('persistent_id', VARCHAR(length=32))
    pfop_vframe_status = Column('pfop_vframe_status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    pfop_transcode_status = Column('pfop_transcode_status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    create_ts = Column('create_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    __table_args__ = (
        Index('video_cloud_bucket_key_index_unique', 'cloud', 'bucket', 'key', unique=True),
    )
コード例 #17
0
def downgrade(pyramid_env):
    from assembl import models as m
    db = m.get_session_maker()()
    with context.begin_transaction():
        op.create_table(
            "user_language_preference_temp",
            sa.Column("id", sa.Integer, primary_key=True),
            sa.Column("user_id", sa.Integer),
            sa.Column("lang_code", sa.String),
            sa.Column("preferred_order", sa.Integer),
            sa.Column("locale_id", sa.Integer),
            sa.Column("explicitly_defined", sa.Boolean, server_default="0"))

    with transaction.manager:
        from assembl.models.auth import LanguagePreferenceOrder
        op.execute("""INSERT INTO user_language_preference_temp
            (id, user_id, locale_id, preferred_order)
            SELECT id, user_id, locale_id, source_of_evidence
            FROM  user_language_preference""")
        locale_ids = db.execute("""SELECT DISTINCT locale_id, locale.code
            FROM user_language_preference
            JOIN locale ON (locale.id=locale_id)""")
        for locale_id, locale_name in locale_ids:
            op.execute(
                "UPDATE user_language_preference_temp SET lang_code = '%s' WHERE locale_id = %d"
                % (locale_name, locale_id))
        op.execute("""UPDATE user_language_preference_temp
            SET explicitly_defined = 1 WHERE preferred_order = %d""" %
                   (LanguagePreferenceOrder.Explicit, ))
        op.execute("DELETE FROM user_language_preference")
        mark_changed()

    with context.begin_transaction():
        op.add_column(
            'user_language_preference',
            sa.Column('explicitly_defined',
                      sa.Boolean,
                      nullable=False,
                      server_default=TextClause("0")))
        op.add_column(
            'user_language_preference',
            sa.Column('lang_code',
                      sa.String(),
                      nullable=False,
                      server_default=""))
        op.drop_index('%s_%s_user_language_preference_UNQC_user_id_locale_id' %
                      (config.get('db_schema'), config.get('db_user')))

        op.create_index(
            '%s_%s_user_language_preference_UNQC_user_id_lang_code' %
            (config.get('db_schema'), config.get('db_user')),
            'user_language_preference', ['user_id', 'lang_code'],
            unique=True)

        op.drop_column('user_language_preference', 'source_of_evidence')
        op.drop_column('user_language_preference', 'translate_to')
        op.drop_column('user_language_preference', 'locale_id')
    with transaction.manager:
        op.execute("""INSERT INTO user_language_preference
            (id, user_id, lang_code, preferred_order, explicitly_defined)
            SELECT id, user_id, lang_code, preferred_order, explicitly_defined
            FROM  user_language_preference_temp""")
        mark_changed()
    with context.begin_transaction():
        op.drop_table("user_language_preference_temp")
コード例 #18
0
class UserIdentityModel(Base):
    __tablename__ = 'user_identity'
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False, autoincrement=False)
    id_card_no = Column('id_card_no', VARCHAR(length=18), nullable=False)
    name = Column('name', VARCHAR(length=16), nullable=False)
    liveness_id = Column('liveness_id', VARCHAR(length=36))
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    id_card_image_oss = Column('id_card_image_oss', VARCHAR(length=255))
    liveness_image_oss = Column('liveness_image_oss', VARCHAR(length=255))
    create_ts = Column('create_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
コード例 #19
0
class UserGuardianModel(Base):
    __tablename__ = 'user_guardian'
    id = Column('id', INTEGER(display_width=11, unsigned=True), primary_key=True, nullable=False)
    user_id = Column('user_id', INTEGER(display_width=11, unsigned=True), nullable=False)
    id_card_no = Column('id_card_no', VARCHAR(length=18), nullable=False)
    realname = Column('realname', VARCHAR(length=16), nullable=False)
    mobile = Column('mobile', VARCHAR(length=11))
    status = Column('status', TINYINT(display_width=1), nullable=False, server_default=DefaultClause(TextClause('0')))
    create_ts = Column('create_ts', INTEGER(display_width=10), server_default=DefaultClause(TextClause('0')))
    __table_args__ = (
        Index('user_guardian_id_card_no_UNIQUE', Column('id_card_no', VARCHAR(length=12)), unique=True),
    )