Monorepo for Tangled tangled.org

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 4b3e7e17 7c16f6f4

verified
+23
+23
appview/db/db.go
··· 1255 1255 return err 1256 1256 }) 1257 1257 1258 + // we cannot modify user-owned record on repository delete 1259 + orm.RunMigration(conn, logger, "remove-foreign-key-profile_pinned_repositories-and-repos", func(tx *sql.Tx) error { 1260 + _, err := tx.Exec(` 1261 + create table profile_pinned_repositories_new ( 1262 + did text not null, 1263 + 1264 + -- data 1265 + at_uri text not null, 1266 + 1267 + -- constraints 1268 + unique(did, at_uri), 1269 + foreign key (did) references profile(did) on delete cascade 1270 + ); 1271 + 1272 + insert into profile_pinned_repositories_new (did, at_uri) 1273 + select did, at_uri from profile_pinned_repositories; 1274 + 1275 + drop table profile_pinned_repositories; 1276 + alter table profile_pinned_repositories_new rename to profile_pinned_repositories; 1277 + `) 1278 + return err 1279 + }) 1280 + 1258 1281 return &DB{ 1259 1282 db, 1260 1283 logger,