Exemple #1
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('student',
    sa.Column('sid', mysql.VARCHAR(length=20), nullable=False),
    sa.Column('name', mysql.VARCHAR(length=20), nullable=False),
    sa.Column('password', mysql.VARCHAR(length=20), nullable=False),
    sa.Column('sex', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False),
    mysql_default_charset='latin1',
    mysql_engine='InnoDB'
    )
    op.create_table('employee',
    sa.Column('name', mysql.CHAR(length=20), nullable=False),
    sa.Column('street', mysql.CHAR(length=15), nullable=True),
    sa.Column('city', mysql.CHAR(length=15), nullable=True),
    sa.Column('salary', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    mysql_default_charset='latin1',
    mysql_engine='InnoDB'
    )
    op.create_table('department',
    sa.Column('name', mysql.CHAR(length=20), nullable=False),
    sa.Column('department', mysql.CHAR(length=20), nullable=True),
    mysql_default_charset='latin1',
    mysql_engine='InnoDB'
    )
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
Exemple #2
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'users',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('phone', mysql.CHAR(length=15), nullable=True),
        sa.Column('password', mysql.TEXT(), nullable=True),
        sa.Column('nick_name', mysql.CHAR(length=50), nullable=True),
        sa.Column('picture', mysql.TEXT(), nullable=True),
        sa.Column('registered_at', mysql.DATETIME(), nullable=True),
        sa.Column('religion', mysql.TEXT(), nullable=True),
        sa.Column('smoke', sa.BOOLEAN(), nullable=True),
        sa.Column('job', mysql.TEXT(), nullable=True),
        sa.Column('school', mysql.TEXT(), nullable=True),
        sa.Column('major', mysql.TEXT(), nullable=True),
        sa.Column('company', mysql.TEXT(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('nick_name'),
        sa.UniqueConstraint('phone'))
    op.create_table(
        'user_sessions',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('token', mysql.TEXT(), nullable=True),
        sa.Column('third_party_token', mysql.TEXT(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('expiry', mysql.DATETIME(), nullable=False),
        sa.Column('activated', sa.Integer(), server_default='1',
                  nullable=True),
        sa.Column('admin', sa.BOOLEAN(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
Exemple #3
0
class User(BASE):
    __tablename__ = "users_main"
    id = Column("ID", mysql.INTEGER(10, unsigned=True), primary_key=True)
    username = Column('Username', mysql.VARCHAR(20))
    email = Column('Email', mysql.VARCHAR(255))
    pass_hash = Column('PassHash', mysql.VARCHAR(60))
    secret = Column('Secret', mysql.VARCHAR(32))
    irc_key = Column('IRCKey', mysql.CHAR(32))
    last_login = Column('LastLogin', mysql.DATETIME)
    last_access = Column('LastAccess', mysql.DATETIME)
    ip = Column('IP', mysql.VARCHAR(15))
    class_id = Column('Class', mysql.TINYINT(2))
    uploaded = Column('Uploaded', mysql.BIGINT(20, unsigned=True))
    downloaded = Column('Downloaded', mysql.BIGINT(20, unsigned=True))
    title = Column('Title', mysql.TEXT)
    enabled = Column('Enabled', mysql.ENUM('0', '1', '2'))
    paranoia = Column('Paranoia', mysql.TEXT)
    visible = Column('Visible', mysql.ENUM('1', '0'))
    invites = Column('Invites', mysql.INTEGER(10, unsigned=True))
    permission_id = Column('PermissionID', mysql.INTEGER(10, unsigned=True),
                           ForeignKey('permissions.ID'))
    custom_permissions = Column('CustomPermissions', mysql.TEXT)
    can_leech = Column('can_leech', mysql.TINYINT(4))
    torrent_pass = Column('torrent_pass', mysql.CHAR(32))
    required_ratio = Column('RequiredRatio', mysql.DOUBLE(10, 8))
    required_ratio_work = Column('RequiredRatioWork', mysql.DOUBLE(10, 8))
    ipcc = Column('ipcc', mysql.VARCHAR(2))
    fl_tokens = Column('FLTokens', mysql.INTEGER(10))

    permission_class = relationship("Permissions")

    info = relationship("UsersInfo")

    def get_paranoia(self):
        return dict_to_list(unserialize(bytes(str(self.paranoia), 'utf-8')))
Exemple #4
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('message',
                    sa.Column('id',
                              mysql.BIGINT(display_width=20, unsigned=True),
                              nullable=False),
                    sa.Column('username',
                              mysql.VARCHAR(length=32),
                              nullable=False),
                    sa.Column('email', mysql.CHAR(length=40), nullable=False),
                    sa.Column('useraddress',
                              mysql.CHAR(length=100),
                              nullable=False),
                    sa.Column('messagetext', mysql.TEXT(), nullable=True),
                    sa.Column(
                        'up_utime',
                        mysql.DATETIME(),
                        server_default=sa.text(
                            'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
                        nullable=False),
                    sa.Column('up_ctime',
                              mysql.DATETIME(),
                              server_default=sa.text('CURRENT_TIMESTAMP'),
                              nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_comment='???',
                    mysql_default_charset='utf8',
                    mysql_engine='InnoDB')
    op.drop_table('message_flask')
Exemple #5
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'mbti_questions',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('question', mysql.TEXT(), nullable=True),
        sa.Column('determinant', mysql.CHAR(length=5), nullable=True),
        sa.Column('positive', sa.BOOLEAN(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'terms',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('title', mysql.TEXT(), nullable=True),
        sa.Column('body', mysql.TEXT(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'terms_agreements',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('term_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('agreed_at', mysql.DATETIME(), nullable=True),
        sa.ForeignKeyConstraint(
            ['term_id'],
            ['terms.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.add_column('animals',
                  sa.Column('mbti', mysql.CHAR(length=50), nullable=True))
    op.add_column('animals',
                  sa.Column('name', mysql.CHAR(length=50), nullable=True))
    op.drop_column('users', 'hp')
    op.drop_column('users', 'mp')
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('UserLog',
                    'userName',
                    existing_type=mysql.VARCHAR(length=20),
                    nullable=True)
    op.alter_column('CourseType',
                    'Cou_typeId',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=True)
    op.alter_column('CourseRsc',
                    'chapId',
                    existing_type=mysql.CHAR(length=15),
                    nullable=True)
    op.alter_column('CourseInfo',
                    'typeId',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=True)
    op.alter_column('CourseDoc',
                    'chapId',
                    existing_type=mysql.CHAR(length=15),
                    nullable=True)
    op.alter_column('ChapterInfo',
                    'courseId',
                    existing_type=mysql.CHAR(length=8),
                    nullable=True)
    op.alter_column('AdminLog',
                    'adminName',
                    existing_type=mysql.VARCHAR(length=20),
                    nullable=True)
Exemple #7
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('ih_user_profile',
                    'password_hash',
                    existing_type=mysql.VARCHAR(charset='utf8', length=128),
                    nullable=True)
    op.alter_column('ih_user_profile',
                    'name',
                    existing_type=mysql.VARCHAR(charset='utf8', length=32),
                    nullable=True)
    op.alter_column('ih_user_profile',
                    'mobile',
                    existing_type=mysql.VARCHAR(charset='utf8', length=11),
                    nullable=True)
    op.drop_column('ih_order_info', 'trade_no')
    op.alter_column('ih_house_info',
                    'title',
                    existing_type=mysql.VARCHAR(charset='utf8', length=64),
                    nullable=True)
    op.alter_column('ih_house_image',
                    'url',
                    existing_type=mysql.VARCHAR(charset='utf8', length=256),
                    nullable=True)
    op.alter_column('ih_facility_info',
                    'name',
                    existing_type=mysql.CHAR(charset='utf8', length=10),
                    nullable=True)
    op.alter_column('ih_area_info',
                    'name',
                    existing_type=mysql.CHAR(length=10),
                    nullable=True)
Exemple #8
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'animal_corelations',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'hearts',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('from_user', sa.Integer(), nullable=True),
        sa.Column('to_user', sa.Integer(), nullable=True),
        sa.Column('double', sa.BOOLEAN(), nullable=True),
        sa.Column('created_at', mysql.DATETIME(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'notifications',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'users',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('email', mysql.TEXT(), nullable=True),
        sa.Column('password', mysql.TEXT(), nullable=True),
        sa.Column('occupation', mysql.TEXT(), nullable=True),
        sa.Column('name', mysql.CHAR(length=50), nullable=True),
        sa.Column('pictures', LaboratoryTypes.TextTuple(), nullable=True),
        sa.Column('bio', mysql.TEXT(), nullable=True),
        sa.Column('phone', mysql.CHAR(length=20), nullable=True),
        sa.Column('location', mysql.TEXT(), nullable=True),
        sa.Column('body_shape', mysql.TEXT(), nullable=True),
        sa.Column('religion', mysql.TEXT(), nullable=True),
        sa.Column('hobby', mysql.TEXT(), nullable=True),
        sa.Column('speciality', mysql.TEXT(), nullable=True),
        sa.Column('interest', mysql.TEXT(), nullable=True),
        sa.Column('drink', mysql.TEXT(), nullable=True),
        sa.Column('cigarette', mysql.TEXT(), nullable=True),
        sa.Column('hp', mysql.INTEGER(), nullable=True),
        sa.Column('mp', mysql.INTEGER(), nullable=True),
        sa.Column('registered_at', mysql.DATETIME(), nullable=True),
        sa.Column('last_access', mysql.DATETIME(), nullable=True),
        sa.Column('fcm_token', mysql.TEXT(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'),
        sa.UniqueConstraint('phone'))
    op.create_table(
        'user_point_transactions',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('created_at', mysql.DATETIME(), nullable=True),
        sa.Column('hp', mysql.INTEGER(), nullable=True),
        sa.Column('mp', mysql.INTEGER(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'user_points',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('hp', mysql.INTEGER(), nullable=True),
        sa.Column('mp', mysql.INTEGER(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
Exemple #9
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'sms_auth',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('auth_key', mysql.CHAR(length=80), nullable=True),
        sa.Column('auth_value', mysql.CHAR(length=10), nullable=True),
        sa.Column('phone_num', mysql.CHAR(length=20), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('expiration', mysql.DATETIME(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
    op.add_column('users', sa.Column('company', mysql.TEXT(), nullable=True))
    op.add_column('users', sa.Column('education', mysql.TEXT(), nullable=True))
    op.add_column('users', sa.Column('height', mysql.INTEGER(), nullable=True))
    op.add_column('users', sa.Column('location1', mysql.TEXT(), nullable=True))
    op.add_column('users', sa.Column('location2', mysql.TEXT(), nullable=True))
    op.add_column(
        'users', sa.Column('occupation_confirmed', sa.BOOLEAN(),
                           nullable=True))
    op.add_column(
        'users',
        sa.Column('occupation_confirmed_at', mysql.DATETIME(), nullable=True))
    op.add_column('users',
                  sa.Column('phone_registered', sa.BOOLEAN(), nullable=True))
    op.drop_column('users', 'location')
Exemple #10
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
                    sa.Column('name',
                              mysql.CHAR(charset='gbk',
                                         collation='gbk_chinese_ci',
                                         length=20),
                              nullable=True),
                    sa.Column('sec',
                              mysql.CHAR(charset='gbk',
                                         collation='gbk_chinese_ci',
                                         length=20),
                              nullable=True),
                    sa.Column('age',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_collate='utf8mb4_0900_ai_ci',
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
Exemple #11
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'user_account',
        sa.Column('invitee_code', mysql.CHAR(length=8), nullable=False))
    op.add_column(
        'user_account',
        sa.Column('inviter_code', mysql.CHAR(length=8), nullable=False))
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('unpwd',
                    sa.Column('Username', mysql.CHAR(length=10),
                              nullable=True),
                    sa.Column('Password', mysql.CHAR(length=20),
                              nullable=True),
                    mysql_default_charset='latin1',
                    mysql_engine='InnoDB')
Exemple #13
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'sms_auth',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('auth_key', mysql.CHAR(length=80), nullable=True),
        sa.Column('auth_value', mysql.CHAR(length=10), nullable=True),
        sa.Column('phone_num', mysql.CHAR(length=20), nullable=True),
        sa.Column('expiration', mysql.DATETIME(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.drop_column('user_sessions', 'third_party_token')
    op.drop_column('user_sessions', 'admin')
Exemple #14
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('mahasiswa',
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.Column('NIM', mysql.CHAR(length=10), nullable=False),
                    sa.Column('Nama', mysql.CHAR(length=100), nullable=False),
                    sa.Column('Alamat', mysql.TEXT(), nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset='latin1',
                    mysql_engine='InnoDB')
    op.create_index('NIM', 'mahasiswa', ['NIM'], unique=True)
    op.drop_table('user')
Exemple #15
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('users',
                    'active',
                    existing_type=sa.Boolean(),
                    type_=mysql.TINYINT(display_width=1),
                    existing_nullable=True)
    op.create_table('role',
                    sa.Column('created_at', mysql.DATETIME(), nullable=True),
                    sa.Column('updated_at', mysql.DATETIME(), nullable=True),
                    sa.Column('active',
                              mysql.TINYINT(display_width=1),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('id',
                              mysql.CHAR(collation='utf8mb4_general_ci',
                                         length=32),
                              nullable=False),
                    sa.Column('name',
                              mysql.VARCHAR(collation='utf8mb4_general_ci',
                                            length=255),
                              nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_collate='utf8mb4_general_ci',
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
    op.create_index('name', 'role', ['name'], unique=True)
    op.drop_table('offers')
    op.drop_table('roles')
    op.drop_table('categories')
    op.drop_table('advs')
Exemple #16
0
class Template(BaseModel, DateMixin):
    """ Template model """

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    userId = db.Column(mysql.INTEGER(10, unsigned=True), ForeignKey('user.id'))
    label = db.Column(db.String(128), nullable=False)
    text = db.Column(db.Text, nullable=False)


    def to_dict(self, properties=None):
        """
        To dictionary
        :param properties: {list} of required properties
        :return: {dict}
        """
        dict = {
            'id': self.id,
            'uuid': self.uuid,
            'label': self.label,
            'text': self.text,
            'created': self.created.isoformat(sep=' ') if self.created \
                                                       else None,
            'updated': self.updated.isoformat(sep=' ') if self.updated \
                                                       else None
        }

        if properties is None:
            properties = dict.keys()

        return {key: dict.get(key) for key in properties}
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('organizations',
                    'authorization',
                    existing_type=sa.String(length=255),
                    type_=mysql.CHAR(length=36),
                    existing_nullable=False)
Exemple #18
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'mbti_questions',
        sa.Column('determinant', mysql.CHAR(length=5), nullable=True))
    op.drop_column('mbti_questions', 'trait')
    op.drop_table('mbti_results')
Exemple #19
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('ip_info',
                    'lock_status',
                    existing_type=sa.SMALLINT(),
                    type_=mysql.CHAR(length=1),
                    existing_nullable=True)
Exemple #20
0
class BookCategory(Base):
    __tablename__ = 'book_category'

    id = sa.Column(
        mysql_types.INTEGER(),
        primary_key=True,
        unique=True,
        nullable=False,
        autoincrement=True,
    )
    book_id = sa.Column(
        mysql_types.CHAR(length=32),
        sa.ForeignKey(column="book.id", ondelete="CASCADE"),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    category_id = sa.Column(
        mysql_types.INTEGER(),
        sa.ForeignKey(column="category.id", ondelete="CASCADE"),
        primary_key=False,
        unique=False,
        nullable=False,
        autoincrement=True,
    )
    book = sa.orm.relationship(
        'Book',
        foreign_keys="[book_category.c.book_id]",
        remote_side=None,
    )
    category = sa.orm.relationship(
        'Category',
        foreign_keys="[book_category.c.category_id]",
        remote_side=None,
    )
Exemple #21
0
class Filing(Base):
    __tablename__ = "filing"

    id = db.Column(db.Integer, primary_key=True)
    EIN = db.Column(m.CHAR(9))
    DLN = db.Column(m.CHAR(14))
    ObjectId = db.Column(m.CHAR(18))
    FormType = db.Column(db.String(20))
    URL = db.Column(db.String(100))
    OrganizationName = db.Column(db.String(120))
    SubmittedOn = db.Column(db.Date)
    LastUpdated = db.Column(db.DateTime)
    TaxPeriod = db.Column(db.Date)
    IsElectronic = db.Column(m.BIT)
    IsAvailable = db.Column(m.BIT)

    raw = relationship("RawXML", back_populates="filing")
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('updatetimestamp', mysql.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False))
    op.create_table('test',
    sa.Column('name', mysql.CHAR(length=32), nullable=True),
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
Exemple #23
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('mbti_indicators',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('synonym', mysql.CHAR(length=10), nullable=True),
    sa.Column('description', mysql.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
Exemple #24
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'users', type_='foreignkey')
    op.drop_constraint(None, 'users', type_='unique')
    op.drop_constraint(None, 'roles', type_='unique')
    op.alter_column('roles', 'name',
               existing_type=mysql.CHAR(length=20),
               nullable=False)
Exemple #25
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'admins',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name',
                  mysql.CHAR(length=30),
                  server_default='',
                  nullable=True),
        sa.Column('password', mysql.TEXT(), nullable=True),
        sa.Column('avatar', mysql.TEXT(), nullable=True),
        sa.Column('role', mysql.CHAR(length=30), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'))
Exemple #26
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('roles', 'name',
               existing_type=mysql.CHAR(length=20),
               nullable=True)
    op.create_unique_constraint(None, 'roles', ['name'])
    op.create_unique_constraint(None, 'users', ['username'])
    op.create_foreign_key(None, 'users', 'roles', ['role_id'], ['id'])
Exemple #27
0
class Application(BaseModel, DateMixin):
    """ Application model """

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    userId = db.Column(mysql.INTEGER(10, unsigned=True), ForeignKey('user.id'))
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    label = db.Column(db.String(32), nullable=False)
    token = db.Column(db.String(32), unique=True, nullable=False)
    prefix = db.Column(db.String(5), unique=True)
    callbackUrl = db.Column(db.String(128))
    note = db.Column(db.String(255))

    outbox = relationship("Outbox", backref='application', lazy='dynamic')
    inbox = relationship("Inbox", backref='application', lazy='dynamic')
    sent_items = relationship("SentItem", backref='application', lazy='dynamic')


    def __init__(self, **kwargs):
        """
        Create token on inicialization
        """
        super(Application, self).__init__(**kwargs)
        # generate token
        self.regenerate_token()


    def regenerate_token(self):
        """
        Regenerate token for API access
        """
        self.token = os.urandom(16).encode('hex')


    def to_dict(self, properties=None):
        """
        To dictionary
        :param properties: {list} of required properties
        :return: {dict}
        """
        dict = {
            'id': self.id,
            'uuid': self.uuid,
            'label': self.label,
            'token': self.token,
            'prefix': self.prefix,
            'callbackUrl': self.callbackUrl,
            'note': self.note,
            'created': self.created.isoformat(sep=' ') if self.created \
                                                       else None,
            'updated': self.updated.isoformat(sep=' ') if self.updated \
                                                       else None
        }

        if properties is None:
            properties = dict.keys()

        return {key: dict.get(key) for key in properties}
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'invest_users',
        sa.Column('user_mobile',
                  mysql.CHAR(length=64),
                  server_default='',
                  nullable=False))
    op.create_unique_constraint(None, 'invest_users', ['user_mobile'])
Exemple #29
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'oauth_naver',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('party_id', mysql.CHAR(length=50), nullable=False),
        sa.Column('party_email', mysql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('party_id'))
Exemple #30
0
class Address(Base):
    __tablename__ = "addresses"
    id = Column(mysql.BIGINT, primary_key=True)
    address = Column(mysql.CHAR(36))
    first_tx_id = Column(mysql.BIGINT)
    first_time = Column(mysql.BIGINT)
    last_time = Column(mysql.BIGINT)
    num_txns = Column(mysql.BIGINT)
    total_received = Column(mysql.BIGINT)
    final_balance = Column(mysql.BIGINT)