From 45bc4342c5c8b52c0b93e401b09bd3e50b85fe30 Mon Sep 17 00:00:00 2001 From: Denys Adamenko Date: Tue, 27 Aug 2024 15:06:11 -0700 Subject: [PATCH] fix: Fix old migrations for Keto 0.8, column nit is not exists in table network --- .../migrations/sql/20220217152313000000_nid_fk.sqlite.up.sql | 2 +- .../sql/migrations/sql/20220217152313000000_nid_fk.up.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.sqlite.up.sql b/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.sqlite.up.sql index c864d2287..4b8bf3d34 100644 --- a/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.sqlite.up.sql +++ b/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.sqlite.up.sql @@ -1,6 +1,6 @@ -- These tuples can't be retrieved over any API (and also not inserted by any API) because we always add a `WHERE nid = ?` clause to the queries. -- This DELETE statement is here to ensure that we don't run into problems where the `nid` column is not properly set. Should not happen if only the official API is used. -DELETE FROM keto_relation_tuples WHERE nid NOT IN (SELECT nid FROM networks); +DELETE FROM keto_relation_tuples WHERE nid NOT IN (SELECT id FROM networks); CREATE TABLE keto_relation_tuples_with_fk ( diff --git a/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.up.sql b/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.up.sql index 828c6378b..dfb5f9e21 100644 --- a/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.up.sql +++ b/internal/persistence/sql/migrations/sql/20220217152313000000_nid_fk.up.sql @@ -1,6 +1,6 @@ -- These tuples can't be retrieved over any API (and also not inserted by any API) because we always add a `WHERE nid = ?` clause to the queries. -- This DELETE statement is here to ensure that we don't run into problems where the `nid` column is not properly set. Should not happen if only the official API is used. -DELETE FROM keto_relation_tuples WHERE nid NOT IN (SELECT nid FROM networks); +DELETE FROM keto_relation_tuples WHERE nid NOT IN (SELECT id FROM networks); ALTER TABLE keto_relation_tuples ADD CONSTRAINT keto_relation_tuples_nid_fk