social/barkshark_social/database/schema.py

138 lines
4.8 KiB
Python

from bsql import Column, Table, Tables
SCHEMA = Tables(
Table(
"config",
Column("key", "text", nullable = False, unique = True),
Column("value", "text")
),
Table(
"media",
Column("id", "serial"),
Column("filename", "text", nullable = False),
Column("original_name", "text", nullable = False),
Column("created", "timestamp")
),
Table(
"instance",
Column("id", "serial"),
Column("domain", "text", nullable = False, unique = True),
Column("web_domain", "text", nullable = False, unique = True),
Column("shared_inbox", "text", nullable = False),
Column("name", "text"),
Column("description", "text"),
Column("banner", "integer", foreign_key = ("media", "id")),
Column("software", "text", nullable = False),
Column("mod_action", "text"),
Column("mod_action_reason", "text"),
Column("mod_action_date", "timestamp"),
Column("note", "text"),
Column("created", "timestamp", nullable = False),
Column("updated", "timestamp", nullable = False)
),
Table(
"user",
Column("id", "serial"),
Column("username", "text", nullable = False),
Column("domain", "text", foreign_key = ("instance", "domain")),
Column("display_name", "text", nullable = False),
Column("avatar", "integer", foreign_key = ("media", "id")),
Column("banner", "integer", foreign_key = ("media", "id")),
Column("actor", "text", nullable = False),
Column("inbox", "text", nullable = False),
Column("page_url", "text"),
Column("email", "text"),
Column("password", "text"),
Column("permission", "integer", default = "10"),
Column("locked", "boolean", default = "0"),
Column("is_bot", "boolean", default = "0"),
Column("private_key", "text", unique = True),
Column("public_key", "text", nullable = False, unique = True),
Column("bio", "text"),
Column("info", "json", default = "{}"),
Column("is_bot", "boolean", default = "0"),
Column("activated", "timestamp"),
Column("mod_action", "text"),
Column("mod_action_reason", "text"),
Column("mod_action_date", "timestamp"),
Column("note", "text"),
Column("created", "timestamp", nullable = False),
Column("updated", "timestamp", nullable = False)
),
Table(
"follow",
Column("id", "serial"),
Column("sourceid", "integer", nullable = False, foreign_key = ("user", "id")),
Column("source_instanceid", "integer", nullable = False, foreign_key = ("instance", "id")),
Column("targetid", "integer", nullable = False, foreign_key = ("user", "id")),
Column("target_instanceid", "integer", nullable = False, foreign_key = ("instance", "id")),
Column("followid", "text", nullable = False),
Column("accepted", "boolean", nullable = False),
Column("created", "timestamp", nullable = False)
),
Table(
"status",
Column("id", "serial"),
Column("userid", "integer", nullable = False, foreign_key = ("user", "id")),
Column("instanceid", "integer", foreign_key = ("instance", 'id')),
Column("hash", "text", nullable = False),
Column("warning", "text"),
Column("content", "text", nullable = False),
Column("visibility", "text", nullable = False),
Column("reply_to", "integer"),
Column("mentions", "json"),
Column("created", "timestamp", nullable = False),
Column("updated", "timestamp")
),
Table(
"app",
Column("id", "serial"),
Column("name", "text", nullable = False),
Column("url", "text"),
Column("redirect_uri", "text", nullable = False),
Column("client_id", "text", nullable = False),
Column("client_secret", "text", nullable = False),
Column("scope", "json", nullable = False),
Column("created", "timestamp", nullable = False),
),
Table(
"token",
Column("id", "serial"),
Column("code", "text", nullable = False, unique = True),
Column("userid", "integer", nullable = False, foreign_key = ("user", "id")),
Column("appid", "integer", nullable = False, foreign_key = ("app", "id")),
Column("authorization_code", "text", unique = True),
Column("user_agent", "text"),
Column("last_access", "timestamp"),
Column("created", "timestamp")
),
Table(
"cookie",
Column("id", "serial"),
Column("code", "text", nullable = False, unique = True),
Column("userid", "integer", nullable = False, foreign_key = ("user", "id")),
Column("user_agent", "text"),
Column("last_access", "timestamp"),
Column("created", "timestamp")
),
Table(
"emoji",
Column("id", "serial"),
Column("name", "text", nullable = False),
Column("instanceid", "integer", nullable = False, foreign_key = ("instance", "id")),
Column("alt_text", "text"),
Column("display", "boolean", default = "1"),
Column("enabled", "boolean", default = "1"),
Column("created", "timestamp", nullable = False),
),
Table(
"ip_block",
Column("id", "serial"),
Column("addresses", "json", nullable = False),
Column("note", "text"),
Column("created", "timestamp", nullable = False),
Column("updated", "timestamp"),
)
)