批量更新功能
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
-- =============================================================
|
||||
-- Contacts: support multiple mobile numbers (a person may have several)
|
||||
-- Tables:
|
||||
-- 1) yz_backend_crm_entity_contact : contacts of clue / business / project
|
||||
-- 2) yz_backend_erp_contact : global address book contacts
|
||||
-- 3) yz_backend_contact_company : company contacts (customers/suppliers),
|
||||
-- shared by project contact picker / address book / customer-supplier
|
||||
-- conversion. This one was missed before: without the column any SELECT
|
||||
-- fails and contact lists show as empty (fixed by the server-side
|
||||
-- migration EnsureErpCompanyContactMobilesColumn on startup).
|
||||
-- All tables get a new column `mobiles` (TEXT, JSON array, max 5).
|
||||
-- The old `mobile` / `phone` column keeps the FIRST number for backward
|
||||
-- compatibility (list display, phone-based dedupe on sync), and existing
|
||||
-- single numbers are backfilled into `mobiles`.
|
||||
-- Run: mysql -h<host> -P<port> -u<user> -p <db> < alter_contact_mobiles.sql
|
||||
-- (re-running only reports "Duplicate column name", which is safe)
|
||||
-- NOTE: keep this file ASCII-only; piping through some shells mangles non-ASCII.
|
||||
-- =============================================================
|
||||
|
||||
-- 1) clue / business / project contacts
|
||||
ALTER TABLE `yz_backend_crm_entity_contact`
|
||||
ADD COLUMN `mobiles` TEXT NULL COMMENT 'phones in JSON array, max 5' AFTER `mobile`;
|
||||
|
||||
-- backfill existing single number as a one-element JSON array
|
||||
UPDATE `yz_backend_crm_entity_contact`
|
||||
SET `mobiles` = JSON_ARRAY(`mobile`)
|
||||
WHERE (`mobiles` IS NULL OR `mobiles` = '')
|
||||
AND `mobile` IS NOT NULL AND `mobile` <> '';
|
||||
|
||||
-- 2) global address book contacts
|
||||
ALTER TABLE `yz_backend_erp_contact`
|
||||
ADD COLUMN `mobiles` TEXT NULL COMMENT 'phones in JSON array, max 5' AFTER `phone`;
|
||||
|
||||
UPDATE `yz_backend_erp_contact`
|
||||
SET `mobiles` = JSON_ARRAY(`phone`)
|
||||
WHERE (`mobiles` IS NULL OR `mobiles` = '')
|
||||
AND `phone` IS NOT NULL AND `phone` <> '';
|
||||
|
||||
-- 3) company contacts (customers / suppliers) - shared by project contact
|
||||
-- picker / address book / customer-supplier conversion.
|
||||
-- NOTE: also auto-added on server startup (EnsureErpCompanyContactMobilesColumn).
|
||||
ALTER TABLE `yz_backend_contact_company`
|
||||
ADD COLUMN `mobiles` TEXT NULL COMMENT 'phones in JSON array, max 5' AFTER `phone`;
|
||||
|
||||
UPDATE `yz_backend_contact_company`
|
||||
SET `mobiles` = JSON_ARRAY(`phone`)
|
||||
WHERE (`mobiles` IS NULL OR `mobiles` = '')
|
||||
AND `phone` IS NOT NULL AND `phone` <> '';
|
||||
Reference in New Issue
Block a user