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,