From 5d374a1475ce65232bc04e656aa2a8529dd8f9d1 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Wed, 27 Mar 2024 16:15:03 -0300 Subject: [PATCH] Rename schema to key_value_storage --- .../RealtimeIntegrationTests.swift | 34 +++++++++++-------- ...7182636_init_key_value_storage_schema.sql} | 4 +-- 2 files changed, 22 insertions(+), 16 deletions(-) rename supabase/migrations/{20240327182636_init_store_schema.sql => 20240327182636_init_key_value_storage_schema.sql} (59%) diff --git a/Tests/RealtimeTests/RealtimeIntegrationTests.swift b/Tests/RealtimeTests/RealtimeIntegrationTests.swift index 4ca7abe7..f7a81a8c 100644 --- a/Tests/RealtimeTests/RealtimeIntegrationTests.swift +++ b/Tests/RealtimeTests/RealtimeIntegrationTests.swift @@ -178,23 +178,29 @@ final class RealtimeIntegrationTests: XCTestCase { } let key = try await ( - db.from("store") + db.from("key_value_storage") .insert(["key": AnyJSON.string(UUID().uuidString), "value": "value1"]).select().single() .execute().value as Entry ).key - try await db.from("store").update(["value": "value2"]).eq("key", value: key).execute() - try await db.from("store").delete().eq("key", value: key).execute() - - let insertedEntries = try await receivedInsertActions.value.map { try $0.decodeRecord( - as: Entry.self, - decoder: JSONDecoder() - ) } - let updatedEntries = try await receivedUpdateActions.value.map { try $0.decodeRecord( - as: Entry.self, - decoder: JSONDecoder() - ) } - let deletedEntryIds = await receivedDeleteActions.value - .compactMap { $0.oldRecord["key"]?.stringValue } + try await db.from("key_value_storage").update(["value": "value2"]).eq("key", value: key) + .execute() + try await db.from("key_value_storage").delete().eq("key", value: key).execute() + + let insertedEntries = try await receivedInsertActions.value.map { + try $0.decodeRecord( + as: Entry.self, + decoder: JSONDecoder() + ) + } + let updatedEntries = try await receivedUpdateActions.value.map { + try $0.decodeRecord( + as: Entry.self, + decoder: JSONDecoder() + ) + } + let deletedEntryIds = await receivedDeleteActions.value.compactMap { + $0.oldRecord["key"]?.stringValue + } XCTAssertNoDifference(insertedEntries, [Entry(key: key, value: "value1")]) XCTAssertNoDifference(updatedEntries, [Entry(key: key, value: "value2")]) diff --git a/supabase/migrations/20240327182636_init_store_schema.sql b/supabase/migrations/20240327182636_init_key_value_storage_schema.sql similarity index 59% rename from supabase/migrations/20240327182636_init_store_schema.sql rename to supabase/migrations/20240327182636_init_key_value_storage_schema.sql index e8e239c6..80591183 100644 --- a/supabase/migrations/20240327182636_init_store_schema.sql +++ b/supabase/migrations/20240327182636_init_key_value_storage_schema.sql @@ -1,8 +1,8 @@ -create table store( +create table key_value_storage( "key" text primary key, "value" jsonb not null ); alter publication supabase_realtime - add table store; + add table key_value_storage;