数据库变更
1.数据库(erp_supplier)
1.1 店铺管理员(erp_supplier.shops_admin)
操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。
sql 脚本:
ALTER TABLE shops_admin ADD status
TINYINT not null default 1 COMMENT '1、正常 2、已删除';
1.2 店铺审核(erp_supplier.shops_check)
操作说明:新增店铺审核erp_supplier.shops_check数据表。
sql 脚本:
CREATE TABLE shops_check
(
shops_id
int(11) unsigned NOT NULL AUTO_INCREMENT,
shop_name
varchar(100) NOT NULL,
shop_domain
varchar(50) NOT NULL,
shop_relation
varchar(5000) DEFAULT NULL,
shop_nature
tinyint(4) unsigned NOT NULL DEFAULT '0',
shop_logo
varchar(200) DEFAULT NULL,
shop_intro
varchar(5000) DEFAULT NULL,
website_url
varchar(500) NOT NULL,
other_url
varchar(500) DEFAULT NULL,
shop_address
varchar(1000) DEFAULT NULL,
create_pid
int(11) unsigned DEFAULT '0',
shops_type
tinyint(4) NOT NULL DEFAULT '1' COMMENT '1、单品店,2、多品店',
operation_status
tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '1 店铺未创建 2店铺已创建',
examine_status
tinyint(4) unsigned NOT NULL DEFAULT '0',
status
tinyint(4) NOT NULL DEFAULT '0' COMMENT '1 开启 0 关闭',
check_status
smallint(6) DEFAULT NULL COMMENT '100 暂存 200 待审核 300 审核通过 900 驳回',
is_read
tinyint(4) NOT NULL DEFAULT '0' COMMENT '1 未处理 2 已处理',
create_time
int(10) unsigned NOT NULL DEFAULT '0',
update_time
int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (shops_id
)
) ENGINE=InnoDB AUTO_INCREMENT=433 DEFAULT CHARSET=utf8;
1.3 供应商(erp_supplier.supplier)
sql 脚本:
ALTER TABLE supplier
ADD COLUMN account_opening_license
varchar(200) NOT NULL DEFAULT '' COMMENT '开户许可证' AFTER contact_address
,
ADD COLUMN taxpayer_qualification_certificate
varchar(200) NULL COMMENT '纳税人资格证明' AFTER account_opening_license
,
ADD COLUMN industry_license
varchar(200) NULL COMMENT '行业许可证' AFTER taxpayer_qualification_certificate
;
CREATE TABLE supplier_check
(
id
int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
supplier_code
varchar(100) DEFAULT NULL COMMENT '供应商编号',
supplier_name
varchar(200) DEFAULT NULL COMMENT '供应商名称',
business_license
varchar(255) DEFAULT NULL COMMENT '经营许可证->组织机构代码证',
legal_person
varchar(10) DEFAULT NULL COMMENT '法人姓名',
linkman
varchar(10) DEFAULT NULL COMMENT '联系人姓名',
phone
varchar(20) DEFAULT NULL COMMENT '联系电话',
fax
varchar(20) DEFAULT NULL COMMENT '传真',
email
varchar(50) DEFAULT NULL COMMENT '邮箱',
url
varchar(100) DEFAULT NULL COMMENT '网址',
tax_certificate
varchar(255) DEFAULT '' COMMENT '税务登记证',
bank_name
varchar(100) DEFAULT NULL COMMENT '开户行',
bank_account
varchar(100) DEFAULT NULL COMMENT '开户账号',
category
tinyint(4) DEFAULT '1' COMMENT '1、普通供应商\n 2、特约供应商',
create_time
int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
update_time
int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
static
tinyint(4) DEFAULT '1',
is_lock
int(11) DEFAULT '1',
found_time
date DEFAULT NULL COMMENT '成立时间',
begin_operate_time
date DEFAULT NULL COMMENT '经营开始时间',
end_operate_time
date DEFAULT NULL COMMENT '经营结束时间',
is_freeze
enum('Y','N') DEFAULT 'N' COMMENT '是否冻结',
status
smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '100暂存,200审核中,300通过,900驳回',
operations
int(10) DEFAULT NULL COMMENT '1 创建 2 编辑 3 冻结 4 解冻',
registered_address
varchar(255) NOT NULL DEFAULT '' COMMENT '公司注册地址',
registered_capital
decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '注册资本',
business_license_pic
varchar(200) NOT NULL DEFAULT '' COMMENT '经营许可证图片->组织机构代码证图片',
business_range
varchar(500) NOT NULL DEFAULT '' COMMENT '经营范围',
legal_identity_card
varchar(200) NOT NULL DEFAULT '' COMMENT '法人身份证电子版',
create_pid
int(11) unsigned DEFAULT '0' COMMENT '创建人',
contact_phone
varchar(50) NOT NULL DEFAULT '' COMMENT '公司联系电话',
contact_address
varchar(255) NOT NULL DEFAULT '' COMMENT '公司联系地址',
account_opening_license
varchar(200) NOT NULL DEFAULT '' COMMENT '开户许可证',
taxpayer_qualification_certificate
varchar(200) DEFAULT NULL COMMENT '纳税人资格证明',
industry_license
varchar(200) DEFAULT NULL COMMENT '行业许可证',
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=1359 DEFAULT CHARSET=utf8;
insert into supplier_check select * from supplier;
2.数据库(yhb_operations)
1.1 帮助分类(yhb_operations.help_category)
操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。
sql 脚本:
ALTER TABLE yhb_operations.help_category ADD status
TINYINT not null default 1 COMMENT '1、正常 2、已删除';
1.2 帮助内容(yhb_operations.help_content)
操作说明:增加标识字段status 1 表示正常记录 2 表示已删除记录。
sql 脚本:
ALTER TABLE yhb_operations.help_content ADD status
TINYINT not null default 1 COMMENT '1、正常 2、已删除';
3.数据库(erp_product)
1.1表(erp_product.standard)
sql 脚本:
ALTER TABLE erp_product
.standard
ADD KEY key_sort_id(sort_id);
ALTER TABLE product_material
CHANGE max_sort_id product_max_sort_id INT(11) UNSIGNED;
UPDATE standard SET standard_sort_id = NULL;
ALTER TABLE erp_product
.standard
DROP COLUMN standard_sort_id
;
1.2表(erp_product.product_material)
sql 脚本:
ALTER TABLE product_material
CHANGE max_sort_id product_max_sort_id INT(11) UNSIGNED;
1.3表(erp_product. brand_series)
sql 脚本:
USE erp_product;
-- add column
ALTER TABLE brand_series
ADD shops_id INT(11) UNSIGNED;
ALTER TABLE brand_series
MODIFY shops_id INT(11) NOT NULL COMMENT '店铺id';
ALTER TABLE brand_series
ADD TYPE SMALLINT(6) UNSIGNED COMMENT '类型';
ALTER TABLE brand_series
ADD TYPE SMALLINT(6) UNSIGNED COMMENT '类型';
-- add key
ALTER TABLE brand_series
ADD KEY key_shops_id (shops_id);
ALTER TABLE brand_series
ADD KEY key_brand_id (brand_id);
-- set null
ALTER TABLE brand_series CHANGE parent_id parent_id INT(11) UNSIGNED NULL;
ALTER TABLE brand_series CHANGE order_by order_by SMALLINT(6) NULL;
1.4表(erp_product.product_special_attr )
sql 脚本:
CREATE TABLE product_special_attr
(
product_id
INT(11) UNSIGNED ,
size_standard
TINYINT(4) DEFAULT NULL,
wear_sense
VARCHAR(250) DEFAULT NULL,
wash_tips
VARCHAR(50) DEFAULT NULL,
product_material
VARCHAR(100) DEFAULT '',
product_skn
INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (product_skn
)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
ALTER TABLE product_special_attr
ADD UNIQUE (product_id
);
1.5数据库迁移 (yh_shops ,erp_product) 把 yh_shops数据库中表size_relations,standard,product_material,product_collocation 迁移到erp_product数据库中对应表。
yh_shops: ALTER TABLE product_standard_relation ADD COLUMN product_skn INT(11)
4.数据库(erp_product)
1.1表(erp_product.product)
sql 脚本:
alter table product add column is_screen enum('Y', 'N') default 'N' COMMENT '是否已拍摄标识';
alter table product add column is_measure enum('Y', 'N') default 'N' COMMENT '是否已测量标识';
alter table product add column status smallint default -1 COMMENT '初始状态-1, 待上架审核状态2 审核通过1 审核驳回 3 下架状态0';
alter table product add column first_shelve_time int(10) unsigned DEFAULT '0' COMMENT '首次上架时间';
alter table product add column shelve_time int(10) unsigned DEFAULT '0' COMMENT '上架时间可作为上新参考';
alter table product add column shelve_time int(10) unsigned DEFAULT '0' COMMENT '上架时间可作为上新参考';
alter table product add column stock
smallint(6) DEFAULT 0 COMMENT '库存';
-- 为价格表增加是否已同步前台的字段
alter table product_price add column sys_status smallint default 1 COMMENT '未同步0, 已同步或者无需同步1';
--回滚脚本
--alter table product drop column is_screen; --alter table product drop column is_measure; --alter table product drop column status; --alter table product drop column stock; ---- alter table product_price drop column sys_status;
--新增表商品的扩展属性表 erp_product表
DROP TABLE IF EXISTS product_ext
;
create table product_ext(
product_skn int COMMENT '商品erp标识',
product_desc text COMMENT '描述',
recommend text COMMENT '小编推荐',
is_hostsell enum('Y', 'N') default 'N' COMMENT '是否热销 Y:是N:否',
sales_phrase varchar(100) COMMENT '促销短语',
is_new enum('Y', 'N') default 'N' COMMENT '是否新品 Y:是N:否',
shelves_day int COMMENT '售罄后几天后下架',
sell_channels set('0','1','2','3','4','5','6','7','8','9') COMMENT '上架渠道',
phrase varchar(500) COMMENT '商品短评',
search_keys varchar(500) COMMENT '搜索关键词 以英文逗号分隔',
vedio_url varchar(100) COMMENT '视频链接',
make_crafts varchar(50) COMMENT '制作工艺',
brand_series varchar(50) COMMENT '品牌系列',
brand_model varchar(50) COMMENT '品牌款型',
reject_reason varchar(500) COMMENT '驳回原因'
)ENGINE=INNODB DEFAULT CHARSET=utf8;
Alter table product_ext add primary key(product_skn);
create table product_shop_relation( product_skn int COMMENT 'SKN', shop_id int COMMENT '店铺Id' ) Alter table product_shop_relation add primary key(product_skn, shop_id);
-- 排序的表结构
DROP TABLE IF EXISTS product_search
;
CREATE TABLE product_search
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
product_skn
int(11) unsigned NOT NULL DEFAULT '0',
model_id
smallint(6) NOT NULL DEFAULT '0',
project_id
smallint(6) NOT NULL DEFAULT '0',
int_value
int(11) unsigned NOT NULL DEFAULT '0',
string_value
varchar(100) DEFAULT NULL,
create_time
int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id
),
KEY project_id
(project_id
),
KEY product_skn
(product_skn
),
KEY product_skn_model_project_id
(product_skn
,model_id
,project_id
)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
-- 商品搭配
DROP TABLE IF EXISTS product_collocation
;
CREATE TABLE product_collocation
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
product_skn
int(11) unsigned NOT NULL DEFAULT '0',
image_url
varchar(255) DEFAULT NULL,
info
text,
content
varchar(255) DEFAULT NULL,
order_by
tinyint(4) NOT NULL DEFAULT '0',
create_time
int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id
),
KEY product_skn
(product_skn
)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
-- 商品相关图片 封面图片
DROP TABLE IF EXISTS goods_images
;
CREATE TABLE goods_images
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
product_skc
int(11) unsigned NOT NULL DEFAULT '0',
product_skn
int(11) unsigned NOT NULL DEFAULT '0',
is_default
enum('Y','N') NOT NULL DEFAULT 'N',
image_name
varchar(50) DEFAULT NULL,
image_url
varchar(255) DEFAULT NULL,
angle
tinyint(4) NOT NULL DEFAULT '0',
order_by
tinyint(4) NOT NULL DEFAULT '0',
intro
varchar(255) DEFAULT NULL,
status
tinyint(4) NOT NULL DEFAULT '1',
gender_cover
tinyint(4) unsigned DEFAULT '0',
PRIMARY KEY (id
),
KEY product_skn
(product_skn
,is_default
,status
),
KEY product_skc
(product_skc
,is_default
,status
),
KEY goods_id_2
(product_skc
,product_skn
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品相关图片';
-- SKU单独上下架
Alter table erp_product.storage ADD column status
tinyint(4) NOT NULL DEFAULT '1' COMMENT '0下架 1 上架';
-- skc上下架状态
Alter table erp_product.goods ADD column status
tinyint(4) NOT NULL DEFAULT '0' COMMENT '0下架 1 上架';
-- skn上下架状态 上架更新或者不上新需要更新 status first_shelve_time(如果没有值更新,有值无需更新) 上架上新 shelve_time 需要更新(不管有没有值)
Alter table erp_product.product ADD column status
tinyint(4) NOT NULL DEFAULT '0' COMMENT '0下架 1 上架';
-- 预上架上新记录表
DROP TABLE IF EXISTS product_timing
;
CREATE TABLE product_timing
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
product_skn
int(11) unsigned NOT NULL,
shelve_time
int(10) unsigned COMMENT '预上架时间',
on_new_time
int(10) unsigned COMMENT '预上架上新时间',
out_sale_time
int(10) unsigned COMMENT '预下架时间',
advance_begin_time
int(10) unsigned COMMENT '预售开始时间',
advance_end_time
int(10) unsigned COMMENT '预售结束时间',
flag
tinyint(4) NOT NULL DEFAULT '0',
create_time
int(10) unsigned NOT NULL,
PRIMARY KEY (id
),
KEY product_skn
(product_skn
),
KEY create_time
(create_time
)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
-- 网销信息缺失类型的全量枚举表
DROP TABLE IF EXISTS netsale_infomiss
;
CREATE TABLE netsale_infomiss (
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
name
varchar(100) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '网销信息缺失类型的全量枚举表';
insert into netsale_infomiss (name) values('文本信息'),('尺码信息'),('搜索/标签');
-- 商品和网销信息缺失表的关联关系表
DROP TABLE IF EXISTS netsale_infomiss_relation
;
CREATE TABLE netsale_infomiss_relation (
product_skn
int(11) unsigned NOT NULL,
infomiss_id
int(11) unsigned NOT NULL COMMENT 'netsale_infomiss_sort 的主键',
PRIMARY KEY (product_skn
, infomiss_id)
) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '网销信息缺失类型和商品的关系表';
DROP TABLE product_special_attr
;
CREATE TABLE product_special_attr
(
product_id
INT(11) UNSIGNED ,
size_standard
TINYINT(4) DEFAULT NULL,
wear_sense
VARCHAR(250) DEFAULT NULL,
wash_tips
VARCHAR(50) DEFAULT NULL,
product_material
VARCHAR(100) DEFAULT '',
product_skn
INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (product_skn
)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
ALTER TABLE product_special_attr
ADD UNIQUE (product_id
);
DROP TABLE IF EXISTS product_brand_relation
;
CREATE TABLE product_brand_relation
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
product_skn
int(11) unsigned NOT NULL DEFAULT '0',
brand_id
smallint(5) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id
),
KEY product_skn
(product_skn
)
) ENGINE=INNODB AUTO_INCREMENT=51033484 DEFAULT CHARSET=utf8;