def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('token_snapshots', sa.Column('is_contract', mysql.BIT(), nullable=True)) op.drop_column('token_snapshots', 'address_type') op.add_column('transfer_info', sa.Column('is_contract', mysql.BIT(), nullable=False)) op.drop_column('transfer_info', 'address_type')
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column( 'user', sa.Column('tutorial_state', mysql.BIT(length=32), server_default=sa.text("b'0'"), nullable=False))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column( "token_snapshots", sa.Column("is_considered", mysql.BIT(), nullable=True) ) op.add_column( "token_snapshots", sa.Column("comment", sa.VARCHAR(length=256), nullable=True) )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'occam_airdrop_events_raw', sa.Column('row_id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('block_no', sa.Integer(), nullable=False), sa.Column('uncle_block_no', sa.Integer(), nullable=True), sa.Column('event', sa.VARCHAR(length=256), nullable=False), sa.Column('json_str', sa.VARCHAR(length=256), nullable=True), sa.Column('processed', mysql.BIT(), nullable=True), sa.Column('transactionHash', sa.VARCHAR(length=256), nullable=True), sa.Column('logIndex', sa.VARCHAR(length=256), nullable=True), sa.Column('error_code', sa.Integer(), nullable=True), sa.Column('error_msg', sa.VARCHAR(length=256), nullable=True), sa.Column('row_updated', mysql.TIMESTAMP(), nullable=True), sa.Column('row_created', mysql.TIMESTAMP(), nullable=True), sa.PrimaryKeyConstraint('row_id'), sa.UniqueConstraint('transactionHash', 'logIndex', name='uq_oaer')) op.create_index('blk_no_idx', 'occam_airdrop_events_raw', ['block_no'], unique=False)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'audit_generated_games', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('randomizer', sa.String(length=45), nullable=True), sa.Column('hash_id', sa.String(length=50), nullable=True), sa.Column('permalink', sa.String(length=2000), nullable=True), sa.Column('settings', sa.JSON(), nullable=True), sa.Column('gentype', sa.String(length=45), nullable=True), sa.Column('genoption', sa.String(length=45), nullable=True), sa.Column('timestamp', sa.DateTime(), server_default=sa.text( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), sa.Column('customizer', mysql.INTEGER(display_width=11), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_audit_generated_games_hash_id'), 'audit_generated_games', ['hash_id'], unique=False) op.create_table( 'audit_messages', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('message_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('user_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('channel_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('message_date', sa.DateTime(), nullable=True), sa.Column('content', sa.String(length=4000, collation='utf8mb4_bin'), nullable=True), sa.Column('attachment', sa.String(length=2000, collation='utf8mb4_bin'), nullable=True), sa.Column('deleted', mysql.INTEGER(display_width=11), server_default=sa.text("'0'"), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_audit_messages_message_id'), 'audit_messages', ['message_id'], unique=False) op.create_table( 'config', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('parameter', sa.String(length=45, collation='utf8mb4_unicode_ci'), nullable=False), sa.Column('value', sa.String(length=45, collation='utf8mb4_unicode_ci'), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'daily', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('hash', sa.String(length=45, collation='utf8_bin'), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table( 'gtbk_games', sa.Column('game_id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('channel', sa.String(length=200), nullable=True), sa.Column('status', sa.String(length=45), nullable=True), sa.Column('timestamp', sa.DateTime(), server_default=sa.text( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), sa.PrimaryKeyConstraint('game_id')) op.create_table( 'gtbk_guesses', sa.Column('guess_id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('game_id', mysql.INTEGER(display_width=11), nullable=True), sa.Column('twitch_user', sa.String(length=200), nullable=True), sa.Column('guess', mysql.INTEGER(display_width=11), nullable=True), sa.Column('score', mysql.INTEGER(display_width=11), server_default=sa.text("'0'"), nullable=True), sa.Column('timestamp', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.PrimaryKeyConstraint('guess_id')) op.create_index('guess_UNIQUE', 'gtbk_guesses', ['game_id', 'twitch_user'], unique=True) op.create_table( 'gtbk_whitelist', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('channel', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.Column('twitch_user', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'mention_counters', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('role_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('counter', mysql.INTEGER(display_width=11), server_default=sa.text("'1'"), nullable=False), sa.Column('last_used', sa.DateTime(), server_default=sa.text( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('role_id')) op.create_table( 'permissions', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('role_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('permission', sa.String(length=45, collation='utf8mb4_unicode_ci'), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'reaction_group', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('channel_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('message_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('name', sa.String(length=400, collation='utf8mb4_unicode_ci'), nullable=True), sa.Column('description', mysql.VARCHAR(length=1000), nullable=True), sa.Column('bot_managed', mysql.INTEGER(display_width=11), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('message_id')) op.create_table( 'reaction_role', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('reaction_group_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('role_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('name', sa.String(length=45, collation='utf8mb4_unicode_ci'), nullable=False), sa.Column('emoji', mysql.VARCHAR(length=200), nullable=False), sa.Column('description', sa.String(length=400, collation='utf8mb4_unicode_ci'), nullable=True), sa.Column('protect_mentions', mysql.TINYINT(display_width=1), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'seed_presets', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('name', mysql.VARCHAR(length=45), nullable=False), sa.Column('randomizer', mysql.VARCHAR(length=45), nullable=True), sa.Column('customizer', mysql.TINYINT(display_width=4), nullable=True), sa.Column('settings', sa.JSON(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_table( 'spoiler_races', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('srl_id', sa.String(length=45, collation='utf8_bin'), nullable=False), sa.Column('spoiler_url', sa.String(length=255, collation='utf8_bin'), nullable=False), sa.Column('studytime', mysql.INTEGER(display_width=11), nullable=True), sa.Column('date', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('srl_id')) op.create_table( 'srl_nick_verification', sa.Column('srl_nick', sa.String(length=45, collation='utf8_bin'), nullable=False), sa.Column('key', mysql.BIGINT(display_width=20), nullable=True), sa.Column('discord_user_id', mysql.BIGINT(display_width=20), nullable=True), sa.Column('timestamp', sa.DateTime(), server_default=sa.text( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), sa.PrimaryKeyConstraint('srl_nick'), sa.UniqueConstraint('key'), sa.UniqueConstraint('srl_nick')) op.create_table( 'srl_races', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('srl_id', sa.String(length=45), nullable=False), sa.Column('goal', sa.String(length=200), nullable=False), sa.Column('timestamp', sa.DateTime(), server_default=sa.text( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=True), sa.Column('message', sa.String(length=200), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('srl_id')) op.create_table( 'srlnick', sa.Column('discord_user_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('srl_nick', sa.String(length=200), nullable=True), sa.Column('twitch_name', sa.String(length=200), nullable=True), sa.Column('srl_verified', mysql.BIT(length=1), nullable=True), sa.PrimaryKeyConstraint('discord_user_id')) op.create_index(op.f('ix_srlnick_srl_nick'), 'srlnick', ['srl_nick'], unique=False) op.create_index(op.f('ix_srlnick_twitch_name'), 'srlnick', ['twitch_name'], unique=False) op.create_table( 'tournament_results', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('srl_id', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('episode_id', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('permalink', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.Column('spoiler', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.Column('event', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('status', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('results_json', sa.JSON(), nullable=True), sa.Column('week', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('written_to_gsheet', mysql.TINYINT(display_width=4), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'twitch_channels', sa.Column('channel', sa.String(length=200), nullable=False), sa.Column('group', sa.String(length=45), nullable=False), sa.PrimaryKeyConstraint('channel')) op.create_table( 'twitch_command_text', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('channel', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.Column('command', sa.String(length=45, collation='utf8_bin'), nullable=True), sa.Column('content', sa.String(length=200, collation='utf8_bin'), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index('idx_twitch_command_text_channel_command', 'twitch_command_text', ['channel', 'command'], unique=True) op.create_table( 'voice_role', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('guild_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('voice_channel_id', mysql.BIGINT(display_width=20), nullable=False), sa.Column('role_id', mysql.BIGINT(display_width=20), nullable=False), sa.PrimaryKeyConstraint('id'))
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('barber_order', sa.Column('id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('comment', mysql.VARCHAR(length=255), nullable=True), sa.Column('commented', mysql.BIT(length=1), nullable=False), sa.Column('cut', mysql.BIT(length=1), nullable=False), sa.Column('date', mysql.VARCHAR(length=255), nullable=True), sa.Column('hair_desc', mysql.VARCHAR(length=255), nullable=True), sa.Column('hair_img_url', mysql.VARCHAR(length=255), nullable=True), sa.Column('hairdresser_comment', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('hairdresser_tel', mysql.VARCHAR(length=255), nullable=True), sa.Column('user_tel', mysql.VARCHAR(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8mb4', mysql_engine=u'MyISAM') op.create_table('bar_ber', sa.Column('id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('business_license', mysql.VARCHAR(length=255), nullable=True), sa.Column('auth', mysql.BIT(length=1), nullable=False), sa.Column('img_url', mysql.VARCHAR(length=255), nullable=True), sa.Column('location', mysql.VARCHAR(length=255), nullable=True), sa.Column('store_name', mysql.VARCHAR(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8mb4', mysql_engine=u'MyISAM') op.create_table('bar_user', sa.Column('id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('business_license', mysql.VARCHAR(length=255), nullable=True), sa.Column('idcard_url', mysql.VARCHAR(length=255), nullable=True), sa.Column('barber_id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('img_url', mysql.VARCHAR(length=255), nullable=True), sa.Column('password', mysql.VARCHAR(length=255), nullable=True), sa.Column('preparing', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('role', mysql.BIT(length=1), nullable=False), sa.Column('salt', mysql.VARCHAR(length=255), nullable=True), sa.Column('tel', mysql.VARCHAR(length=255), nullable=True), sa.Column('user_name', mysql.VARCHAR(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8mb4', mysql_engine=u'MyISAM') op.create_table('location', sa.Column('id', mysql.BIGINT(display_width=20), autoincrement=True, nullable=False), sa.Column('location', mysql.VARCHAR(length=255), nullable=True), sa.Column('name', mysql.VARCHAR(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8mb4', mysql_engine=u'InnoDB') op.create_table('move_base_goal', sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False, comment=u'id'), sa.Column('position_x', mysql.FLOAT(), nullable=False), sa.Column('position_y', mysql.FLOAT(), nullable=False), sa.Column('position_z', mysql.FLOAT(), nullable=False), sa.Column('orientation_x', mysql.FLOAT(), nullable=False), sa.Column('orientation_y', mysql.FLOAT(), nullable=False), sa.Column('orientation_z', mysql.FLOAT(), nullable=False), sa.Column('orientation_w', mysql.FLOAT(), nullable=False), sa.Column('location', mysql.TEXT(), nullable=False, comment=u'?????????'), sa.PrimaryKeyConstraint('id'), comment=u'?????????', mysql_comment=u'?????????', mysql_default_charset=u'utf8mb4', mysql_engine=u'InnoDB') op.create_table('barber_robbing_order', sa.Column('id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('hair_desc', mysql.VARCHAR(length=255), nullable=True), sa.Column('hairdresser_get', mysql.BIT(length=1), nullable=False), sa.Column('hairdresser_tel', mysql.VARCHAR(length=255), nullable=True), sa.Column('latitude', mysql.VARCHAR(length=255), nullable=True), sa.Column('order_id', mysql.BIGINT(display_width=20), autoincrement=False, nullable=False), sa.Column('user_get', mysql.BIT(length=1), nullable=False), sa.Column('user_tel', mysql.VARCHAR(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8mb4', mysql_engine=u'MyISAM') op.create_table('hibernate_sequence', sa.Column('next_val', mysql.BIGINT(display_width=20), autoincrement=False, nullable=True), mysql_default_charset=u'utf8mb4', mysql_engine=u'MyISAM') op.drop_index(op.f('ix_pose_to_location_location'), table_name='pose_to_location') op.drop_table('pose_to_location')
class User(Base, BaseMixin): __tablename__ = 'user' email = sa.Column(sa.Unicode(1024), nullable=False, unique=True) display_name = sa.Column(sa.Unicode(256), nullable=False) username = sa.Column(sa.Unicode(256), nullable=True, unique=True) role = sa.Column(sa.Unicode(1024), nullable=False, server_default='user') platform = sa.Column(sa.Unicode(16), nullable=True) last_login_at = sa.Column(sa.DateTime, nullable=True) description = sa.Column(sa.Unicode(1024), nullable=False, server_default='') seeking_subscription_message = sa.Column(sa.Unicode(1024), nullable=False, server_default='') language = sa.Column(sa.Unicode(7), nullable=True) ui_language = sa.Column(sa.Unicode(7), nullable=False, server_default='en') avatar_storage = sa.Column(FileHandleStore, nullable=True) is_trial = sa.Column(sa.Boolean, nullable=False, server_default=false()) mailchimp_stage = sa.Column(sa.Integer, nullable=False, server_default="1") customer_id = sa.Column(sa.Unicode(128), nullable=True, unique=True) stripe_access_token = sa.Column(sa.Unicode(128), nullable=True, unique=True) stripe_refresh_token = sa.Column(sa.Unicode(128), nullable=True, unique=True) stripe_account_id = sa.Column(sa.Unicode(128), nullable=True, unique=False) android_product_id = sa.Column(sa.Unicode(128), nullable=True) android_original_transaction_id = sa.Column(sa.Unicode(128), nullable=True, unique=True) ios_product_id = sa.Column(sa.Unicode(128), nullable=True) ios_original_transaction_id = sa.Column(sa.Unicode(128), nullable=True, unique=True) expire_date = sa.Column(sa.DateTime, nullable=True) is_cancelled = sa.Column(sa.Boolean, nullable=False, server_default=true()) is_anonymous = sa.Column(sa.Boolean, nullable=False, server_default=false()) tutorial_state = sa.Column(mysql.BIT(32), nullable=False, server_default=text("b'0'")) like_coin_id = sa.Column(sa.Unicode(128), nullable=True, unique=True) stories = relationship("Story", secondary=user_story, secondaryjoin='and_( \ user_story.c.story_id==Story.id, \ Story.is_deleted==false() \ )', lazy='select', cascade='', backref=backref("users", lazy="joined", viewonly=True)) liked_stories = relationship("Story", secondary=user_like_story, lazy='select', cascade='', backref=backref('liked_users', lazy="select")) libraries_selected = relationship("Library", secondary=user_selected_library, secondaryjoin='''and_( user_selected_library.c.library_id==Library.id, Library.is_deleted==false() )''', lazy='select', cascade='', backref=backref("selected_users", lazy="select")) links = relationship(UserLink, order_by=UserLink.order, cascade='all, delete', backref=backref("user", lazy="joined")) subscription_payouts = relationship( "UserSubscriptionPayout", primaryjoin="User.id == UserSubscriptionPayout.author_id", lazy='select', viewonly=True) likecoin_txs = relationship('LikecoinTx', primaryjoin="User.id == LikecoinTx.user_id", cascade='', backref=backref('user', lazy='select')) def __init__(self, email, is_anonymous=False): self.email = email self.is_anonymous = is_anonymous self.mailchimp_stage = 1 self.tutorial_state = 0 def serialize(self): return { "id": self.id, "email": self.email, "displayName": self.display_name, "username": self.username, "role": self.role, "description": self.description, 'seekingSubscriptionMessage': self.seeking_subscription_message, "language": self.language, "uiLanguage": self.ui_language, 'avatar': self.avatar_url(), "isTrial": self.is_trial, 'expireDate': self.expire_date.isoformat() if self.expire_date else None, 'androidProductId': self.android_product_id, 'iosProductId': self.ios_product_id, 'isCancelled': self.is_cancelled, 'tutorialState': self.serialize_tutorial_state(), 'isStripeConnected': bool(self.stripe_account_id), 'hasPaymentInfo': bool(self.customer_id), 'isAnonymous': self.is_anonymous, 'likeCoinId': self.like_coin_id, } def serialize_min(self): return { 'id': self.id, "email": self.email, "displayName": self.display_name, 'avatar': self.avatar_url(), } def serialize_credit(self): return { 'id': self.id, 'displayName': self.display_name, 'description': self.description, 'seekingSubscriptionMessage': self.seeking_subscription_message, 'avatar': self.avatar_url(), 'likeCoinId': self.like_coin_id, } def avatar_url(self): return get_upload_base_url( ) + self.avatar_storage.url if self.avatar_storage else '' def serialize_tutorial_state(self): string_bits = str(bin(self.tutorial_state))[2:].zfill(32) bool_list = [] for char in string_bits: bool_list.append(char == '1') return bool_list def import_handle(self, handle): self.avatar_storage = handle def is_free(self): return self.role == "user" def is_paid(self): return self.role == "paid" def is_admin(self): return self.role == "admin" @property def is_new_subscribe(self): return (not self.customer_id) and \ (not self.android_original_transaction_id) and \ (not self.ios_original_transaction_id)
"""The non-standard DOUBLE type.""" __visit_name__ = 'DOUBLE' @compiles(TINYINT) def compile_tinyint(type_, compiler, **kw): return "TINYINT" @compiles(DOUBLE) def compile_double(type_, compiler, **kw): return "DOUBLE" boolean_map = { MYSQL: mysql.BIT(1), ORACLE: oracle.NUMBER(1), POSTGRES: postgresql.BOOLEAN() } byte_map = { MYSQL: mysql.TINYINT(), ORACLE: oracle.NUMBER(3), POSTGRES: postgresql.SMALLINT(), } short_map = { MYSQL: mysql.SMALLINT(), ORACLE: oracle.NUMBER(5), POSTGRES: postgresql.SMALLINT(), }