Skip to content

Commit

Permalink
Use JSONB instead of JSON for thread metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakar-io committed May 8, 2024
1 parent bf2264f commit 712ccc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/app/lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ async def _init_connection(conn) -> None:
decoder=orjson.loads,
schema="pg_catalog",
)
await conn.set_type_codec(
"jsonb",
encoder=lambda v: orjson.dumps(v).decode(),
decoder=orjson.loads,
schema="pg_catalog",
)
await conn.set_type_codec(
"uuid", encoder=lambda v: str(v), decoder=lambda v: v, schema="pg_catalog"
)
Expand Down
2 changes: 1 addition & 1 deletion backend/migrations/000004_add_metadata_to_thread.up.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ALTER TABLE thread
ADD COLUMN metadata JSON;
ADD COLUMN metadata JSONB;

UPDATE thread
SET metadata = json_build_object(
Expand Down

0 comments on commit 712ccc6

Please sign in to comment.