diff --git a/migrations/20260906000002_drop_legacy_share_tables.sql b/migrations/20260906000002_drop_legacy_share_tables.sql new file mode 100644 index 00000000..4cf8b9ca --- /dev/null +++ b/migrations/20260906000002_drop_legacy_share_tables.sql @@ -0,0 +1,38 @@ +-- Drop the pre-Round-3 per-domain share tables. Every reader/writer +-- was retired in the Rust cleanup landing alongside this migration: +-- +-- * `CalendarUseCase::{list_shared_calendars, share_calendar, +-- remove_calendar_sharing, get_calendar_shares}` — gone +-- * `AddressBookUseCase::{share_address_book, unshare_address_book, +-- get_address_book_shares}` — gone +-- * `CalendarRepository` / `AddressBookRepository` share methods — gone +-- * SQL bodies in `calendar_pg_repository.rs` / +-- `address_book_pg_repository.rs` that touched these tables — gone +-- +-- Data lives on in `storage.role_grants` (backfilled by +-- `20260906000001_backfill_calendar_address_book_role_grants.sql`). +-- The one-release rollback window between the backfill and this drop +-- was left implicit — no external process reads either table today. + +DROP TABLE IF EXISTS caldav.calendar_shares; +DROP TABLE IF EXISTS carddav.address_book_shares; + +-- Post-flight introspection: refuse to complete if either table is +-- still present. Guards against a name-collision resurrection by an +-- older seed file or hand-rolled restore step. +DO $$ +DECLARE + stray_count INT; +BEGIN + SELECT COUNT(*) INTO stray_count + FROM pg_class c + JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE (n.nspname = 'caldav' AND c.relname = 'calendar_shares') + OR (n.nspname = 'carddav' AND c.relname = 'address_book_shares'); + + IF stray_count > 0 THEN + RAISE EXCEPTION + 'Migration 20260906000002 finished with % legacy share table(s) still present', + stray_count; + END IF; +END $$; diff --git a/src/domain/repositories/address_book_repository.rs b/src/domain/repositories/address_book_repository.rs index f9841c11..6e86c9cb 100644 --- a/src/domain/repositories/address_book_repository.rs +++ b/src/domain/repositories/address_book_repository.rs @@ -12,9 +12,8 @@ pub type AddressBookRepositoryResult = Result; /// The pre-Round-3 methods that read/wrote `carddav.address_book_shares` /// (`get_shared_address_books`, `share_address_book`, /// `unshare_address_book`, `get_address_book_shares`) have been removed -/// from this trait. The `carddav.address_book_shares` table still -/// exists for one-release rollback safety; a follow-up migration drops -/// it. +/// from this trait, and the backing table was dropped in +/// `20260906000002_drop_legacy_share_tables.sql`. pub trait AddressBookRepository: Send + Sync + 'static { async fn create_address_book( &self, diff --git a/src/domain/repositories/calendar_repository.rs b/src/domain/repositories/calendar_repository.rs index 1216353e..8719fbdb 100644 --- a/src/domain/repositories/calendar_repository.rs +++ b/src/domain/repositories/calendar_repository.rs @@ -10,9 +10,8 @@ pub type CalendarRepositoryResult = Result; /// the pre-Round-3 methods that read/wrote `caldav.calendar_shares` /// (`list_calendars_shared_with_user`, `user_has_calendar_access`, /// `share_calendar`, `remove_calendar_sharing`, `get_calendar_shares`) -/// have been removed from this trait. The `caldav.calendar_shares` table -/// still exists for one-release rollback safety; a follow-up migration -/// drops it. +/// have been removed from this trait, and the backing table was dropped +/// in `20260906000002_drop_legacy_share_tables.sql`. pub trait CalendarRepository: Send + Sync + 'static { /// Creates a new calendar async fn create_calendar(&self, calendar: Calendar) -> CalendarRepositoryResult;