feat(calendar,addressbook): remove share tables

This commit is contained in:
Edouard Vanbelle
2026-07-06 08:54:41 +02:00
parent 0e341758af
commit 28108fe8b2
3 changed files with 42 additions and 6 deletions
@@ -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 $$;
@@ -12,9 +12,8 @@ pub type AddressBookRepositoryResult<T> = Result<T, DomainError>;
/// 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,
@@ -10,9 +10,8 @@ pub type CalendarRepositoryResult<T> = Result<T, DomainError>;
/// 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<Calendar>;