diff --git a/app/plugins/builtins/mail/migrations/0009_remove_mail_soft_delete.sql b/app/plugins/builtins/mail/migrations/0009_remove_mail_soft_delete.sql index 3ec9c89..7c55640 100644 --- a/app/plugins/builtins/mail/migrations/0009_remove_mail_soft_delete.sql +++ b/app/plugins/builtins/mail/migrations/0009_remove_mail_soft_delete.sql @@ -1,4 +1,15 @@ -- Remove soft-delete (deleted_at) logic from mails -- Mails now use standard mail program logic: folder_id for Trash, permanent DELETE for Trash empty -- This migration clears all existing deleted_at values so no mails are hidden -UPDATE mails SET deleted_at = NULL; +-- Safe for fresh installs: only update if column exists +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'mails' + AND column_name = 'deleted_at' + ) THEN + UPDATE mails SET deleted_at = NULL; + END IF; +END $$;