Showing
1 changed file
with
315 additions
and
0 deletions
inferface-document/Database-upgrad.md
0 → 100644
1 | +# 数据库变更 | ||
2 | +--------------------- | ||
3 | + | ||
4 | + | ||
5 | +1.数据库(erp_supplier) | ||
6 | +1.1 店铺管理员(erp_supplier.shops_admin) | ||
7 | +操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。 | ||
8 | +sql 脚本: | ||
9 | +ALTER TABLE shops_admin ADD `status` TINYINT not null default 1 COMMENT '1、正常 2、已删除'; | ||
10 | +1.2 店铺审核(erp_supplier.shops_check) | ||
11 | +操作说明:新增店铺审核erp_supplier.shops_check数据表。 | ||
12 | +sql 脚本: | ||
13 | +CREATE TABLE `shops_check` ( | ||
14 | + `shops_id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
15 | + `shop_name` varchar(100) NOT NULL, | ||
16 | + `shop_domain` varchar(50) NOT NULL, | ||
17 | + `shop_relation` varchar(5000) DEFAULT NULL, | ||
18 | + `shop_nature` tinyint(4) unsigned NOT NULL DEFAULT '0', | ||
19 | + `shop_logo` varchar(200) DEFAULT NULL, | ||
20 | + `shop_intro` varchar(5000) DEFAULT NULL, | ||
21 | + `website_url` varchar(500) NOT NULL, | ||
22 | + `other_url` varchar(500) DEFAULT NULL, | ||
23 | + `shop_address` varchar(1000) DEFAULT NULL, | ||
24 | + `create_pid` int(11) unsigned DEFAULT '0', | ||
25 | + `shops_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1、单品店,2、多品店', | ||
26 | + `operation_status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '1 店铺未创建 2店铺已创建', | ||
27 | + `examine_status` tinyint(4) unsigned NOT NULL DEFAULT '0', | ||
28 | + `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1 开启 0 关闭', | ||
29 | + `check_status` smallint(6) DEFAULT NULL COMMENT '100 暂存 200 待审核 300 审核通过 900 驳回', | ||
30 | + `is_read` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1 未处理 2 已处理', | ||
31 | + `create_time` int(10) unsigned NOT NULL DEFAULT '0', | ||
32 | + `update_time` int(10) unsigned NOT NULL DEFAULT '0', | ||
33 | + PRIMARY KEY (`shops_id`) | ||
34 | +) ENGINE=InnoDB AUTO_INCREMENT=433 DEFAULT CHARSET=utf8; | ||
35 | +1.3 供应商(erp_supplier.supplier) | ||
36 | +sql 脚本: | ||
37 | +ALTER TABLE `supplier` | ||
38 | +ADD COLUMN `account_opening_license` varchar(200) NOT NULL DEFAULT '' COMMENT '开户许可证' AFTER `contact_address`, | ||
39 | +ADD COLUMN `taxpayer_qualification_certificate` varchar(200) NULL COMMENT '纳税人资格证明' AFTER `account_opening_license`, | ||
40 | +ADD COLUMN `industry_license` varchar(200) NULL COMMENT '行业许可证' AFTER `taxpayer_qualification_certificate`; | ||
41 | + | ||
42 | +CREATE TABLE `supplier_check` ( | ||
43 | + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', | ||
44 | + `supplier_code` varchar(100) DEFAULT NULL COMMENT '供应商编号', | ||
45 | + `supplier_name` varchar(200) DEFAULT NULL COMMENT '供应商名称', | ||
46 | + `business_license` varchar(255) DEFAULT NULL COMMENT '经营许可证->组织机构代码证', | ||
47 | + `legal_person` varchar(10) DEFAULT NULL COMMENT '法人姓名', | ||
48 | + `linkman` varchar(10) DEFAULT NULL COMMENT '联系人姓名', | ||
49 | + `phone` varchar(20) DEFAULT NULL COMMENT '联系电话', | ||
50 | + `fax` varchar(20) DEFAULT NULL COMMENT '传真', | ||
51 | + `email` varchar(50) DEFAULT NULL COMMENT '邮箱', | ||
52 | + `url` varchar(100) DEFAULT NULL COMMENT '网址', | ||
53 | + `tax_certificate` varchar(255) DEFAULT '' COMMENT '税务登记证', | ||
54 | + `bank_name` varchar(100) DEFAULT NULL COMMENT '开户行', | ||
55 | + `bank_account` varchar(100) DEFAULT NULL COMMENT '开户账号', | ||
56 | + `category` tinyint(4) DEFAULT '1' COMMENT '1、普通供应商\n 2、特约供应商', | ||
57 | + `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', | ||
58 | + `update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间', | ||
59 | + `static` tinyint(4) DEFAULT '1', | ||
60 | + `is_lock` int(11) DEFAULT '1', | ||
61 | + `found_time` date DEFAULT NULL COMMENT '成立时间', | ||
62 | + `begin_operate_time` date DEFAULT NULL COMMENT '经营开始时间', | ||
63 | + `end_operate_time` date DEFAULT NULL COMMENT '经营结束时间', | ||
64 | + `is_freeze` enum('Y','N') DEFAULT 'N' COMMENT '是否冻结', | ||
65 | + `status` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '100暂存,200审核中,300通过,900驳回', | ||
66 | + `operations` int(10) DEFAULT NULL COMMENT '1 创建 2 编辑 3 冻结 4 解冻', | ||
67 | + `registered_address` varchar(255) NOT NULL DEFAULT '' COMMENT '公司注册地址', | ||
68 | + `registered_capital` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '注册资本', | ||
69 | + `business_license_pic` varchar(200) NOT NULL DEFAULT '' COMMENT '经营许可证图片->组织机构代码证图片', | ||
70 | + `business_range` varchar(500) NOT NULL DEFAULT '' COMMENT '经营范围', | ||
71 | + `legal_identity_card` varchar(200) NOT NULL DEFAULT '' COMMENT '法人身份证电子版', | ||
72 | + `create_pid` int(11) unsigned DEFAULT '0' COMMENT '创建人', | ||
73 | + `contact_phone` varchar(50) NOT NULL DEFAULT '' COMMENT '公司联系电话', | ||
74 | + `contact_address` varchar(255) NOT NULL DEFAULT '' COMMENT '公司联系地址', | ||
75 | + `account_opening_license` varchar(200) NOT NULL DEFAULT '' COMMENT '开户许可证', | ||
76 | + `taxpayer_qualification_certificate` varchar(200) DEFAULT NULL COMMENT '纳税人资格证明', | ||
77 | + `industry_license` varchar(200) DEFAULT NULL COMMENT '行业许可证', | ||
78 | + PRIMARY KEY (`id`) | ||
79 | +) ENGINE=InnoDB AUTO_INCREMENT=1359 DEFAULT CHARSET=utf8; | ||
80 | +insert into supplier_check select * from supplier; | ||
81 | + | ||
82 | +2.数据库(yhb_operations) | ||
83 | +1.1 帮助分类(yhb_operations.help_category) | ||
84 | +操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。 | ||
85 | +sql 脚本: | ||
86 | +ALTER TABLE yhb_operations.help_category ADD `status` TINYINT not null default 1 COMMENT '1、正常 2、已删除'; | ||
87 | +1.2 帮助内容(yhb_operations.help_content) | ||
88 | +操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。 | ||
89 | +sql 脚本: | ||
90 | +ALTER TABLE yhb_operations.help_content ADD `status` TINYINT not null default 1 COMMENT '1、正常 2、已删除'; | ||
91 | +3.数据库(erp_product) | ||
92 | +1.1表(erp_product.standard) | ||
93 | +sql 脚本: | ||
94 | +ALTER TABLE `erp_product`.`standard` ADD KEY key_sort_id(sort_id); | ||
95 | +ALTER TABLE `product_material` CHANGE max_sort_id product_max_sort_id INT(11) UNSIGNED; | ||
96 | +UPDATE standard SET standard_sort_id = NULL; | ||
97 | +ALTER TABLE `erp_product`.`standard` DROP COLUMN `standard_sort_id`; | ||
98 | + | ||
99 | +1.2表(erp_product.product_material) | ||
100 | +sql 脚本: | ||
101 | +ALTER TABLE `product_material` CHANGE max_sort_id product_max_sort_id INT(11) UNSIGNED; | ||
102 | + | ||
103 | + | ||
104 | +1.3表(erp_product. brand_series) | ||
105 | +sql 脚本: | ||
106 | +USE erp_product; | ||
107 | +-- add column | ||
108 | +ALTER TABLE `brand_series` ADD shops_id INT(11) UNSIGNED; | ||
109 | +ALTER TABLE `brand_series` MODIFY shops_id INT(11) NOT NULL COMMENT '店铺id'; | ||
110 | +ALTER TABLE `brand_series` ADD TYPE SMALLINT(6) UNSIGNED COMMENT '类型'; | ||
111 | +ALTER TABLE `brand_series` ADD TYPE SMALLINT(6) UNSIGNED COMMENT '类型'; | ||
112 | + -- add key | ||
113 | +ALTER TABLE `brand_series` ADD KEY key_shops_id (shops_id); | ||
114 | +ALTER TABLE `brand_series` ADD KEY key_brand_id (brand_id); | ||
115 | +-- set null | ||
116 | +ALTER TABLE brand_series CHANGE parent_id parent_id INT(11) UNSIGNED NULL; | ||
117 | +ALTER TABLE brand_series CHANGE order_by order_by SMALLINT(6) NULL; | ||
118 | +1.4表(erp_product.product_special_attr ) | ||
119 | +sql 脚本: | ||
120 | + | ||
121 | +CREATE TABLE `product_special_attr` ( | ||
122 | + `product_id` INT(11) UNSIGNED , | ||
123 | + `size_standard` TINYINT(4) DEFAULT NULL, | ||
124 | + `wear_sense` VARCHAR(250) DEFAULT NULL, | ||
125 | + `wash_tips` VARCHAR(50) DEFAULT NULL, | ||
126 | + `product_material` VARCHAR(100) DEFAULT '', | ||
127 | + `product_skn` INT(11) UNSIGNED NOT NULL, | ||
128 | + PRIMARY KEY (`product_skn`) | ||
129 | +) ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
130 | +ALTER TABLE `product_special_attr` ADD UNIQUE (`product_id`); | ||
131 | + | ||
132 | + | ||
133 | +1.5数据库迁移 | ||
134 | +(yh_shops ,erp_product) | ||
135 | +把 yh_shops数据库中表size_relations,standard,product_material,product_collocation | ||
136 | + 迁移到erp_product数据库中对应表。 | ||
137 | + | ||
138 | + | ||
139 | +yh_shops: | ||
140 | +ALTER TABLE product_standard_relation ADD COLUMN product_skn INT(11) | ||
141 | + | ||
142 | + | ||
143 | +4.数据库(erp_product) | ||
144 | +1.1表(erp_product.product) | ||
145 | +sql 脚本: | ||
146 | +alter table product add column is_screen enum('Y', 'N') default 'N' COMMENT '是否已拍摄标识'; | ||
147 | +alter table product add column is_measure enum('Y', 'N') default 'N' COMMENT '是否已测量标识'; | ||
148 | +alter table product add column status smallint default -1 COMMENT '初始状态-1, 待上架审核状态2 审核通过1 审核驳回 3 下架状态0'; | ||
149 | +alter table product add column first_shelve_time int(10) unsigned DEFAULT '0' COMMENT '首次上架时间'; | ||
150 | +alter table product add column shelve_time int(10) unsigned DEFAULT '0' COMMENT '上架时间可作为上新参考'; | ||
151 | +alter table product add column shelve_time int(10) unsigned DEFAULT '0' COMMENT '上架时间可作为上新参考'; | ||
152 | +alter table product add column `stock` smallint(6) DEFAULT 0 COMMENT '库存'; | ||
153 | +-- 为价格表增加是否已同步前台的字段 | ||
154 | +alter table product_price add column sys_status smallint default 1 COMMENT '未同步0, 已同步或者无需同步1'; | ||
155 | + | ||
156 | +--回滚脚本 | ||
157 | + | ||
158 | +--alter table product drop column is_screen; | ||
159 | +--alter table product drop column is_measure; | ||
160 | +--alter table product drop column status; | ||
161 | +--alter table product drop column stock; | ||
162 | +---- alter table product_price drop column sys_status; | ||
163 | + | ||
164 | +--新增表商品的扩展属性表 erp_product表 | ||
165 | +DROP TABLE IF EXISTS `product_ext`; | ||
166 | +create table product_ext( | ||
167 | + product_skn int COMMENT '商品erp标识', | ||
168 | + product_desc text COMMENT '描述', | ||
169 | + recommend text COMMENT '小编推荐', | ||
170 | + is_hostsell enum('Y', 'N') default 'N' COMMENT '是否热销 Y:是N:否', | ||
171 | + sales_phrase varchar(100) COMMENT '促销短语', | ||
172 | + is_new enum('Y', 'N') default 'N' COMMENT '是否新品 Y:是N:否', | ||
173 | + shelves_day int COMMENT '售罄后几天后下架', | ||
174 | + sell_channels set('0','1','2','3','4','5','6','7','8','9') COMMENT '上架渠道', | ||
175 | + phrase varchar(500) COMMENT '商品短评', | ||
176 | + search_keys varchar(500) COMMENT '搜索关键词 以英文逗号分隔', | ||
177 | + vedio_url varchar(100) COMMENT '视频链接', | ||
178 | + make_crafts varchar(50) COMMENT '制作工艺', | ||
179 | + brand_series varchar(50) COMMENT '品牌系列', | ||
180 | + brand_model varchar(50) COMMENT '品牌款型', | ||
181 | + reject_reason varchar(500) COMMENT '驳回原因' | ||
182 | +)ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
183 | +Alter table product_ext add primary key(product_skn); | ||
184 | + | ||
185 | + | ||
186 | +create table product_shop_relation( | ||
187 | + product_skn int COMMENT 'SKN', | ||
188 | + shop_id int COMMENT '店铺Id' | ||
189 | +) | ||
190 | +Alter table product_shop_relation add primary key(product_skn, shop_id); | ||
191 | + | ||
192 | +-- 排序的表结构 | ||
193 | +DROP TABLE IF EXISTS `product_search`; | ||
194 | +CREATE TABLE `product_search` ( | ||
195 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
196 | + `product_skn` int(11) unsigned NOT NULL DEFAULT '0', | ||
197 | + | ||
198 | + `model_id` smallint(6) NOT NULL DEFAULT '0', | ||
199 | + `project_id` smallint(6) NOT NULL DEFAULT '0', | ||
200 | + `int_value` int(11) unsigned NOT NULL DEFAULT '0', | ||
201 | + `string_value` varchar(100) DEFAULT NULL, | ||
202 | + `create_time` int(10) unsigned NOT NULL DEFAULT '0', | ||
203 | + PRIMARY KEY (`id`), | ||
204 | + KEY `project_id` (`project_id`), | ||
205 | + KEY `product_skn` (`product_skn`), | ||
206 | + KEY `product_skn_model_project_id` (`product_skn`,`model_id`,`project_id`) | ||
207 | +) ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
208 | + | ||
209 | +-- 商品搭配 | ||
210 | +DROP TABLE IF EXISTS `product_collocation`; | ||
211 | +CREATE TABLE `product_collocation` ( | ||
212 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
213 | + `product_skn` int(11) unsigned NOT NULL DEFAULT '0', | ||
214 | + `image_url` varchar(255) DEFAULT NULL, | ||
215 | + `info` text, | ||
216 | + `content` varchar(255) DEFAULT NULL, | ||
217 | + `order_by` tinyint(4) NOT NULL DEFAULT '0', | ||
218 | + `create_time` int(10) unsigned NOT NULL DEFAULT '0', | ||
219 | + PRIMARY KEY (`id`), | ||
220 | + KEY `product_skn` (`product_skn`) | ||
221 | +) ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
222 | + | ||
223 | +-- 商品相关图片 封面图片 | ||
224 | +DROP TABLE IF EXISTS `goods_images`; | ||
225 | +CREATE TABLE `goods_images` ( | ||
226 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
227 | + `product_skc` int(11) unsigned NOT NULL DEFAULT '0', | ||
228 | + `product_skn` int(11) unsigned NOT NULL DEFAULT '0', | ||
229 | + `is_default` enum('Y','N') NOT NULL DEFAULT 'N', | ||
230 | + `image_name` varchar(50) DEFAULT NULL, | ||
231 | + `image_url` varchar(255) DEFAULT NULL, | ||
232 | + `angle` tinyint(4) NOT NULL DEFAULT '0', | ||
233 | + `order_by` tinyint(4) NOT NULL DEFAULT '0', | ||
234 | + `intro` varchar(255) DEFAULT NULL, | ||
235 | + `status` tinyint(4) NOT NULL DEFAULT '1', | ||
236 | + `gender_cover` tinyint(4) unsigned DEFAULT '0', | ||
237 | + PRIMARY KEY (`id`), | ||
238 | + KEY `product_skn` (`product_skn`,`is_default`,`status`), | ||
239 | + KEY `product_skc` (`product_skc`,`is_default`,`status`), | ||
240 | + KEY `goods_id_2` (`product_skc`,`product_skn`) | ||
241 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品相关图片'; | ||
242 | + | ||
243 | + | ||
244 | +-- SKU单独上下架 | ||
245 | +Alter table erp_product.storage ADD column `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0下架 1 上架'; | ||
246 | + | ||
247 | +-- skc上下架状态 | ||
248 | +Alter table erp_product.goods ADD column `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0下架 1 上架'; | ||
249 | + | ||
250 | +-- skn上下架状态 上架更新或者不上新需要更新 status first_shelve_time(如果没有值更新,有值无需更新) 上架上新 shelve_time 需要更新(不管有没有值) | ||
251 | +Alter table erp_product.product ADD column `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0下架 1 上架'; | ||
252 | + | ||
253 | +-- 预上架上新记录表 | ||
254 | +DROP TABLE IF EXISTS `product_timing`; | ||
255 | +CREATE TABLE `product_timing` ( | ||
256 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
257 | + `product_skn` int(11) unsigned NOT NULL, | ||
258 | + `shelve_time` int(10) unsigned COMMENT '预上架时间', | ||
259 | + `on_new_time` int(10) unsigned COMMENT '预上架上新时间', | ||
260 | + `out_sale_time` int(10) unsigned COMMENT '预下架时间', | ||
261 | + `advance_begin_time` int(10) unsigned COMMENT '预售开始时间', | ||
262 | + `advance_end_time` int(10) unsigned COMMENT '预售结束时间', | ||
263 | + `flag` tinyint(4) NOT NULL DEFAULT '0', | ||
264 | + `create_time` int(10) unsigned NOT NULL, | ||
265 | + PRIMARY KEY (`id`), | ||
266 | + KEY `product_skn` (`product_skn`), | ||
267 | + KEY `create_time` (`create_time`) | ||
268 | +) ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
269 | + | ||
270 | +-- 网销信息缺失类型的全量枚举表 | ||
271 | +DROP TABLE IF EXISTS `netsale_infomiss`; | ||
272 | +CREATE TABLE netsale_infomiss ( | ||
273 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
274 | + `name` varchar(100) DEFAULT NULL, | ||
275 | + PRIMARY KEY (`id`) | ||
276 | +) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '网销信息缺失类型的全量枚举表'; | ||
277 | + | ||
278 | +insert into netsale_infomiss (name) values('文本信息'),('尺码信息'),('搜索/标签'); | ||
279 | + | ||
280 | +-- 商品和网销信息缺失表的关联关系表 | ||
281 | +DROP TABLE IF EXISTS `netsale_infomiss_relation`; | ||
282 | +CREATE TABLE netsale_infomiss_relation ( | ||
283 | + `product_skn` int(11) unsigned NOT NULL, | ||
284 | + `infomiss_id` int(11) unsigned NOT NULL COMMENT 'netsale_infomiss_sort 的主键', | ||
285 | + PRIMARY KEY (`product_skn`, infomiss_id) | ||
286 | +) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '网销信息缺失类型和商品的关系表'; | ||
287 | + | ||
288 | + | ||
289 | +DROP TABLE `product_special_attr`; | ||
290 | + | ||
291 | +CREATE TABLE `product_special_attr` ( | ||
292 | + `product_id` INT(11) UNSIGNED , | ||
293 | + `size_standard` TINYINT(4) DEFAULT NULL, | ||
294 | + `wear_sense` VARCHAR(250) DEFAULT NULL, | ||
295 | + `wash_tips` VARCHAR(50) DEFAULT NULL, | ||
296 | + `product_material` VARCHAR(100) DEFAULT '', | ||
297 | + `product_skn` INT(11) UNSIGNED NOT NULL, | ||
298 | + PRIMARY KEY (`product_skn`) | ||
299 | +) ENGINE=INNODB DEFAULT CHARSET=utf8; | ||
300 | + | ||
301 | +ALTER TABLE `product_special_attr` ADD UNIQUE (`product_id`); | ||
302 | + | ||
303 | +DROP TABLE IF EXISTS `product_brand_relation`; | ||
304 | +CREATE TABLE `product_brand_relation` ( | ||
305 | + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
306 | + `product_skn` int(11) unsigned NOT NULL DEFAULT '0', | ||
307 | + `brand_id` smallint(5) unsigned NOT NULL DEFAULT '0', | ||
308 | + PRIMARY KEY (`id`), | ||
309 | + KEY `product_skn` (`product_skn`) | ||
310 | +) ENGINE=INNODB AUTO_INCREMENT=51033484 DEFAULT CHARSET=utf8; | ||
311 | + | ||
312 | + | ||
313 | +``` | ||
314 | + | ||
315 | + |
-
Please register or login to post a comment