mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 09:19:51 +00:00
The pre-017 signup trigger (001) inserted the profiles row inside an `EXCEPTION WHEN OTHERS ... RAISE WARNING; RETURN NEW` block, so a signup could leave an auth.users row with no matching profiles row. The 017 account-sharing backfill keyed accounts off `profiles`, so such an orphaned user got no account and was never linked. If that user owned any domain rows (pre-017 RLS only required `auth.uid() = user_id`, not a profile), their account_id stayed NULL and the subsequent `ALTER TABLE ... SET NOT NULL` aborted the whole migration — exactly the upgrade failure reported in #274. Add a step (0) to the backfill DO block that creates the missing profile for every auth.users row lacking one, before accounts are created. This keys the backfill off auth.users instead of profiles, so every authenticated user is migrated and no domain row can be left without an account. Idempotent and safe to re-run, matching the rest of 017. Fixes #274 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| 001_initial_schema.sql | ||
| 002_pipelines_enhancements.sql | ||
| 003_broadcast_recipient_wamid.sql | ||
| 004_contact_delete_set_null.sql | ||
| 005_broadcast_counts_incremental.sql | ||
| 006_automations.sql | ||
| 007_automations_increment_counter.sql | ||
| 008_profile_avatars_storage.sql | ||
| 009_message_actions.sql | ||
| 010_flows.sql | ||
| 011_profile_beta_features.sql | ||
| 012_flows_increment_counter.sql | ||
| 013_whatsapp_config_phone_number_id_unique.sql | ||
| 014_message_templates_meta_integration.sql | ||
| 015_whatsapp_config_registration.sql | ||
| 016_flow_media.sql | ||
| 017_account_sharing.sql | ||
| 018_account_member_rpcs.sql | ||
| 019_invitation_rpcs.sql | ||
| 020_account_sharing_followups.sql | ||
| 021_account_default_currency.sql | ||
| 022_contact_phone_dedup.sql | ||
| 023_chat_media.sql | ||