# 10:36 2021/8/11
ALTER TABLE `slides`
	ADD INDEX `agent_id` (`agent_id`);
ALTER TABLE `specials`
	ADD INDEX `agent_id` (`agent_id`);
ALTER TABLE `suppliers`
	ADD UNIQUE INDEX `account` (`account`);
ALTER TABLE `orders`
	ADD INDEX `mobile` (`mobile`);

# 16:32 2021/8/11
ALTER TABLE `users`
	CHANGE COLUMN `unionid` `unionid` VARCHAR(64) NOT NULL COMMENT '微信unionid' COLLATE 'utf8mb4_unicode_ci' AFTER `agent_id`;

# 19:14 2021/8/11
ALTER TABLE `agents`
	ADD COLUMN `agent_name` VARCHAR(50) NOT NULL COMMENT '代理商名称' AFTER `password`;
ALTER TABLE `agents`
	ADD UNIQUE INDEX `account` (`account`);

ALTER TABLE `suppliers`
	ADD COLUMN `supplier_name` VARCHAR(50) NOT NULL COMMENT '供应商名称' AFTER `password`;

#11:15 2021/8/12
ALTER TABLE `suppliers`
	ADD COLUMN `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '1:启用；0:待审核；-1:审核拒绝；-2:禁用' AFTER `supplier_name`,
	ADD COLUMN `company_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '公司名称' AFTER `status`,
	ADD COLUMN `logo` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'LOGO' AFTER `company_name`,
	ADD COLUMN `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '公司地址' AFTER `logo`,
	ADD COLUMN `license_pic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '营业执照' AFTER `address`,
	ADD COLUMN `director` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '负责人' AFTER `license_pic`,
	ADD COLUMN `contact_phone` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '联系电话' AFTER `director`;

ALTER TABLE `agents`
	ADD COLUMN `company_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '公司名称' COLLATE 'utf8_general_ci' AFTER `status`,
	ADD COLUMN `logo` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'LOGO' COLLATE 'utf8_general_ci' AFTER `company_name`,
	ADD COLUMN `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '公司地址' COLLATE 'utf8_general_ci' AFTER `logo`,
	ADD COLUMN `license_pic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '营业执照' COLLATE 'utf8_general_ci' AFTER `address`,
	ADD COLUMN `director` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '负责人' COLLATE 'utf8_general_ci' AFTER `license_pic`,
	ADD COLUMN `contact_phone` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '联系电话' COLLATE 'utf8_general_ci' AFTER `director`;

ALTER TABLE `suppliers`
	ADD COLUMN `deleted_at` INT(10) UNSIGNED NULL DEFAULT NULL AFTER `updated_at`;

ALTER TABLE `agents`
	ADD COLUMN `deleted_at` INT(10) UNSIGNED NULL DEFAULT NULL AFTER `updated_at`;

ALTER TABLE `agents`
	CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '1:启用；0:待审核；-1:审核拒绝；-2:禁用' AFTER `mchkey`;

ALTER TABLE `categories`
	CHANGE COLUMN `agent_id` `agent_id` INT(10) NOT NULL DEFAULT '0' COMMENT '代理商ID，0为系统和供应商共用分类' AFTER `id`;


# 9:26 2021/8/13
ALTER TABLE `channels`
	CHANGE COLUMN `agent_id` `agent_id` INT(10) NOT NULL DEFAULT '0' COMMENT '代理商ID，0表示系统默认分类' AFTER `id`;

# 16:47 2021/8/13
CREATE TABLE `guides` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`account` VARCHAR(50) NOT NULL COMMENT '账号' COLLATE 'utf8_general_ci',
	`password` CHAR(32) NOT NULL COMMENT '密码' COLLATE 'utf8_general_ci',
	`guide_name` VARCHAR(50) NOT NULL COMMENT '地接名称' COLLATE 'utf8_general_ci',
	`photo` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '形象照' COLLATE 'utf8_general_ci',
	`license_pic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '地接资格证件' COLLATE 'utf8_general_ci',
	`contact_phone` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '联系电话' COLLATE 'utf8_general_ci',
	`status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '1:启用；0:待审核；-1:审核拒绝；-2:禁用',
	`created_at` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`updated_at` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`deleted_at` INT(10) UNSIGNED NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	UNIQUE INDEX `account` (`account`) USING BTREE
)
COMMENT='地接'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

#################################################################

# 18:30 ‎2021/‎08/‎15
ALTER TABLE `agents`
	CHANGE COLUMN `account` `username` VARCHAR(120) NOT NULL COMMENT '账号' COLLATE 'utf8_general_ci' AFTER `id`,
	CHANGE COLUMN `password` `password` VARCHAR(80) NOT NULL COMMENT '密码' COLLATE 'utf8_general_ci' AFTER `username`,
	CHANGE COLUMN `agent_name` `name` VARCHAR(255) NOT NULL COMMENT '代理商名称' COLLATE 'utf8_general_ci' AFTER `password`,
	ADD COLUMN `avatar` VARCHAR(255) NULL DEFAULT NULL COMMENT '头像' COLLATE 'utf8_general_ci' AFTER `name`,
	DROP INDEX `account`,
	ADD UNIQUE INDEX `account` (`username`) USING BTREE;

ALTER TABLE `suppliers`
	CHANGE COLUMN `account` `username` VARCHAR(120) NOT NULL COMMENT '账号' COLLATE 'utf8_general_ci' AFTER `id`,
	CHANGE COLUMN `password` `password` VARCHAR(80) NOT NULL COMMENT '密码' COLLATE 'utf8_general_ci' AFTER `username`,
	CHANGE COLUMN `supplier_name` `name` VARCHAR(50) NOT NULL COMMENT '供应商名称' COLLATE 'utf8_general_ci' AFTER `password`,
	ADD COLUMN `avatar` VARCHAR(255) NULL DEFAULT NULL COMMENT '头像' COLLATE 'utf8_general_ci' AFTER `name`,
	DROP INDEX `account`,
	ADD UNIQUE INDEX `account` (`username`) USING BTREE;

ALTER TABLE `guides`
	CHANGE COLUMN `account` `username` VARCHAR(120) NOT NULL COMMENT '账号' COLLATE 'utf8_general_ci' AFTER `id`,
	CHANGE COLUMN `password` `password` VARCHAR(80) NOT NULL COMMENT '密码' COLLATE 'utf8_general_ci' AFTER `username`,
	CHANGE COLUMN `guide_name` `name` VARCHAR(50) NOT NULL COMMENT '供应商名称' COLLATE 'utf8_general_ci' AFTER `password`,
	ADD COLUMN `avatar` VARCHAR(255) NULL DEFAULT NULL COMMENT '头像' COLLATE 'utf8_general_ci' AFTER `name`,
	DROP INDEX `account`,
	ADD UNIQUE INDEX `account` (`username`) USING BTREE;

# 19:51 ‎2021/‎08/‎15 --created_at--
ALTER TABLE `user_money_logs`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `user_money_logs` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `user_money_logs`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `user_favs`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `user_favs` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `user_favs`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `users`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `users` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `users`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `suppliers`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `suppliers` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `suppliers`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `specials`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `specials` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `specials`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `slides`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `slides` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `slides`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `products`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `products` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `products`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `orders`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `orders` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `orders`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `notices`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `notices` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `notices`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `messages`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `messages` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `messages`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `guides`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `guides` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `guides`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `coupons`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `coupons` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `coupons`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `articles`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `articles` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `articles`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `agent_products`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `agent_products` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `agent_products`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `agents`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `agents` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `agents`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE `advertisings`
	CHANGE COLUMN `created_at` `created_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `advertisings` SET `created_at` = FROM_UNIXTIME(`created_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `advertisings`
	CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;

# 23:39 ‎2021/‎08/‎15 --updated_at--
ALTER TABLE `advertisings`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `advertisings` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `advertisings`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `agents`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `agents` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `agents`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `agent_products`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `agent_products` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `agent_products`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `articles`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `articles` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `articles`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `coupons`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `coupons` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `coupons`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `guides`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `guides` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `guides`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `messages`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `messages` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `messages`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `notices`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `notices` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `notices`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `orders`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `orders` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `orders`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `products`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `products` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `products`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `slides`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `slides` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `slides`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `specials`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `specials` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `specials`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `suppliers`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `suppliers` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `suppliers`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `users`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `users` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `users`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `user_favs`
	CHANGE COLUMN `updated_at` `updated_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `user_favs` SET `updated_at` = FROM_UNIXTIME(`updated_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `user_favs`
	CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT NULL;



# 0:00 ‎2021/‎08/‎16
ALTER TABLE `suppliers`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `products`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `orders`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `orders`
	CHANGE COLUMN `paid_at` `paid_at` VARCHAR(50) NULL DEFAULT NULL;
UPDATE `orders` SET `paid_at` = FROM_UNIXTIME(`paid_at`, '%Y-%m-%d %H:%i:%s');
ALTER TABLE `orders`
	CHANGE COLUMN `paid_at` `paid_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `messages`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `guides`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `channels`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `categories`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `articles`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;

ALTER TABLE `agent_products`
	ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `updated_at`;

ALTER TABLE `agents`
	CHANGE COLUMN `deleted_at` `deleted_at` TIMESTAMP NULL DEFAULT NULL;






