Spaces:
Sleeping
Sleeping
ADD: implement foreign models for Workspace, SocialAccount, and Comment
Browse files
repositories/foreign_models.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from peewee import BooleanField, CharField, DateTimeField, TextField, UUIDField
|
| 2 |
+
from playhouse.postgres_ext import BinaryJSONField
|
| 3 |
+
|
| 4 |
+
from repositories.models import BaseModel
|
| 5 |
+
|
| 6 |
+
# Tier B — tables this app reads and (in places) writes rows to, but does not
|
| 7 |
+
# own the schema for. DDL is managed by the teammate's Drizzle migrations on
|
| 8 |
+
# the Next.js side. Deliberately kept out of repositories/models.py so
|
| 9 |
+
# `pw_migrate --auto repositories.models` can never generate a migration
|
| 10 |
+
# that touches these tables.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class Workspace(BaseModel):
|
| 14 |
+
id = TextField(primary_key=True)
|
| 15 |
+
name = TextField()
|
| 16 |
+
slug = TextField(unique=True)
|
| 17 |
+
logo = TextField(null=True)
|
| 18 |
+
metadata = TextField(null=True)
|
| 19 |
+
created_at = DateTimeField(null=True)
|
| 20 |
+
indexed_at = DateTimeField(null=True)
|
| 21 |
+
reply_mode = CharField(max_length=10, null=True)
|
| 22 |
+
usage_warn_80_month = CharField(max_length=7, null=True)
|
| 23 |
+
usage_warn_100_month = CharField(max_length=7, null=True)
|
| 24 |
+
|
| 25 |
+
class Meta:
|
| 26 |
+
table_name = "workspace"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class SocialAccount(BaseModel):
|
| 30 |
+
id = UUIDField(primary_key=True)
|
| 31 |
+
workspace_id = TextField()
|
| 32 |
+
channel = CharField(max_length=20)
|
| 33 |
+
channel_identifier = TextField()
|
| 34 |
+
credentials = BinaryJSONField()
|
| 35 |
+
is_active = BooleanField(default=True)
|
| 36 |
+
connected_by_user_id = TextField(null=True)
|
| 37 |
+
created_at = DateTimeField(null=True)
|
| 38 |
+
updated_at = DateTimeField(null=True)
|
| 39 |
+
|
| 40 |
+
class Meta:
|
| 41 |
+
table_name = "social_account"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class Comment(BaseModel):
|
| 45 |
+
id = UUIDField(primary_key=True)
|
| 46 |
+
workspace_id = TextField()
|
| 47 |
+
channel = CharField(max_length=20)
|
| 48 |
+
external_id = TextField(null=True)
|
| 49 |
+
commenter_handle = TextField(null=True)
|
| 50 |
+
comment_text = TextField()
|
| 51 |
+
reply_text = TextField(null=True)
|
| 52 |
+
route = CharField(max_length=16, null=True)
|
| 53 |
+
created_at = DateTimeField(null=True)
|
| 54 |
+
|
| 55 |
+
class Meta:
|
| 56 |
+
table_name = "comments"
|