use kgraph;

DROP TABLE
IF
	EXISTS t_air_status_info;
CREATE TABLE t_air_status_info (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	air_model_id BIGINT ( 20 ) COMMENT '飞机id',
	model_number VARCHAR ( 64 ) COMMENT '型号',
	air_id BIGINT ( 20 ) COMMENT '机号id',
	air_number VARCHAR ( 64 ) COMMENT '机号',
	serial VARCHAR ( 64 ) COMMENT '飞机编号',
	production_date datetime COMMENT '出厂日期',
	production_info VARCHAR ( 255 ) COMMENT '厂家信息',
	version VARCHAR ( 64 ) COMMENT '版本号',
	version_update_date datetime COMMENT '版本升级日期',
	repair_times INT COMMENT '维修次数',
	repair_date datetime COMMENT '维修时间',
	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
	create_time datetime COMMENT '创建时间',
	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
	update_time datetime COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB COMMENT = '飞机履历';

-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历', '2317', '1', 'airRecord', 'ledger/airRecord/index', 1, 0, 'C', '0', '0', 'ledger:airRecord:list', '#', 'admin', sysdate(), '', null, '飞机履历菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'ledger:airRecord:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'ledger:airRecord:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'ledger:airRecord:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'ledger:airRecord:remove',       '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('飞机履历导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'ledger:airRecord:export',       '#', 'admin', sysdate(), '', null, '');

ALTER TABLE `kgraph`.`t_air_system_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '系统名称' AFTER `id`;
ALTER TABLE `kgraph`.`t_air_subsystem_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '分系统名称' AFTER `id`;
ALTER TABLE `kgraph`.`t_air_part_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '部件名称' AFTER `id`;
ALTER TABLE `kgraph`.`t_air_system_status_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '系统名称' AFTER `id`;
ALTER TABLE `kgraph`.`t_air_subsystem_status_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '分系统名称' AFTER `id`;
ALTER TABLE `kgraph`.`t_air_part_status_info`
ADD COLUMN `name` varchar(64) NULL COMMENT '部件名称' AFTER `id`;

ALTER TABLE `kgraph`.`t_air_system_status_info`
MODIFY COLUMN `serial` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统编号' AFTER `air_number`,
MODIFY COLUMN `version` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本升级' AFTER `production_date`,
MODIFY COLUMN `version_update_date` datetime NULL DEFAULT NULL COMMENT '升级时间' AFTER `version`,
ADD COLUMN `return_factory_time` datetime NULL COMMENT '返厂时间' AFTER `repair_date`,
ADD COLUMN `repair_item` varchar(255) NULL COMMENT '维修事项' AFTER `return_factory_time`,
ADD COLUMN `bunch_unit` varchar(255) NULL COMMENT '串件安装飞机号' AFTER `repair_item`;

commit;