同市客户在运输计划装货、卸货段自动带出同市,同市运输只要求购买证。 Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
725 B
SQL
19 lines
725 B
SQL
-- 客户主数据增加「是否同市」,运输计划装/送段选客户时默认带入段次勾选。
|
|
-- MySQL 5.7。可重复执行。存量客户默认 0。
|
|
SET NAMES utf8mb4;
|
|
|
|
SET @schema_name = DATABASE();
|
|
|
|
SET @col_exists = (
|
|
SELECT COUNT(*) FROM information_schema.COLUMNS
|
|
WHERE TABLE_SCHEMA = @schema_name AND TABLE_NAME = 'crm_customer' AND COLUMN_NAME = 'same_city'
|
|
);
|
|
SET @alter_sql = IF(
|
|
@col_exists = 0,
|
|
'ALTER TABLE crm_customer ADD COLUMN same_city tinyint NOT NULL DEFAULT 0 COMMENT ''是否同市 0-否 1-是;相对本公司业务所在市,运输计划段次默认带入'' AFTER address',
|
|
'SELECT 1'
|
|
);
|
|
PREPARE alter_stmt FROM @alter_sql;
|
|
EXECUTE alter_stmt;
|
|
DEALLOCATE PREPARE alter_stmt;
|