this repo has no description

appview/db: remove foreign key constraint between collections

Appview cannot modify the user-owned record on repository deletion

Signed-off-by: Seongmin Lee <git@boltless.me>

boltless.me 4a8bce5d d2b09d54

verified
+23
+23
appview/db/db.go
··· 1181 1181 return err 1182 1182 }) 1183 1183 1184 + // we cannot modify user-owned record on repository delete 1185 + orm.RunMigration(conn, logger, "remove-foreign-key-profile_pinned_repositories-and-repos", func(tx *sql.Tx) error { 1186 + _, err := tx.Exec(` 1187 + create table profile_pinned_repositories_new ( 1188 + did text not null, 1189 + 1190 + -- data 1191 + at_uri text not null, 1192 + 1193 + -- constraints 1194 + unique(did, at_uri), 1195 + foreign key (did) references profile(did) on delete cascade 1196 + ); 1197 + 1198 + insert into profile_pinned_repositories_new (did, at_uri) 1199 + select did, at_uri from profile_pinned_repositories; 1200 + 1201 + drop table profile_pinned_repositories; 1202 + alter table profile_pinned_repositories_new rename to profile_pinned_repositories; 1203 + `) 1204 + return err 1205 + }) 1206 + 1184 1207 return &DB{ 1185 1208 db, 1186 1209 logger,