2026-08-25 06:43:31 +02:00
|
|
|
-- Migration: Remove the legacy CVR uniqueness rule.
|
|
|
|
|
-- CVR is company metadata and multiple e-conomic customer records may
|
|
|
|
|
-- legitimately share the same value. This mirrors migration 1000 and keeps
|
|
|
|
|
-- this historical migration safe when schema detection selects it again.
|
2025-12-22 11:35:16 +01:00
|
|
|
|
|
|
|
|
-- Drop old unique constraint
|
|
|
|
|
ALTER TABLE customers DROP CONSTRAINT IF EXISTS customers_cvr_number_key;
|
|
|
|
|
|
2026-08-25 06:43:31 +02:00
|
|
|
DROP INDEX IF EXISTS customers_cvr_number_unique_idx;
|
2025-12-22 11:35:16 +01:00
|
|
|
|
2026-08-25 06:43:31 +02:00
|
|
|
CREATE INDEX IF NOT EXISTS idx_customers_cvr
|
|
|
|
|
ON customers(cvr_number)
|
|
|
|
|
WHERE cvr_number IS NOT NULL AND cvr_number <> '';
|
|
|
|
|
|
|
|
|
|
COMMENT ON COLUMN customers.cvr_number IS
|
|
|
|
|
'Danish CVR number. Informational/searchable; duplicates are allowed.';
|