| 123456789101112131415161718192021222324252627282930313233 |
- -- 库存流水记下装货/送货产品明细,同一产品的多段归档各自保留一条流水。
- -- MySQL 5.7 / utf8mb4。可重复执行。已有流水的两个字段为空,不改数量和金额。
- SET NAMES utf8mb4;
- SET @col_exists = (
- SELECT COUNT(*) FROM information_schema.COLUMNS
- WHERE TABLE_SCHEMA = DATABASE()
- AND TABLE_NAME = 'pl_inventory_transaction'
- AND COLUMN_NAME = 'stop_type'
- );
- SET @ddl = IF(
- @col_exists = 0,
- 'ALTER TABLE `pl_inventory_transaction` ADD COLUMN `stop_type` varchar(20) NOT NULL DEFAULT '''' COMMENT ''来源段类型:load装货 delivery送货,按产品归档为空'' AFTER `plan_no`',
- 'SELECT 1'
- );
- PREPARE stmt FROM @ddl;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
- SET @col_exists = (
- SELECT COUNT(*) FROM information_schema.COLUMNS
- WHERE TABLE_SCHEMA = DATABASE()
- AND TABLE_NAME = 'pl_inventory_transaction'
- AND COLUMN_NAME = 'stop_product_id'
- );
- SET @ddl = IF(
- @col_exists = 0,
- 'ALTER TABLE `pl_inventory_transaction` ADD COLUMN `stop_product_id` varchar(64) NOT NULL DEFAULT '''' COMMENT ''装货或送货产品明细ID,按产品归档为空'' AFTER `stop_type`',
- 'SELECT 1'
- );
- PREPARE stmt FROM @ddl;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
|