USE tmerclub_auth;

# 修改平台发货地址菜单 651为发货管理菜单
update menu set parent_id = 651, component = 'system/delivery-manager/addr/index', seq = 2 where menu_id = 650 and name = '发货地址';

# 订单发票新增供应商id字段
USE tmerclub_order_0;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_1;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_2;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_3;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_4;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_5;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_6;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;

USE tmerclub_order_7;
DELIMITER //
DROP PROCEDURE IF EXISTS updateInvoiceColumn //
CREATE PROCEDURE updateInvoiceColumn()
BEGIN
    DECLARE i INT;
    SET i = 0;
    WHILE i < 64 DO
        SET @add_column = CONCAT( 'ALTER TABLE order_invoice_', i, " ADD COLUMN `supplier_id` bigint(0) NULL COMMENT '供应商id' AFTER `shop_id`" );
        PREPARE add_column FROM @add_column;
        EXECUTE add_column;
        SET i = i + 1;
    END WHILE;
END //
CALL updateInvoiceColumn() //
DROP PROCEDURE updateInvoiceColumn //
DELIMITER;