Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptation deployment data source: MYSQL #1208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.chat2db.server.domain.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class ChartDO implements Serializable {
/**
* 图表信息
*/
@TableField("`schema`")
private String schema;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.chat2db.server.domain.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class DashboardDO implements Serializable {
/**
* 报表布局信息
*/
@TableField("`schema`")
private String schema;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.chat2db.server.domain.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
Expand Down Expand Up @@ -92,6 +93,7 @@ public class DataSourceDO implements Serializable {
/**
* ssl配置信息json
*/
@TableField("`ssl`")
private String ssl;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.chat2db.server.domain.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class TableVectorMappingDO implements Serializable {
/**
* schema名称
*/
@TableField("`schema`")
private String schema;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS `data_source` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
`alias` varchar(128) DEFAULT NULL COMMENT '别名',
Expand All @@ -8,43 +8,43 @@ CREATE TABLE IF NOT EXISTS `data_source` (
`password` varchar(256) DEFAULT NULL COMMENT '密码',
`type` varchar(32) DEFAULT NULL COMMENT '数据库类型',
`env_type` varchar(32) DEFAULT NULL COMMENT '环境类型',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='数据源连接表'
;

CREATE TABLE IF NOT EXISTS `operation_log` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`data_source_id` bigint(20) unsigned NOT NULL COMMENT '数据源连接ID',
`data_source_id` bigint unsigned NOT NULL COMMENT '数据源连接ID',
`database_name` varchar(128) DEFAULT NULL COMMENT 'db名称',
`type` varchar(32) NOT NULL COMMENT '数据库类型',
`ddl` text DEFAULT NULL COMMENT 'ddl内容',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='我的执行记录表'
;

CREATE TABLE IF NOT EXISTS `operation_saved` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`data_source_id` bigint(20) unsigned NOT NULL COMMENT '数据源连接ID',
`data_source_id` bigint unsigned NOT NULL COMMENT '数据源连接ID',
`database_name` varchar(128) DEFAULT NULL COMMENT 'db名称',
`name` varchar(128) DEFAULT NULL COMMENT '保存名称',
`type` varchar(32) NOT NULL COMMENT '数据库类型',
`status` varchar(32) NOT NULL COMMENT 'ddl语句状态:DRAFT/RELEASE',
`ddl` text DEFAULT NULL COMMENT 'ddl内容',
`tab_opened` text DEFAULT NULL COMMENT '是否在tab中被打开,y表示打开,n表示未打开',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='我的保存表'
;


CREATE TABLE IF NOT EXISTS `dbhub_user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`user_name` varchar(32) NOT NULL COMMENT '用户名',
Expand All @@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS `dbhub_user` (
;

CREATE TABLE IF NOT EXISTS `system_config` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`code` varchar(32) NOT NULL COMMENT '配置项编码',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
CREATE TABLE IF NOT EXISTS `dashboard` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`name` varchar(128) DEFAULT NULL COMMENT '报表名称',
`description` varchar(128) DEFAULT NULL COMMENT '报表描述',
`schema` text DEFAULT NULL COMMENT '报表布局信息',
`deleted` text DEFAULT NULL COMMENT '是否被删除,y表示删除,n表示未删除',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自定义报表表'
;

CREATE TABLE IF NOT EXISTS `chart` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`name` varchar(128) DEFAULT NULL COMMENT '图表名称',
`description` varchar(128) DEFAULT NULL COMMENT '图表描述',
`schema` text DEFAULT NULL COMMENT '图表信息',
`data_source_id` bigint(20) unsigned DEFAULT NULL COMMENT '数据源连接ID',
`data_source_id` bigint unsigned DEFAULT NULL COMMENT '数据源连接ID',
`type` varchar(32) DEFAULT NULL COMMENT '数据库类型',
`database_name` varchar(128) DEFAULT NULL COMMENT 'db名称',
`ddl` text DEFAULT NULL COMMENT 'ddl内容',
`deleted` text DEFAULT NULL COMMENT '是否被删除,y表示删除,n表示未删除',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自定义报表表'
;

CREATE TABLE IF NOT EXISTS `dashboard_chart_relation` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`dashboard_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '报表id',
`chart_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '图表id',
`dashboard_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '报表id',
`chart_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '图表id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自定义报表表'
;
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE IF NOT EXISTS `pin_table` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`data_source_id` bigint(20) unsigned NOT NULL COMMENT '数据源连接ID',
`data_source_id` bigint unsigned NOT NULL COMMENT '数据源连接ID',
`database_name` varchar(128) DEFAULT NULL COMMENT 'db名称',
`schema_name` varchar(128) DEFAULT NULL COMMENT 'schema名称',
`table_name` varchar(128) DEFAULT NULL COMMENT 'table_name',
`deleted` text DEFAULT NULL COMMENT '是否被删除,y表示删除,n表示未删除',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
`user_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '用户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='PIN TABLES'
;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INSERT INTO DATA_SOURCE (GMT_CREATE, GMT_MODIFIED, ALIAS, URL, USER_NAME, PASSWORD, TYPE, USER_ID, HOST, PORT, SSH,JDBC)
VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '[email protected]', 'jdbc:mysql://db.sqlgpt.cn:3306/DEMO', 'demo', 'kok39AYoOSM=', 'MYSQL', 0, 'db.sqlgpt.cn', '3306', '{"use":false}', '8.0');

INSERT INTO DASHBOARD (ID, GMT_CREATE, GMT_MODIFIED, NAME, DESCRIPTION, SCHEMA, DELETED, USER_ID)
INSERT INTO DASHBOARD (ID, GMT_CREATE, GMT_MODIFIED, NAME, DESCRIPTION, `SCHEMA`, DELETED, USER_ID)
VALUES (1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '学生成绩分析', '学生成绩分析', '[[1],[2],[3]]', 'N', 0);

INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, SCHEMA, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, `SCHEMA`, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
VALUES (1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '{"chartType":"Column","xAxis":"name","yAxis":"total_score"}', 1, 'DEMO', 'SELECT s.name, sc.chinese_score, sc.math_score, sc.english_score, sc.science_score, sc.humanities_score,
(sc.chinese_score + sc.math_score + sc.english_score + sc.science_score + sc.humanities_score) AS total_score
FROM student s
JOIN score sc ON s.id = sc.student_id', 'N', 0);

INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, SCHEMA, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, `SCHEMA`, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
VALUES (2, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '{"chartType":"Pie","xAxis":"grade"}', 1, 'DEMO', 'SELECT s.name,
score.chinese_score,
score.math_score,
Expand All @@ -27,7 +27,7 @@ VALUES (2, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '{"chartType":"Pie","xAxis":"gr
FROM score
JOIN student s ON score.student_id = s.id', 'N', 0);

INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, SCHEMA, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
INSERT INTO CHART (ID, GMT_CREATE, GMT_MODIFIED, `SCHEMA`, DATA_SOURCE_ID, DATABASE_NAME, DDL, DELETED, USER_ID)
VALUES (3, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '{"chartType":"Line","xAxis":"name","yAxis":"chinese_score"}', 1, 'DEMO', 'SELECT s.name, sc.chinese_score, sc.math_score, sc.english_score, sc.science_score, sc.humanities_score,
(sc.chinese_score + sc.math_score + sc.english_score + sc.science_score + sc.humanities_score) AS total_score
FROM student s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS `jdbc_driver` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`db_type` varchar(32) NOT NULL COMMENT 'db类型',
Expand Down
Loading