From d8bb97877b3868800f77798959be2169a0c781db Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 16 Jan 2026 19:41:29 +0900 Subject: [PATCH] appview/db: remove foreign key constraint between collections Appview cannot modify the user-owned record on repository deletion Signed-off-by: Seongmin Lee --- appview/db/db.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/appview/db/db.go b/appview/db/db.go index daa31633..5b50a306 100644 --- a/appview/db/db.go +++ b/appview/db/db.go @@ -1287,6 +1287,29 @@ func Make(ctx context.Context, dbPath string) (*DB, error) { return err }) + // we cannot modify user-owned record on repository delete + orm.RunMigration(conn, logger, "remove-foreign-key-profile_pinned_repositories-and-repos", func(tx *sql.Tx) error { + _, err := tx.Exec(` + create table profile_pinned_repositories_new ( + did text not null, + + -- data + at_uri text not null, + + -- constraints + unique(did, at_uri), + foreign key (did) references profile(did) on delete cascade + ); + + insert into profile_pinned_repositories_new (did, at_uri) + select did, at_uri from profile_pinned_repositories; + + drop table profile_pinned_repositories; + alter table profile_pinned_repositories_new rename to profile_pinned_repositories; + `) + return err + }) + return &DB{ db, logger, -- 2.51.2