FRCDiscord / Dozer

Omnipotent guild management bot for FIRST Discord servers
GNU General Public License v3.0
42 stars 45 forks source link

[DRAFT PR] ORMTables -- DatabaseTables with less boilerplate #416

Open guineawheek opened 1 year ago

guineawheek commented 1 year ago

Overview

ORM tables are a new variant on DatabaseTables:

Differences from DatabaseTable:

Versioning:

Worked example:

    class StarboardConfig(db.ORMTable):
        __tablename__ = 'starboard_settings'
        __uniques__ = ('guild_id',) 

        # the column definitions
        guild_id: int     = db.Column("bigint NOT NULL")
        channel_id: int   = db.Column("bigint NOT NULL")
        star_emoji: str   = db.Column("varchar NOT NULL")
        cancel_emoji: str = db.Column("varchar")
        threshold: int    = db.Column("bigint NOT NULL")
        # this parameter could be added later down the line, and it will be added using ALTER TABLE.
        some_new_col: int = db.Column("bigint NOT NULL DEFAULT 10", version=1)

TODO