class TodoTable(db.Table, table_name="todos"): id = db.PrimaryKeyColumn() owner_id = db.Column(db.Integer(big=True)) content = db.Column(db.String) added_at = db.Column(db.Datetime) jump_url = db.Column(db.String)
class Reminders(db.Table): id = db.PrimaryKeyColumn() expires = db.Column(db.Datetime, index=True) created = db.Column(db.Datetime, default="now() at time zone 'utc'") event = db.Column(db.String) extra = db.Column(db.JSON, default="'{}'::jsonb")
class Plonks(db.Table): """ Create db table for plonks. """ id = db.PrimaryKeyColumn() guild_id = db.Column(db.Integer(big=True), index=True) # this can either be a channel_id or an author_id entity_id = db.Column(db.Integer(big=True), index=True, unique=True)
class TwitchSecretTable(db.Table): """ Creates the database for storing the OAuth secret. """ id = db.PrimaryKeyColumn() secret = db.Column(db.String) edited_at = db.Column(db.Datetime) expires_at = db.Column(db.Datetime)
class TodoTable(db.Table, table_name="todos"): id = db.PrimaryKeyColumn() owner_id = db.Column(db.Integer(big=True)) content = db.Column(db.String) added_at = db.Column(db.Datetime(timezone=True), default="now() at time zone 'utc'") jump_url = db.Column(db.String)
class TwitchClipTable(db.Table): """ Creates the Clip table for storing clip following data. """ id = db.PrimaryKeyColumn() guild_id = db.Column(db.Integer(big=True)) channel_id = db.Column(db.Integer(big=True)) broadcaster_id = db.Column(db.String()) last_25_clips = db.Column(db.Array(db.String()))
class StatisticsTable(db.Table, table_name="statistics"): id = db.PrimaryKeyColumn() message_deletes = db.Column(db.Integer(big=True)) bulk_message_deletes = db.Column(db.Integer(big=True)) message_edits = db.Column(db.Integer(big=True)) bans = db.Column(db.Integer(big=True)) unbans = db.Column(db.Integer(big=True)) channel_deletes = db.Column(db.Integer(big=True)) channel_creates = db.Column(db.Integer(big=True)) command_count = db.Column(db.Integer(big=True))
class SnipeDeleteTable(db.Table, table_name="snipe_deletes"): id = db.PrimaryKeyColumn() user_id = db.Column(db.Integer(big=True)) guild_id = db.Column(db.Integer(big=True)) channel_id = db.Column(db.Integer(big=True)) message_id = db.Column(db.Integer(big=True)) message_content = db.Column(db.String()) attachment_urls = db.Column(db.Array(db.String()), nullable=True) delete_time = db.Column(db.Integer(big=True))
class TwitchTable(db.Table): """ Create the twitch database table. """ id = db.PrimaryKeyColumn() guild_id = db.Column(db.Integer(big=True)) channel_id = db.Column(db.Integer(big=True)) streamer_name = db.Column(db.String) streamer_last_game = db.Column(db.String()) streamer_last_datetime = db.Column(db.Datetime())
class Commands(db.Table): id = db.PrimaryKeyColumn() guild_id = db.Column(db.Integer(big=True), index=True) channel_id = db.Column(db.Integer(big=True)) author_id = db.Column(db.Integer(big=True), index=True) used = db.Column(db.Datetime, index=True) prefix = db.Column(db.String) command = db.Column(db.String, index=True) failed = db.Column(db.Boolean, index=True)
class SnipeEditTable(db.Table, table_name="snipe_edits"): id = db.PrimaryKeyColumn() user_id = db.Column(db.Integer(big=True)) guild_id = db.Column(db.Integer(big=True)) channel_id = db.Column(db.Integer(big=True)) message_id = db.Column(db.Integer(big=True)) before_content = db.Column(db.String()) after_content = db.Column(db.String()) edited_time = db.Column(db.Integer(big=True)) jump_url = db.Column(db.String)
class CommandConfig(db.Table, table_name="command_config"): """ Create db table for command config. """ id = db.PrimaryKeyColumn() guild_id = db.Column(db.Integer(big=True), index=True) channel_id = db.Column(db.Integer(big=True)) name = db.Column(db.String) whitelist = db.Column(db.Boolean) @classmethod def create_table(cls, *, exists_ok=True): statement = super().create_table(exists_ok=exists_ok) # create the unique index sql = "CREATE UNIQUE INDEX IF NOT EXISTS command_config_uniq_idx ON command_config (channel_id, name, whitelist);" return statement + "\n" + sql
class TagLookup(db.Table, table_name="tag_lookup"): id = db.PrimaryKeyColumn() # we will create more indexes manually name = db.Column(db.String, index=True) location_id = db.Column(db.Integer(big=True), index=True) owner_id = db.Column(db.Integer(big=True)) created_at = db.Column(db.Datetime, default="now() at time zone 'utc'") tag_id = db.Column(db.ForeignKey("tags", "id")) @classmethod def create_table(cls, *, exists_ok=True): statement = super().create_table(exists_ok=exists_ok) # create the indexes sql = ( "CREATE INDEX IF NOT EXISTS tag_lookup_name_trgm_idx ON tag_lookup USING GIN (name gin_trgm_ops);\n" "CREATE INDEX IF NOT EXISTS tag_lookup_name_lower_idx ON tag_lookup (LOWER(name));\n" "CREATE UNIQUE INDEX IF NOT EXISTS tag_lookup_uniq_idx ON tag_lookup (LOWER(name), location_id);" ) return statement + "\n" + sql
class Feeds(db.Table): id = db.PrimaryKeyColumn() channel_id = db.Column(db.Integer(big=True)) role_id = db.Column(db.Integer(big=True)) name = db.Column(db.String)