Refactor with registry.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from data import Registry, RowModel
|
||||
from data.columns import String, Timestamp, Integer
|
||||
|
||||
|
||||
class Koan(RowModel):
|
||||
"""
|
||||
Schema
|
||||
======
|
||||
CREATE TABLE koans(
|
||||
koanid INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
communityid INTEGER NOT NULL REFERENCES communities ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
name TEXT NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
"""
|
||||
_tablename_ = 'koans'
|
||||
_cache_ = {}
|
||||
|
||||
koanid = Integer(primary=True)
|
||||
communityid = Integer()
|
||||
name = String()
|
||||
message = String()
|
||||
created_at = Timestamp()
|
||||
_timestamp = Timestamp()
|
||||
|
||||
|
||||
class KoanData(Registry):
|
||||
VERSION = ('KOANS', 1)
|
||||
|
||||
koans = Koan.table
|
||||
|
||||
Reference in New Issue
Block a user