From 363ab562c3110194fb721591ffe304ba09e6e1b0 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 23 May 2024 22:58:26 -0700 Subject: [PATCH] refac: migration --- .../web/internal/migrations/009_add_models.py | 8 +++++++- backend/apps/web/models/models.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/apps/web/internal/migrations/009_add_models.py b/backend/apps/web/internal/migrations/009_add_models.py index 276769441..20cdd429e 100644 --- a/backend/apps/web/internal/migrations/009_add_models.py +++ b/backend/apps/web/internal/migrations/009_add_models.py @@ -40,11 +40,17 @@ def migrate(migrator: Migrator, database: pw.Database, *, fake=False): @migrator.create_model class Model(pw.Model): id = pw.TextField(unique=True) - meta = pw.TextField() + user_id = pw.TextField() base_model_id = pw.TextField(null=True) + name = pw.TextField() + + meta = pw.TextField() params = pw.TextField() + created_at = (pw.BigIntegerField(null=False),) + updated_at = (pw.BigIntegerField(null=False),) + class Meta: table_name = "model" diff --git a/backend/apps/web/models/models.py b/backend/apps/web/models/models.py index cd734e67b..57d0f02fc 100644 --- a/backend/apps/web/models/models.py +++ b/backend/apps/web/models/models.py @@ -45,10 +45,7 @@ class Model(pw.Model): The model's id as used in the API. If set to an existing model, it will override the model. """ - meta = JSONField() - """ - Holds a JSON encoded blob of metadata, see `ModelMeta`. - """ + user_id = pw.TextField() base_model_id = pw.TextField(null=True) """ @@ -66,16 +63,24 @@ class Model(pw.Model): Holds a JSON encoded blob of parameters, see `ModelParams`. """ + meta = JSONField() + """ + Holds a JSON encoded blob of metadata, see `ModelMeta`. + """ + + updated_at: int # timestamp in epoch + created_at: int # timestamp in epoch + class Meta: database = DB class ModelModel(BaseModel): id: str - meta: ModelMeta base_model_id: Optional[str] = None name: str params: ModelParams + meta: ModelMeta ####################