sa.Index('hive_votes_voter_id_post_id_idx','voter_id','post_id'),# probably this index is redundant to hive_votes_voter_id_last_update_idx because of starting voter_id.
sa.Index('hive_votes_voter_id_last_update_idx','voter_id','last_update'),# this index is critical for hive_accounts_info_view performance
sa.Index('hive_notifs_ix1','dst_id','id',postgresql_where=sql_text("dst_id IS NOT NULL")),
sa.Index('hive_notifs_ix2','community_id','id',postgresql_where=sql_text("community_id IS NOT NULL")),
sa.Index('hive_notifs_ix3','community_id','type_id','id',postgresql_where=sql_text("community_id IS NOT NULL")),
sa.Index('hive_notifs_ix4','community_id','post_id','type_id','id',postgresql_where=sql_text("community_id IS NOT NULL AND post_id IS NOT NULL")),
sa.Index('hive_notifs_ix5','post_id','type_id','dst_id','src_id',postgresql_where=sql_text("post_id IS NOT NULL AND type_id IN (16,17)")),# filter: dedupe
sa.Index('hive_notifs_ix6','dst_id','created_at','score','id',postgresql_where=sql_text("dst_id IS NOT NULL")),# unread
)
sa.Table('hive_notification_cache',metadata,
sa.Column('id',sa.BigInteger,primary_key=True),
sa.Column('block_num',sa.Integer,nullable=False),
sa.Column('type_id',sa.Integer,nullable=False),
sa.Column('dst',sa.Integer,nullable=True),# dst account id except persistent notifs from hive_notifs
sa.Column('src',sa.Integer,nullable=True),# src account id
sa.Column('dst_post_id',sa.Integer,nullable=True),# destination post id
sa.Column('post_id',sa.Integer,nullable=True),
sa.Column('created_at',sa.DateTime,nullable=False),# notification creation time
sa.Index('hive_votes_voter_id_post_id_idx','voter_id','post_id'),# probably this index is redundant to hive_votes_voter_id_last_update_idx because of starting voter_id.
sa.Index('hive_votes_voter_id_last_update_idx','voter_id','last_update'),# this index is critical for hive_accounts_info_view performance
sa.Index('hive_notifs_ix1','dst_id','id',postgresql_where=sql_text("dst_id IS NOT NULL")),
sa.Index('hive_notifs_ix2','community_id','id',postgresql_where=sql_text("community_id IS NOT NULL")),
sa.Index('hive_notifs_ix3','community_id','type_id','id',postgresql_where=sql_text("community_id IS NOT NULL")),
sa.Index('hive_notifs_ix4','community_id','post_id','type_id','id',postgresql_where=sql_text("community_id IS NOT NULL AND post_id IS NOT NULL")),
sa.Index('hive_notifs_ix5','post_id','type_id','dst_id','src_id',postgresql_where=sql_text("post_id IS NOT NULL AND type_id IN (16,17)")),# filter: dedupe
sa.Index('hive_notifs_ix6','dst_id','created_at','score','id',postgresql_where=sql_text("dst_id IS NOT NULL")),# unread
)
sa.Table('hive_notification_cache',metadata,
sa.Column('id',sa.BigInteger,primary_key=True),
sa.Column('block_num',sa.Integer,nullable=False),
sa.Column('type_id',sa.Integer,nullable=False),
sa.Column('dst',sa.Integer,nullable=True),# dst account id except persistent notifs from hive_notifs
sa.Column('src',sa.Integer,nullable=True),# src account id
sa.Column('dst_post_id',sa.Integer,nullable=True),# destination post id
sa.Column('post_id',sa.Integer,nullable=True),
sa.Column('created_at',sa.DateTime,nullable=False),# notification creation time