Skip to content

Commit

Permalink
#527 给表数据添加create_time和update_time字段
Browse files Browse the repository at this point in the history
  • Loading branch information
lzw2006 committed Dec 29, 2018
1 parent a0a4876 commit 6e503b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@

<insert id="batchCreateOrUpdateHistory" parameterType="java.util.List">
insert into saturn_dashboard_history(
zk_cluster, record_type , topic, content, record_date
zk_cluster, record_type , topic, content, record_date, create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.zkCluster}, #{item.type}, #{item.topic}, #{item.content}, #{item.recordDate}
#{item.zkCluster}, #{item.type}, #{item.topic}, #{item.content}, #{item.recordDate}, #{item.recordDate}
)
</foreach>
on duplicate key update
content = values(content)
content = values(content),
update_time = values(create_time)
</insert>

</mapper>
8 changes: 5 additions & 3 deletions saturn-console/src/main/resources/db/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@ CREATE TABLE `saturn_dashboard_history` (
`zk_cluster` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '所属zk集群',
`record_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '类型',
`topic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '主题',
`content` LONGTEXT NOT NULL COMMENT '内容',
`record_date` DATE NOT NULL COMMENT '记录日期',
`content` LONGTEXT COMMENT '内容',
`record_date` DATE COMMENT '记录日期',
`create_time` TIMESTAMP NOT NULL DEFAULT '1980-01-01 00:00:00' COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `index1` (`zk_cluster`, `record_type`, `topic`, `record_date`)
UNIQUE KEY `history_key` (`zk_cluster`, `record_type`, `topic`, `record_date`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 COMMENT ='dashboard历史记录表';

ALTER TABLE `namespace_info` ADD `bus_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '业务组id';
Expand Down

0 comments on commit 6e503b5

Please sign in to comment.