1
0
Просмотр исходного кода

chore: 数据库自动初始化,删除过期sql

370774330@qq.com 5 лет назад
Родитель
Сommit
b1325084d6

+ 2 - 1
web/src/main/resources/application-wph.yml

@@ -7,7 +7,8 @@ spring:
     separator: ;
     initialization-mode: always
     continue-on-error: false
-    schema: sql/init.sql
+    schema:
+      - classpath:sql/init.sql
 
   mail:
     host: smtp.qq.com

+ 0 - 19
web/src/main/resources/sql/bug_list.sql

@@ -1,19 +0,0 @@
-create table if not exists devcloud.bug_list
-(
-    id                 int auto_increment
-        primary key,
-    title              varchar(31)                         null,
-    description        text                                null,
-    time_to_take mediumtext                          null,
-    start_time         timestamp default CURRENT_TIMESTAMP not null,
-    end_time           timestamp                           null,
-    priority           varchar(10)                         null,
-    state              varchar(10)                         null,
-    project_id         int                                 null,
-    processor_id       int                                 null,
-    constraint bug_list_project_id_fk
-        foreign key (project_id) references devcloud.project (id),
-    constraint bug_list_user_id_fk
-        foreign key (processor_id) references devcloud.user (id)
-);
-

+ 0 - 15
web/src/main/resources/sql/commit.sql

@@ -1,15 +0,0 @@
-create table if not exists devcloud.commit
-(
-    id              varchar(127) not null
-        primary key,
-    message         text         null,
-    title           text         null,
-    timestamp       varchar(31)  null,
-    gitlab_username varchar(31)  null,
-    related_id      int          null,
-    project_id      int          null,
-    related_type    varchar(11)  null,
-    constraint commit_project_id_fk
-        foreign key (project_id) references devcloud.project (id)
-);
-

+ 46 - 17
web/src/main/resources/sql/init.sql

@@ -1,18 +1,17 @@
-create database if not exists devcloud;
-use devcloud;
 create table if not exists devcloud.project
 (
-    id             int          not null,
+    id             int          not null
+        primary key,
     name           varchar(128) null,
     description    varchar(512) null,
-    git_remote_url varchar(512) not null,
-    primary key (id)
+    git_remote_url varchar(512) not null
 )
     charset = utf8;
 
 create table if not exists devcloud.commit
 (
-    id              varchar(127) not null,
+    id              varchar(127) not null
+        primary key,
     message         text         null,
     title           text         null,
     timestamp       varchar(31)  null,
@@ -20,7 +19,6 @@ create table if not exists devcloud.commit
     related_id      int          null,
     project_id      int          null,
     related_type    varchar(11)  null,
-    primary key (id),
     constraint commit_project_id_fk
         foreign key (project_id) references devcloud.project (id)
 );
@@ -38,6 +36,41 @@ create table if not exists devcloud.pipeline
             on delete set null
 );
 
+create table if not exists devcloud.deployment
+(
+    id            int auto_increment
+        primary key,
+    pipeline_id   int         not null,
+    namespace     varchar(63) null,
+    deploy_name   varchar(63) null,
+    deployed_time timestamp   null,
+    access_url    text        null,
+    constraint deployment_pipeline_id_uindex
+        unique (pipeline_id),
+    constraint deployment_pipeline_id_fk
+        foreign key (pipeline_id) references devcloud.pipeline (id)
+);
+
+create table if not exists devcloud.test_case
+(
+    id         int auto_increment
+        primary key,
+    project_id int                  not null,
+    title      varchar(63)          null,
+    pass       tinyint(1) default 0 not null
+);
+
+create table if not exists devcloud.test_step
+(
+    id           int auto_increment
+        primary key,
+    test_case_id int  null,
+    description  text null,
+    constraint test_step_test_case_id_fk
+        foreign key (test_case_id) references devcloud.test_case (id)
+            on delete set null
+);
+
 create table if not exists devcloud.tree_log
 (
     id        int auto_increment
@@ -52,7 +85,8 @@ create table if not exists devcloud.tree_log
 
 create table if not exists devcloud.tree_node
 (
-    id           int auto_increment,
+    id           int auto_increment
+        primary key,
     title        varchar(24)                           not null,
     description  varchar(512)                          null,
     type         varchar(32) default '0'               not null,
@@ -65,23 +99,18 @@ create table if not exists devcloud.tree_node
     project_id   int                                   null,
     deep         int                                   null,
     parent_id    int                                   null,
-    processor_id int                                   null,
-    constraint tree_nodes_id_uindex
-        unique (id)
+    processor_id int                                   null
 );
 
-alter table devcloud.tree_node
-    add primary key (id);
-
 create table if not exists devcloud.user
 (
-    id          int         not null,
+    id          int         not null
+        primary key,
     username    varchar(31) null,
     phone       varchar(11) null,
     email       varchar(63) null,
     role        varchar(11) null,
-    with_gitlab tinyint(1)  null,
-    primary key (id)
+    with_gitlab tinyint(1)  null
 );
 
 create table if not exists devcloud.bug_list

+ 0 - 13
web/src/main/resources/sql/pipeline.sql

@@ -1,13 +0,0 @@
-create table if not exists devcloud.pipeline
-(
-    id            int auto_increment
-        primary key,
-    project_id    int         null,
-    name          varchar(47) null,
-    config_json   text        null,
-    template_name varchar(31) null,
-    constraint pipeline_project_id_fk
-        foreign key (project_id) references devcloud.project (id)
-            on delete set null
-);
-

+ 0 - 15
web/src/main/resources/sql/pipeline_history.sql

@@ -1,15 +0,0 @@
-create table if not exists devcloud.pipeline_history
-(
-    id          int auto_increment
-        primary key,
-    pipeline_id int                                 null,
-    start_time  timestamp default CURRENT_TIMESTAMP not null,
-    user_id     int                                 null,
-    result      varchar(15)                         null,
-    details     text                                null,
-    constraint pipeline_history_pipeline_id_fk
-        foreign key (pipeline_id) references devcloud.pipeline (id),
-    constraint pipeline_history_user_id_fk
-        foreign key (user_id) references devcloud.user (id)
-);
-

+ 0 - 10
web/src/main/resources/sql/project.sql

@@ -1,10 +0,0 @@
-create table if not exists devcloud.project
-(
-    id             int          not null
-        primary key,
-    name           varchar(128) null,
-    description    varchar(512) null,
-    git_remote_url varchar(512) not null
-)
-    charset = utf8;
-

+ 0 - 39
web/src/main/resources/sql/tree_log.sql

@@ -1,39 +0,0 @@
-/*
- Navicat Premium Data Transfer
-
- Source Server         : localhost_3306
- Source Server Type    : MySQL
- Source Server Version : 80018
- Source Host           : localhost:3306
- Source Schema         : seecoder
-
- Target Server Type    : MySQL
- Target Server Version : 80018
- File Encoding         : 65001
-
- Date: 11/03/2021 09:46:42
-*/
-
-SET NAMES utf8mb4;
-SET FOREIGN_KEY_CHECKS = 0;
-
--- ----------------------------
--- Table structure for tree_log
--- ----------------------------
-use devcloud;
-DROP TABLE IF EXISTS `tree_log`;
-CREATE TABLE `tree_log`  (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `time` datetime(0) NULL DEFAULT NULL,
-  `operation` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `user_id` int(11) NULL DEFAULT NULL,
-  `tree_id` int(11) NULL DEFAULT NULL,
-  `user_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-
--- ----------------------------
--- Records of tree_log
--- ----------------------------
-
-SET FOREIGN_KEY_CHECKS = 1;

+ 0 - 23
web/src/main/resources/sql/trees.sql

@@ -1,23 +0,0 @@
-create table if not exists devcloud.tree_node
-(
-    id           int auto_increment,
-    title        varchar(24)                           not null,
-    description  varchar(512)                          null,
-    type         varchar(32) default '0'               not null,
-    priority     int         default 0                 null,
-    state        varchar(32) default '0'               not null,
-    time_to_take int         default 0                 not null,
-    start_time   datetime    default CURRENT_TIMESTAMP not null,
-    end_time     datetime                              null,
-    leaf         tinyint(1)  default 0                 null,
-    project_id   int                                   null,
-    deep         int                                   null,
-    parent_id    int                                   null,
-    processor_id int                                   null,
-    constraint tree_nodes_id_uindex
-        unique (id)
-);
-
-alter table devcloud.tree_node
-    add primary key (id);
-

+ 0 - 11
web/src/main/resources/sql/user.sql

@@ -1,11 +0,0 @@
-create table if not exists devcloud.user
-(
-    id          int         not null
-        primary key,
-    username    varchar(31) null,
-    phone       varchar(11) null,
-    email       varchar(63) null,
-    role        varchar(11) null,
-    with_gitlab tinyint(1)  null
-);
-