refactor(profiles): remove dead registry surface

Delete unused registry members (ProfileConnectionRegistry.insertIfAbsent /
removeAllForProfile, ProfileRegistry.reorder, ProfilesView.countFor,
ConnectionRegistry.getDefault) and their orphan tests, refreshing the stale
docs that named removeAllForProfile as the profile-delete cleanup path.

Repair the "one default per profile" join-row invariant: the connectionId FK
cascade (foreign_keys=ON) silently drops a profile's default row while its
other rows survive, leaving it defaultless. Add promoteMissingDefaults, share
a deterministic re-promotion helper with remove(), and re-promote in
removeAllForConnection.
This commit is contained in:
edde746
2026-07-02 11:41:25 +02:00
parent d193633a5d
commit 1059658515
8 changed files with 84 additions and 70 deletions
+4 -4
View File
@@ -58,10 +58,10 @@ class _AppDatabaseTestSuite {
test('ProfileConnections has no profile_id FK (virtual plex_home profiles)', () async {
// v20 dropped the profile_id FK so virtual Plex Home profiles can
// persist join rows without a parent `profiles` row. The two
// profile-delete sites (profile_detail_screen, profile_switch_screen)
// call ProfileConnectionRegistry.removeAllForProfile manually before
// deleting the profile, so the cascade isn't needed.
// persist join rows without a parent `profiles` row. Profile deletion
// instead cleans up join rows explicitly (via the teardown flow's
// removeAllProfileConnectionsAndCleanup) before deleting the profile,
// so the cascade isn't needed.
final now = DateTime.now().millisecondsSinceEpoch;
await db
.into(db.connections)