From f67e175197c0b938aa2447d4631198dc26b00715 Mon Sep 17 00:00:00 2001 From: DreamlandLiu <205407@qq.com> Date: Tue, 22 Nov 2022 22:51:22 +0800 Subject: [PATCH 1/3] merge migration sql files --- .../src/main/resources/application.yaml | 2 + .../db/migration/V00001__Create_schema.sql | 390 -------------- .../db/migration/V00002__Add_data.sql | 27 - .../db/migration/V00003__Add_view_config.sql | 15 - .../db/migration/V00004__Add_project.sql | 2 - .../db/migration/V00005__Add_project_role.sql | 55 -- .../db/migration/V00006__Drop_oldrole.sql | 3 - .../db/migration/V00007__Add_project_des.sql | 2 - .../migration/V00008__Add_job_dag_field.sql | 5 - .../migration/V00009__Add_dataset_field.sql | 4 - .../migration/V00010__Add_project_privacy.sql | 2 - .../migration/V00011__Add_resource_pool.sql | 18 - .../migration/V00012__Delete_task_field.sql | 3 - .../migration/V00013__Add_dataset_field.sql | 2 - .../V00014__Update_dataset_field.sql | 2 - .../V00015__Restore_task_result_path.sql | 18 - .../V00016__alter_manifest_2_image.sql | 16 - .../migration/V00017__Add_version_field.sql | 20 - .../db/migration/V00018__job_defaults.sql | 4 - .../V00019__Modify_project_index.sql | 84 --- .../migration/V00020__Add_job_step_spec.sql | 19 - .../migration/V00021__Add_system_setting.sql | 20 - .../db/migration/V00022__Add_test_role.sql | 25 - .../V00023__Refactor_resource_pool.sql | 18 - .../db/migration/V00024__Refactor_rename.sql | 24 - .../V00025__enlarge_dataset_meta.sql | 18 - .../migration/V00026__Add_dataset_reader.sql | 52 -- .../db/migration/V00027__Add_trash.sql | 35 -- .../db/migration/V00028__Add_panel_plugin.sql | 39 -- .../migration/V00029__Mod_project_unique.sql | 20 - .../migration/V00030__Remove_dataset_auth.sql | 17 - .../migration/V00031__Mod_dataset_reader.sql | 24 - .../v0_3_2/V0_3_2_000__clear_mirgration.sql | 1 + .../v0_3_2/V0_3_2_001__create_schema.sql | 477 ++++++++++++++++++ .../v0_3_2/V0_3_2_002__init_data.sql | 55 ++ 35 files changed, 535 insertions(+), 983 deletions(-) delete mode 100644 server/controller/src/main/resources/db/migration/V00001__Create_schema.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00002__Add_data.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00003__Add_view_config.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00004__Add_project.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00005__Add_project_role.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00006__Drop_oldrole.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00007__Add_project_des.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00008__Add_job_dag_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00009__Add_dataset_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00010__Add_project_privacy.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00011__Add_resource_pool.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00012__Delete_task_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00013__Add_dataset_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00014__Update_dataset_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00015__Restore_task_result_path.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00016__alter_manifest_2_image.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00017__Add_version_field.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00018__job_defaults.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00019__Modify_project_index.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00020__Add_job_step_spec.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00021__Add_system_setting.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00022__Add_test_role.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00023__Refactor_resource_pool.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00024__Refactor_rename.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00025__enlarge_dataset_meta.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00026__Add_dataset_reader.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00027__Add_trash.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00028__Add_panel_plugin.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00029__Mod_project_unique.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00030__Remove_dataset_auth.sql delete mode 100644 server/controller/src/main/resources/db/migration/V00031__Mod_dataset_reader.sql create mode 100644 server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_000__clear_mirgration.sql create mode 100644 server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql create mode 100644 server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_002__init_data.sql diff --git a/server/controller/src/main/resources/application.yaml b/server/controller/src/main/resources/application.yaml index 1a73ad594d..811cb82ac7 100644 --- a/server/controller/src/main/resources/application.yaml +++ b/server/controller/src/main/resources/application.yaml @@ -80,6 +80,8 @@ spring: password: ${SW_METADATA_STORAGE_PASSWORD:starwhale} flyway: locations: "classpath:db/migration" + ignore-missing-migrations: true + out-of-order: true mvc: view: suffix: .html diff --git a/server/controller/src/main/resources/db/migration/V00001__Create_schema.sql b/server/controller/src/main/resources/db/migration/V00001__Create_schema.sql deleted file mode 100644 index c29905304e..0000000000 --- a/server/controller/src/main/resources/db/migration/V00001__Create_schema.sql +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright 2022.1-2022 - * starwhale.ai All right reserved. This software is the confidential and proprietary information of - * starwhale.ai ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only - * in accordance with the terms of the license agreement you entered into with starwhale.ai. - */ --- ---------------------------- --- Table structure for agent_info --- ---------------------------- -create table if not exists agent_info -( - id bigint auto_increment comment 'PK' primary key, - agent_ip int unsigned not null, - connect_time datetime not null, - agent_version varchar(255) not null, - agent_status varchar(32) not null, - serial_number varchar(255) not null, - device_info text not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_serial_number - unique (serial_number) -); -create index idx_agent_version on agent_info (agent_version); - --- ---------------------------- --- Table structure for dag_graph --- ---------------------------- -create table if not exists dag_graph -( - id bigint auto_increment comment 'PK' - primary key, - job_id bigint not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint idx_dag_job_id - unique (job_id) -); - --- ---------------------------- --- Table structure for dag_graph_edge --- ---------------------------- -create table if not exists dag_graph_edge -( - id bigint auto_increment comment 'PK' - primary key, - graph_id bigint not null, - from_node bigint not null, - to_node bigint not null, - content varchar(255) not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_dag_edge_from - on dag_graph_edge (from_node); - -create index idx_dag_edge_graph_id - on dag_graph_edge (graph_id); - -create index idx_dag_edge_to - on dag_graph_edge (to_node); - --- ---------------------------- --- Table structure for dag_graph_node --- ---------------------------- -create table if not exists dag_graph_node -( - id bigint auto_increment comment 'PK' primary key, - graph_id bigint not null, - node_type varchar(50) not null, - node_group varchar(255) not null, - owner_id bigint not null, - content varchar(255) not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_dag_node_graph_id - on dag_graph_node (graph_id); - -create index idx_dag_node_owner_id - on dag_graph_node (owner_id); - --- ---------------------------- --- Table structure for dataset_info --- ---------------------------- -create table if not exists dataset_info -( - id bigint auto_increment comment 'PK' primary key, - dataset_name varchar(255) not null, - project_id bigint null, - owner_id bigint not null, - is_deleted tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_dataset_name - on dataset_info (dataset_name); - -create index idx_owner_id - on dataset_info (owner_id); - -create index idx_project_id - on dataset_info (project_id); - --- ---------------------------- --- Table structure for dataset_version --- ---------------------------- -create table if not exists dataset_version -( - id bigint auto_increment comment 'PK' primary key, - dataset_id bigint not null, - owner_id bigint not null, - version_name varchar(255) not null, - version_tag varchar(255) null, - version_meta text not null, - files_uploaded text null, - storage_path text not null, - status tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint unq_swds_version_name - unique (dataset_id, version_name) -); - -create index idx_dataset_id - on dataset_version (dataset_id); - -create index idx_owner_id - on dataset_version (owner_id); - --- ---------------------------- --- Table structure for job_dataset_version_rel --- ---------------------------- -create table if not exists job_dataset_version_rel -( - id bigint auto_increment comment 'PK' primary key, - job_id bigint not null, - dataset_version_id bigint not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_dataset_version_id - on job_dataset_version_rel (dataset_version_id); - -create index idx_job_id - on job_dataset_version_rel (job_id); - --- ---------------------------- --- Table structure for job_info --- ---------------------------- -create table if not exists job_info -( - id bigint auto_increment comment 'PK' primary key, - job_uuid varchar(255) not null, - project_id bigint not null, - swmp_version_id bigint not null, - owner_id bigint not null, - created_time datetime not null, - finished_time datetime null, - duration_ms bigint not null, - job_status varchar(50) not null, - job_type varchar(50) not null, - swrt_version_id bigint not null, - device_type tinyint unsigned not null, - device_amount int not null, - result_output_path text not null, - job_comment text null, - is_deleted tinyint unsigned default '0' not null, - constraint uk_job_uuid - unique (job_uuid) -); - -create index idx_base_image - on job_info (swrt_version_id); - -create index idx_job_status - on job_info (job_status); - -create index idx_owner_id - on job_info (owner_id); - -create index idx_swmp_version_id - on job_info (swmp_version_id); - --- ---------------------------- --- Table structure for project_info --- ---------------------------- -create table if not exists project_info -( - id bigint auto_increment comment 'PK' primary key, - project_name varchar(255) not null, - owner_id bigint not null, - is_default tinyint unsigned default '0' not null, - is_deleted tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_create_user_id - on project_info (owner_id); - -create index idx_project_name - on project_info (project_name); - --- ---------------------------- --- Table structure for runtime_info --- ---------------------------- -create table if not exists runtime_info -( - id bigint auto_increment comment 'PK' primary key, - runtime_name varchar(255) not null, - project_id bigint not null, - owner_id bigint not null, - is_deleted tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_owner_id - on runtime_info (owner_id); - -create index idx_project_id - on runtime_info (project_id); - -create index idx_runtime_name - on runtime_info (runtime_name); - --- ---------------------------- --- Table structure for runtime_version --- ---------------------------- -create table if not exists runtime_version -( - id bigint auto_increment comment 'PK' primary key, - runtime_id bigint not null, - owner_id bigint not null, - version_name varchar(255) not null, - version_tag varchar(255) null, - version_meta text not null, - storage_path text not null, - manifest text null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint unq_runtime_version_name - unique (runtime_id, version_name) -); - -create index idx_owner_id - on runtime_version (owner_id); - -create index idx_runtime_id - on runtime_version (runtime_id); - --- ---------------------------- --- Table structure for step --- ---------------------------- -create table if not exists step -( - id bigint auto_increment comment 'PK' primary key, - step_uuid varchar(255) not null, - step_name varchar(255) not null, - job_id bigint not null, - last_step_id bigint null, - step_status varchar(50) not null, - finished_time datetime null, - started_time datetime null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_step_uuid - unique (step_uuid) -); - -create index idx_step_job_id - on step (job_id); - --- ---------------------------- --- Table structure for swmp_info --- ---------------------------- -create table if not exists swmp_info -( - id bigint auto_increment comment 'PK' primary key, - swmp_name varchar(255) not null, - project_id bigint not null, - owner_id bigint not null, - is_deleted tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -create index idx_owner_id - on swmp_info (owner_id); - -create index idx_project_id - on swmp_info (project_id); - -create index idx_swmp_name - on swmp_info (swmp_name); - --- ---------------------------- --- Table structure for swmp_version --- ---------------------------- -create table if not exists swmp_version -( - id bigint auto_increment comment 'PK' primary key, - swmp_id bigint not null, - owner_id bigint not null, - version_name varchar(255) not null, - version_tag varchar(255) null, - version_meta text not null, - storage_path text not null, - manifest text null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint unq_swmp_version_name - unique (swmp_id, version_name) -); - -create index idx_owner_id - on swmp_version (owner_id); - -create index idx_swmp_id - on swmp_version (swmp_id); - --- ---------------------------- --- Table structure for task_info --- ---------------------------- -create table if not exists task_info -( - id bigint auto_increment comment 'PK' primary key, - task_uuid varchar(255) not null, - step_id bigint not null, - agent_id bigint null, - task_status varchar(50) not null, - task_type varchar(50) not null, - result_path text not null, - task_request longtext null, - finished_time datetime null, - started_time datetime null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_task_uuid - unique (task_uuid) -); - -create index idx_agent_id - on task_info (agent_id); - -create index idx_job_id - on task_info (step_id); - -create index idx_task_status - on task_info (task_status); - -create index idx_task_type - on task_info (task_type); - --- ---------------------------- --- Table structure for user_info --- ---------------------------- -create table if not exists user_info -( - id bigint auto_increment comment 'PK' primary key, - user_name varchar(255) not null, - user_pwd varchar(255) not null, - user_pwd_salt varchar(255) not null, - role_id bigint not null, - user_enabled tinyint unsigned default '0' not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_user_name - unique (user_name) -); - --- ---------------------------- --- Table structure for user_role --- ---------------------------- -create table if not exists user_role -( - id bigint auto_increment comment 'PK' primary key, - role_name varchar(32) not null, - role_name_en varchar(32) not null, - constraint uk_role_name - unique (role_name) -); - - - diff --git a/server/controller/src/main/resources/db/migration/V00002__Add_data.sql b/server/controller/src/main/resources/db/migration/V00002__Add_data.sql deleted file mode 100644 index 2f109ad31b..0000000000 --- a/server/controller/src/main/resources/db/migration/V00002__Add_data.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2022.1-2022 - * starwhale.ai All right reserved. This software is the confidential and proprietary information of - * starwhale.ai ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only - * in accordance with the terms of the license agreement you entered into with starwhale.ai. - */ - -#init data for test - -insert into user_role(role_name, role_name_en) -values ('admin', 'admin'); -insert into user_role(role_name, role_name_en) -values ('user', 'user'); - -#password=abcd1234 -insert into user_info(user_name, user_pwd, user_pwd_salt, role_id, user_enabled) -values ('starwhale', 'ee9533077d01d2d65a4efdb41129a91e', '6ea18d595773ccc2beacce26', 1, 1); - -#password=asdf7890 -insert into user_info(user_name, user_pwd, user_pwd_salt, role_id, user_enabled) -values ('test', '7ce1c1d60c3393e4ca681e738036fe8c', 'be1866739033b7907631a71e', 1, 0); - -insert into project_info(project_name, owner_id) -values ('project_for_test1', 1); -insert into project_info(project_name, owner_id) -values ('project_for_test2', 2); - diff --git a/server/controller/src/main/resources/db/migration/V00003__Add_view_config.sql b/server/controller/src/main/resources/db/migration/V00003__Add_view_config.sql deleted file mode 100644 index 081c8d605d..0000000000 --- a/server/controller/src/main/resources/db/migration/V00003__Add_view_config.sql +++ /dev/null @@ -1,15 +0,0 @@ --- ---------------------------- --- Table structure for dataset_info --- ---------------------------- -create table if not exists view_config -( - id bigint auto_increment comment 'PK' primary key, - config_name varchar(255) not null, - project_id bigint not null, - owner_id bigint not null, - content text not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_config_name - unique (config_name, owner_id, project_id) -); \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00004__Add_project.sql b/server/controller/src/main/resources/db/migration/V00004__Add_project.sql deleted file mode 100644 index b5edc0a449..0000000000 --- a/server/controller/src/main/resources/db/migration/V00004__Add_project.sql +++ /dev/null @@ -1,2 +0,0 @@ -insert into project_info(project_name, owner_id) -values ('starwhale', 1); diff --git a/server/controller/src/main/resources/db/migration/V00005__Add_project_role.sql b/server/controller/src/main/resources/db/migration/V00005__Add_project_role.sql deleted file mode 100644 index 86ea12327d..0000000000 --- a/server/controller/src/main/resources/db/migration/V00005__Add_project_role.sql +++ /dev/null @@ -1,55 +0,0 @@ --- ---------------------------- --- Table structure for user_role --- ---------------------------- -create table if not exists user_role_info -( - id bigint auto_increment comment 'PK' primary key, - role_name varchar(32) not null, - role_code varchar(32) not null, - role_description varchar(255) not null, - constraint uk_role_name - unique (role_name) -); - -insert into user_role_info(role_name, role_code, role_description) -values ('Owner', 'OWNER', ''); - -insert into user_role_info(role_name, role_code, role_description) -values ('Maintainer', 'MAINTAINER', ''); - -insert into user_role_info(role_name, role_code, role_description) -values ('Guest', 'GUEST', ''); - --- ---------------------------- --- Table structure for user_role_rel --- ---------------------------- -create table if not exists user_role_rel -( - id bigint auto_increment comment 'PK' primary key, - user_id bigint not null, - role_id bigint not null, - project_id bigint not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - constraint uk_project_role - unique (user_id, role_id, project_id) -); - -create index idx_user_id - on user_role_rel (user_id); - -create index idx_role_id - on user_role_rel (role_id); - -create index idx_project_id - on user_role_rel (project_id); - -insert into user_role_rel(user_id, role_id, project_id) -values ((select id from user_info where user_name='starwhale'), - (select id from user_role_info where role_name='owner'), - 0); - -insert into user_role_rel(user_id, role_id, project_id) -values ((select id from user_info where user_name='starwhale'), - (select id from user_role_info where role_name='owner'), - (select id from project_info where project_name='starwhale')); diff --git a/server/controller/src/main/resources/db/migration/V00006__Drop_oldrole.sql b/server/controller/src/main/resources/db/migration/V00006__Drop_oldrole.sql deleted file mode 100644 index 76c6a49a4e..0000000000 --- a/server/controller/src/main/resources/db/migration/V00006__Drop_oldrole.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table user_info drop column role_id; - -drop table if exists user_role; diff --git a/server/controller/src/main/resources/db/migration/V00007__Add_project_des.sql b/server/controller/src/main/resources/db/migration/V00007__Add_project_des.sql deleted file mode 100644 index 6fcdda2964..0000000000 --- a/server/controller/src/main/resources/db/migration/V00007__Add_project_des.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table project_info - add project_description text null after owner_id; diff --git a/server/controller/src/main/resources/db/migration/V00008__Add_job_dag_field.sql b/server/controller/src/main/resources/db/migration/V00008__Add_job_dag_field.sql deleted file mode 100644 index 698473ea90..0000000000 --- a/server/controller/src/main/resources/db/migration/V00008__Add_job_dag_field.sql +++ /dev/null @@ -1,5 +0,0 @@ -alter table swmp_version - add eval_jobs text not null; -alter table step - add concurrency int not null, - add task_num int not null; diff --git a/server/controller/src/main/resources/db/migration/V00009__Add_dataset_field.sql b/server/controller/src/main/resources/db/migration/V00009__Add_dataset_field.sql deleted file mode 100644 index ad675d3b3b..0000000000 --- a/server/controller/src/main/resources/db/migration/V00009__Add_dataset_field.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table dataset_version - add size bigint not null; -alter table dataset_version - add index_table varchar(255) not null; diff --git a/server/controller/src/main/resources/db/migration/V00010__Add_project_privacy.sql b/server/controller/src/main/resources/db/migration/V00010__Add_project_privacy.sql deleted file mode 100644 index 54d279ec9a..0000000000 --- a/server/controller/src/main/resources/db/migration/V00010__Add_project_privacy.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table project_info - add privacy int not null default '0' after owner_id; diff --git a/server/controller/src/main/resources/db/migration/V00011__Add_resource_pool.sql b/server/controller/src/main/resources/db/migration/V00011__Add_resource_pool.sql deleted file mode 100644 index 9e91f664e8..0000000000 --- a/server/controller/src/main/resources/db/migration/V00011__Add_resource_pool.sql +++ /dev/null @@ -1,18 +0,0 @@ --- ---------------------------- --- Table structure for resource_pool --- ---------------------------- -create table if not exists resource_pool -( - id bigint auto_increment comment 'PK' primary key, - label varchar(64) not null unique, - name varchar(255) null, - description text null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); - -insert into resource_pool(label, name, description) -values ('default', 'default', 'default resource pool'); - -alter table job_info - add resource_pool_id bigint not null; diff --git a/server/controller/src/main/resources/db/migration/V00012__Delete_task_field.sql b/server/controller/src/main/resources/db/migration/V00012__Delete_task_field.sql deleted file mode 100644 index 17a45cae6a..0000000000 --- a/server/controller/src/main/resources/db/migration/V00012__Delete_task_field.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table task_info - drop column task_type, - drop column result_path; diff --git a/server/controller/src/main/resources/db/migration/V00013__Add_dataset_field.sql b/server/controller/src/main/resources/db/migration/V00013__Add_dataset_field.sql deleted file mode 100644 index 547f6513ae..0000000000 --- a/server/controller/src/main/resources/db/migration/V00013__Add_dataset_field.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table dataset_version - add storage_auths TEXT not null; diff --git a/server/controller/src/main/resources/db/migration/V00014__Update_dataset_field.sql b/server/controller/src/main/resources/db/migration/V00014__Update_dataset_field.sql deleted file mode 100644 index 3e2cbad646..0000000000 --- a/server/controller/src/main/resources/db/migration/V00014__Update_dataset_field.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table dataset_version - modify storage_auths text null; diff --git a/server/controller/src/main/resources/db/migration/V00015__Restore_task_result_path.sql b/server/controller/src/main/resources/db/migration/V00015__Restore_task_result_path.sql deleted file mode 100644 index ff775fdc06..0000000000 --- a/server/controller/src/main/resources/db/migration/V00015__Restore_task_result_path.sql +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -alter table task_info - add output_path TEXT; diff --git a/server/controller/src/main/resources/db/migration/V00016__alter_manifest_2_image.sql b/server/controller/src/main/resources/db/migration/V00016__alter_manifest_2_image.sql deleted file mode 100644 index e669f829e9..0000000000 --- a/server/controller/src/main/resources/db/migration/V00016__alter_manifest_2_image.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -ALTER TABLE runtime_version RENAME COLUMN manifest TO image; diff --git a/server/controller/src/main/resources/db/migration/V00017__Add_version_field.sql b/server/controller/src/main/resources/db/migration/V00017__Add_version_field.sql deleted file mode 100644 index f9fd04e741..0000000000 --- a/server/controller/src/main/resources/db/migration/V00017__Add_version_field.sql +++ /dev/null @@ -1,20 +0,0 @@ -alter table swmp_version - add version_order bigint default 0 not null after id; -update swmp_version set version_order = id; -create index idx_version_order - on swmp_version (version_order); - -alter table dataset_version - add version_order bigint default 0 not null after id; -update dataset_version set version_order = id; -create index idx_version_order - on dataset_version (version_order); - -alter table runtime_version - add version_order bigint default 0 not null after id; -update runtime_version set version_order = id; -create index idx_version_order - on runtime_version (version_order); - - - diff --git a/server/controller/src/main/resources/db/migration/V00018__job_defaults.sql b/server/controller/src/main/resources/db/migration/V00018__job_defaults.sql deleted file mode 100644 index 4393505386..0000000000 --- a/server/controller/src/main/resources/db/migration/V00018__job_defaults.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE job_info MODIFY COLUMN created_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP; -ALTER TABLE job_info MODIFY COLUMN duration_ms bigint; - - diff --git a/server/controller/src/main/resources/db/migration/V00019__Modify_project_index.sql b/server/controller/src/main/resources/db/migration/V00019__Modify_project_index.sql deleted file mode 100644 index bbc5fe256d..0000000000 --- a/server/controller/src/main/resources/db/migration/V00019__Modify_project_index.sql +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -drop index idx_project_name on project_info; - -create unique index unq_project_name - on project_info (project_name); \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00020__Add_job_step_spec.sql b/server/controller/src/main/resources/db/migration/V00020__Add_job_step_spec.sql deleted file mode 100644 index abf8a3ad4c..0000000000 --- a/server/controller/src/main/resources/db/migration/V00020__Add_job_step_spec.sql +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -alter table job_info - add step_spec text after result_output_path; -ALTER TABLE job_info DROP COLUMN device_type; -ALTER TABLE job_info DROP COLUMN device_amount; \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00021__Add_system_setting.sql b/server/controller/src/main/resources/db/migration/V00021__Add_system_setting.sql deleted file mode 100644 index 66c6f8dca6..0000000000 --- a/server/controller/src/main/resources/db/migration/V00021__Add_system_setting.sql +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -create table if not exists system_setting -( - id bigint auto_increment comment 'PK' primary key, - content text comment 'yaml format' not null -); \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00022__Add_test_role.sql b/server/controller/src/main/resources/db/migration/V00022__Add_test_role.sql deleted file mode 100644 index 0919ced287..0000000000 --- a/server/controller/src/main/resources/db/migration/V00022__Add_test_role.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -insert into user_role_rel(user_id, role_id, project_id) -values ((select id from user_info where user_name = 'test'), - (select id from user_role_info where role_name = 'maintainer'), - 0); - -insert into user_role_rel(user_id, role_id, project_id) -values ((select id from user_info where user_name = 'test'), - (select id from user_role_info where role_name = 'guest'), - (select id from project_info where project_name = 'starwhale')); \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00023__Refactor_resource_pool.sql b/server/controller/src/main/resources/db/migration/V00023__Refactor_resource_pool.sql deleted file mode 100644 index dc111a0482..0000000000 --- a/server/controller/src/main/resources/db/migration/V00023__Refactor_resource_pool.sql +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -drop table resource_pool; -ALTER TABLE job_info RENAME COLUMN resource_pool_id TO resource_pool; -ALTER TABLE job_info MODIFY resource_pool varchar(255) null; diff --git a/server/controller/src/main/resources/db/migration/V00024__Refactor_rename.sql b/server/controller/src/main/resources/db/migration/V00024__Refactor_rename.sql deleted file mode 100644 index b98d1b53e2..0000000000 --- a/server/controller/src/main/resources/db/migration/V00024__Refactor_rename.sql +++ /dev/null @@ -1,24 +0,0 @@ --- ---------------------------- --- Table structure for job_info --- ---------------------------- -alter table job_info - change swmp_version_id model_version_id bigint not null; - -alter table job_info - change swrt_version_id runtime_version_id bigint not null; - --- ---------------------------- --- Table structure for model_info --- ---------------------------- -alter table swmp_info - change swmp_name model_name varchar(255) not null; - -rename table swmp_info to model_info; - --- ---------------------------- --- Table structure for model_version --- ---------------------------- -alter table swmp_version - change swmp_id model_id bigint not null; - -rename table swmp_version to model_version; \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00025__enlarge_dataset_meta.sql b/server/controller/src/main/resources/db/migration/V00025__enlarge_dataset_meta.sql deleted file mode 100644 index a5bf6f6a08..0000000000 --- a/server/controller/src/main/resources/db/migration/V00025__enlarge_dataset_meta.sql +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -alter table dataset_version - change version_meta version_meta MEDIUMTEXT not null; \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00026__Add_dataset_reader.sql b/server/controller/src/main/resources/db/migration/V00026__Add_dataset_reader.sql deleted file mode 100644 index 63aa71ba28..0000000000 --- a/server/controller/src/main/resources/db/migration/V00026__Add_dataset_reader.sql +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -create table if not exists `dataset_read_session` -( - `id` varchar(255) NOT NULL, - `dataset_name` varchar(255) NOT NULL, - `dataset_version` varchar(255) NOT NULL, - `table_name` varchar(255) NOT NULL, - `current` varchar(255) NULL, - `current_inclusive` tinyint unsigned NOT NULL DEFAULT '1', - `start` varchar(255) NULL, - `start_inclusive` tinyint unsigned NOT NULL DEFAULT '1', - `end` varchar(255) NULL, - `end_inclusive` tinyint unsigned NOT NULL DEFAULT '1', - `batch_size` bigint NOT NULL, - `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -); - -create table if not exists `dataset_read_log` -( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', - `session_id` varchar(255) NOT NULL, - `consumer_id` varchar(255) NULL, - `start` varchar(255) NOT NULL, - `start_inclusive` tinyint unsigned NOT NULL DEFAULT '1', - `end` varchar(255) NULL, - `end_inclusive` tinyint unsigned NOT NULL DEFAULT '0', - `status` varchar(20) NOT NULL, - `size` bigint NOT NULL, - `assigned_num` bigint NOT NULL DEFAULT 0, - `assigned_time` datetime NULL, - `finished_time` datetime NULL, - `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - UNIQUE KEY `session_readrange` (`session_id`, `start`, `end`) -) diff --git a/server/controller/src/main/resources/db/migration/V00027__Add_trash.sql b/server/controller/src/main/resources/db/migration/V00027__Add_trash.sql deleted file mode 100644 index 4172ac2ee9..0000000000 --- a/server/controller/src/main/resources/db/migration/V00027__Add_trash.sql +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - --- ---------------------------- --- Table structure for trash --- ---------------------------- -create table if not exists trash -( - id bigint auto_increment comment 'PK' primary key, - project_id bigint not null, - object_id bigint not null, - operator_id bigint not null, - trash_name varchar(255) not null, - trash_type varchar(255) not null, - size bigint default 0 not null, - retention datetime not null, - updated_time datetime not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP -); -create index idx_project_id on trash (project_id); -create index idx_operator_id on trash (operator_id); \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/V00028__Add_panel_plugin.sql b/server/controller/src/main/resources/db/migration/V00028__Add_panel_plugin.sql deleted file mode 100644 index 70e8723e95..0000000000 --- a/server/controller/src/main/resources/db/migration/V00028__Add_panel_plugin.sql +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -create table panel_plugin -( - id bigint auto_increment comment 'PK' primary key, - name varchar(255) not null, - version varchar(255) not null, - meta json null, - storage_path text not null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - deleted_time datetime null, - constraint uniq unique (name, version, deleted_time) -); - -create table panel_setting -( - user_id bigint not null, - project_id bigint not null, - name varchar(255) not null, - content text null, - created_time datetime default CURRENT_TIMESTAMP not null, - modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP, - primary key (name, project_id) -); diff --git a/server/controller/src/main/resources/db/migration/V00029__Mod_project_unique.sql b/server/controller/src/main/resources/db/migration/V00029__Mod_project_unique.sql deleted file mode 100644 index 7540ce0885..0000000000 --- a/server/controller/src/main/resources/db/migration/V00029__Mod_project_unique.sql +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -drop index unq_project_name on project_info; - -create unique index unq_project_name_owner - on project_info (project_name, owner_id); diff --git a/server/controller/src/main/resources/db/migration/V00030__Remove_dataset_auth.sql b/server/controller/src/main/resources/db/migration/V00030__Remove_dataset_auth.sql deleted file mode 100644 index 1894f35866..0000000000 --- a/server/controller/src/main/resources/db/migration/V00030__Remove_dataset_auth.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -ALTER TABLE dataset_version DROP COLUMN storage_auths; diff --git a/server/controller/src/main/resources/db/migration/V00031__Mod_dataset_reader.sql b/server/controller/src/main/resources/db/migration/V00031__Mod_dataset_reader.sql deleted file mode 100644 index a5f79f45e0..0000000000 --- a/server/controller/src/main/resources/db/migration/V00031__Mod_dataset_reader.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2022 Starwhale, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -TRUNCATE TABLE dataset_read_session; -ALTER TABLE dataset_read_session MODIFY COLUMN id BIGINT auto_increment NOT NULL COMMENT 'PK'; -ALTER TABLE dataset_read_session ADD session_id varchar(255) NOT NULL; -ALTER TABLE dataset_read_session ADD CONSTRAINT dataset_read_session_UN UNIQUE KEY (session_id,dataset_name,dataset_version); - -TRUNCATE TABLE dataset_read_log; -ALTER TABLE dataset_read_log DROP KEY session_readrange; -ALTER TABLE dataset_read_log MODIFY COLUMN session_id BIGINT NOT NULL; -ALTER TABLE dataset_read_log ADD CONSTRAINT dataset_read_log_UK UNIQUE KEY (session_id,`start`,`end`); diff --git a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_000__clear_mirgration.sql b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_000__clear_mirgration.sql new file mode 100644 index 0000000000..50a8b428f3 --- /dev/null +++ b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_000__clear_mirgration.sql @@ -0,0 +1 @@ +truncate table flyway_schema_history; \ No newline at end of file diff --git a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql new file mode 100644 index 0000000000..17049d7627 --- /dev/null +++ b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql @@ -0,0 +1,477 @@ +/* + * Copyright 2022.1-2022 + * starwhale.ai All right reserved. This software is the confidential and proprietary information of + * starwhale.ai ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only + * in accordance with the terms of the license agreement you entered into with starwhale.ai. + */ +-- ---------------------------- +-- Table structure for agent_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `agent_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `agent_ip` int UNSIGNED NOT NULL, + `connect_time` datetime NOT NULL, + `agent_version` varchar(255) NOT NULL, + `agent_status` varchar(32) NOT NULL, + `serial_number` varchar(255) NOT NULL, + `device_info` text NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_serial_number` (`serial_number` ASC) USING BTREE, + INDEX `idx_agent_version` (`agent_version` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dag_graph +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dag_graph` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `job_id` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `idx_dag_job_id` (`job_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dag_graph_edge +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dag_graph_edge` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `graph_id` bigint NOT NULL, + `from_node` bigint NOT NULL, + `to_node` bigint NOT NULL, + `content` varchar(255) NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_dag_edge_from` (`from_node` ASC) USING BTREE, + INDEX `idx_dag_edge_graph_id` (`graph_id` ASC) USING BTREE, + INDEX `idx_dag_edge_to` (`to_node` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dag_graph_node +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dag_graph_node` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `graph_id` bigint NOT NULL, + `node_type` varchar(50) NOT NULL, + `node_group` varchar(255) NOT NULL, + `owner_id` bigint NOT NULL, + `content` varchar(255) NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_dag_node_graph_id` (`graph_id` ASC) USING BTREE, + INDEX `idx_dag_node_owner_id` (`owner_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dataset_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dataset_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `dataset_name` varchar(255) NOT NULL, + `project_id` bigint NULL DEFAULT NULL, + `owner_id` bigint NOT NULL, + `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_dataset_name` (`dataset_name` ASC) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_project_id` (`project_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dataset_read_log +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dataset_read_log` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `session_id` bigint NOT NULL, + `consumer_id` varchar(255) NULL DEFAULT NULL, + `start` varchar(255) NOT NULL, + `start_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `end` varchar(255) NULL DEFAULT NULL, + `end_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 0, + `status` varchar(20) NOT NULL, + `size` bigint NOT NULL, + `assigned_num` bigint NOT NULL DEFAULT 0, + `assigned_time` datetime NULL DEFAULT NULL, + `finished_time` datetime NULL DEFAULT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `dataset_read_log_UK` (`session_id` ASC, `start` ASC, `end` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dataset_read_session +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dataset_read_session` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `dataset_name` varchar(255) NOT NULL, + `dataset_version` varchar(255) NOT NULL, + `table_name` varchar(255) NOT NULL, + `start` varchar(255) NULL DEFAULT NULL, + `start_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `end` varchar(255) NULL DEFAULT NULL, + `end_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `batch_size` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `session_id` varchar(255) NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `dataset_read_session_UN` (`session_id` ASC, `dataset_name` ASC, `dataset_version` + ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for dataset_version +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `dataset_version` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `version_order` bigint NOT NULL DEFAULT 0, + `dataset_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `version_name` varchar(255) NOT NULL, + `version_tag` varchar(255) NULL DEFAULT NULL, + `version_meta` mediumtext NOT NULL, + `files_uploaded` text NULL, + `storage_path` text NOT NULL, + `status` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `size` bigint NOT NULL, + `index_table` varchar(255) NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `unq_swds_version_name` (`dataset_id` ASC, `version_name` ASC) USING BTREE, + INDEX `idx_dataset_id` (`dataset_id` ASC) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_version_order` (`version_order` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for job_dataset_version_rel +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `job_dataset_version_rel` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `job_id` bigint NOT NULL, + `dataset_version_id` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_dataset_version_id` (`dataset_version_id` ASC) USING BTREE, + INDEX `idx_job_id` (`job_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for job_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `job_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `job_uuid` varchar(255) NOT NULL, + `project_id` bigint NOT NULL, + `model_version_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `finished_time` datetime NULL DEFAULT NULL, + `duration_ms` bigint NULL DEFAULT NULL, + `job_status` varchar(50) NOT NULL, + `job_type` varchar(50) NOT NULL, + `runtime_version_id` bigint NOT NULL, + `result_output_path` text NOT NULL, + `step_spec` text NULL, + `job_comment` text NULL, + `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, + `resource_pool` varchar(255) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_job_uuid` (`job_uuid` ASC) USING BTREE, + INDEX `idx_base_image` (`runtime_version_id` ASC) USING BTREE, + INDEX `idx_job_status` (`job_status` ASC) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_swmp_version_id` (`model_version_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for model_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `model_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `model_name` varchar(255) NOT NULL, + `project_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_project_id` (`project_id` ASC) USING BTREE, + INDEX `idx_swmp_name` (`model_name` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for model_version +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `model_version` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `version_order` bigint NOT NULL DEFAULT 0, + `model_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `version_name` varchar(255) NOT NULL, + `version_tag` varchar(255) NULL DEFAULT NULL, + `version_meta` text NOT NULL, + `storage_path` text NOT NULL, + `manifest` text NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `eval_jobs` text NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `unq_swmp_version_name` (`model_id` ASC, `version_name` ASC) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_swmp_id` (`model_id` ASC) USING BTREE, + INDEX `idx_version_order` (`version_order` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for panel_plugin +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `panel_plugin` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `meta` json NULL, + `storage_path` text NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `deleted_time` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uniq` (`name` ASC, `version` ASC, `deleted_time` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for panel_setting +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `panel_setting` +( + `user_id` bigint NOT NULL, + `project_id` bigint NOT NULL, + `name` varchar(255) NOT NULL, + `content` text NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`name`, `project_id`) USING BTREE +); + +-- ---------------------------- +-- Table structure for project_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `project_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `project_name` varchar(255) NOT NULL, + `owner_id` bigint NOT NULL, + `privacy` int NOT NULL DEFAULT 0, + `project_description` text NULL, + `is_default` tinyint UNSIGNED NOT NULL DEFAULT 0, + `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `unq_project_name_owner` (`project_name` ASC, `owner_id` ASC) USING BTREE, + INDEX `idx_create_user_id` (`owner_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for runtime_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `runtime_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `runtime_name` varchar(255) NOT NULL, + `project_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_project_id` (`project_id` ASC) USING BTREE, + INDEX `idx_runtime_name` (`runtime_name` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for runtime_version +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `runtime_version` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `version_order` bigint NOT NULL DEFAULT 0, + `runtime_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `version_name` varchar(255) NOT NULL, + `version_tag` varchar(255) NULL DEFAULT NULL, + `version_meta` text NOT NULL, + `storage_path` text NOT NULL, + `image` text NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `unq_runtime_version_name` (`runtime_id` ASC, `version_name` ASC) USING BTREE, + INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, + INDEX `idx_runtime_id` (`runtime_id` ASC) USING BTREE, + INDEX `idx_version_order` (`version_order` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for step +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `step` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `step_uuid` varchar(255) NOT NULL, + `step_name` varchar(255) NOT NULL, + `job_id` bigint NOT NULL, + `last_step_id` bigint NULL DEFAULT NULL, + `step_status` varchar(50) NOT NULL, + `finished_time` datetime NULL DEFAULT NULL, + `started_time` datetime NULL DEFAULT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `concurrency` int NOT NULL, + `task_num` int NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_step_uuid` (`step_uuid` ASC) USING BTREE, + INDEX `idx_step_job_id` (`job_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for system_setting +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `system_setting` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `content` text NOT NULL COMMENT 'yaml format', + PRIMARY KEY (`id`) USING BTREE +); + +-- ---------------------------- +-- Table structure for task_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `task_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `task_uuid` varchar(255) NOT NULL, + `step_id` bigint NOT NULL, + `agent_id` bigint NULL DEFAULT NULL, + `task_status` varchar(50) NOT NULL, + `task_request` longtext NULL, + `finished_time` datetime NULL DEFAULT NULL, + `started_time` datetime NULL DEFAULT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `output_path` text NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_task_uuid` (`task_uuid` ASC) USING BTREE, + INDEX `idx_agent_id` (`agent_id` ASC) USING BTREE, + INDEX `idx_job_id` (`step_id` ASC) USING BTREE, + INDEX `idx_task_status` (`task_status` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for trash +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `trash` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `project_id` bigint NOT NULL, + `object_id` bigint NOT NULL, + `operator_id` bigint NOT NULL, + `trash_name` varchar(255) NOT NULL, + `trash_type` varchar(255) NOT NULL, + `size` bigint NOT NULL DEFAULT 0, + `retention` datetime NOT NULL, + `updated_time` datetime NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_project_id` (`project_id` ASC) USING BTREE, + INDEX `idx_operator_id` (`operator_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for user_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `user_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `user_name` varchar(255) NOT NULL, + `user_pwd` varchar(255) NOT NULL, + `user_pwd_salt` varchar(255) NOT NULL, + `user_enabled` tinyint UNSIGNED NOT NULL DEFAULT 0, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_user_name` (`user_name` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for user_role_info +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `user_role_info` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `role_name` varchar(32) NOT NULL, + `role_code` varchar(32) NOT NULL, + `role_description` varchar(255) NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_role_name` (`role_name` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for user_role_rel +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `user_role_rel` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `user_id` bigint NOT NULL, + `role_id` bigint NOT NULL, + `project_id` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_project_role` (`user_id` ASC, `role_id` ASC, `project_id` ASC) USING BTREE, + INDEX `idx_user_id` (`user_id` ASC) USING BTREE, + INDEX `idx_role_id` (`role_id` ASC) USING BTREE, + INDEX `idx_project_id` (`project_id` ASC) USING BTREE +); + +-- ---------------------------- +-- Table structure for view_config +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `view_config` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `config_name` varchar(255) NOT NULL, + `project_id` bigint NOT NULL, + `owner_id` bigint NOT NULL, + `content` text NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_config_name` (`config_name` ASC, `owner_id` ASC, `project_id` ASC) USING BTREE +); diff --git a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_002__init_data.sql b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_002__init_data.sql new file mode 100644 index 0000000000..b1bed6f10c --- /dev/null +++ b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_002__init_data.sql @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Starwhale, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#password=abcd1234 +insert ignore into user_info(user_name, user_pwd, user_pwd_salt, user_enabled) +values ('starwhale', 'ee9533077d01d2d65a4efdb41129a91e', '6ea18d595773ccc2beacce26', 1); + +#password=asdf7890 +insert ignore into user_info(user_name, user_pwd, user_pwd_salt, user_enabled) +values ('test', '7ce1c1d60c3393e4ca681e738036fe8c', 'be1866739033b7907631a71e', 0); + +insert ignore into project_info(project_name, owner_id) +values ('starwhale', 1); + +insert ignore into user_role_info(role_name, role_code, role_description) +values ('Owner', 'OWNER', ''); + +insert ignore into user_role_info(role_name, role_code, role_description) +values ('Maintainer', 'MAINTAINER', ''); + +insert ignore into user_role_info(role_name, role_code, role_description) +values ('Guest', 'GUEST', ''); + +insert ignore into user_role_rel(user_id, role_id, project_id) +values ((select id from user_info where user_name='starwhale'), + (select id from user_role_info where role_name='owner'), + 0); + +insert ignore into user_role_rel(user_id, role_id, project_id) +values ((select id from user_info where user_name='starwhale'), + (select id from user_role_info where role_name='owner'), + (select id from project_info where project_name='starwhale')); + +insert ignore into user_role_rel(user_id, role_id, project_id) +values ((select id from user_info where user_name = 'test'), + (select id from user_role_info where role_name = 'maintainer'), + 0); + +insert ignore into user_role_rel(user_id, role_id, project_id) +values ((select id from user_info where user_name = 'test'), + (select id from user_role_info where role_name = 'guest'), + (select id from project_info where project_name = 'starwhale')); From 9cb38c6e42d01b19f0386d6ab58c626e35177630 Mon Sep 17 00:00:00 2001 From: DreamlandLiu <205407@qq.com> Date: Wed, 23 Nov 2022 11:18:22 +0800 Subject: [PATCH 2/3] fix bug --- .../v0_3_2/V0_3_2_001__create_schema.sql | 193 +++++++++++------- 1 file changed, 115 insertions(+), 78 deletions(-) diff --git a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql index 17049d7627..7ae50bdca9 100644 --- a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql +++ b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql @@ -1,12 +1,7 @@ -/* - * Copyright 2022.1-2022 - * starwhale.ai All right reserved. This software is the confidential and proprietary information of - * starwhale.ai ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only - * in accordance with the terms of the license agreement you entered into with starwhale.ai. - */ -- ---------------------------- -- Table structure for agent_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `agent_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -19,13 +14,14 @@ CREATE TABLE IF NOT EXISTS `agent_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_serial_number` (`serial_number` ASC) USING BTREE, - INDEX `idx_agent_version` (`agent_version` ASC) USING BTREE + UNIQUE INDEX `uk_serial_number` (`serial_number`) USING BTREE, + INDEX `idx_agent_version` (`agent_version`) USING BTREE ); -- ---------------------------- -- Table structure for dag_graph -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dag_graph` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -33,12 +29,13 @@ CREATE TABLE IF NOT EXISTS `dag_graph` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `idx_dag_job_id` (`job_id` ASC) USING BTREE + UNIQUE INDEX `idx_dag_job_id` (`job_id`) USING BTREE ); -- ---------------------------- -- Table structure for dag_graph_edge -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dag_graph_edge` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -49,14 +46,15 @@ CREATE TABLE IF NOT EXISTS `dag_graph_edge` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_dag_edge_from` (`from_node` ASC) USING BTREE, - INDEX `idx_dag_edge_graph_id` (`graph_id` ASC) USING BTREE, - INDEX `idx_dag_edge_to` (`to_node` ASC) USING BTREE + INDEX `idx_dag_edge_from` (`from_node`) USING BTREE, + INDEX `idx_dag_edge_graph_id` (`graph_id`) USING BTREE, + INDEX `idx_dag_edge_to` (`to_node`) USING BTREE ); -- ---------------------------- -- Table structure for dag_graph_node -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dag_graph_node` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -68,13 +66,14 @@ CREATE TABLE IF NOT EXISTS `dag_graph_node` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_dag_node_graph_id` (`graph_id` ASC) USING BTREE, - INDEX `idx_dag_node_owner_id` (`owner_id` ASC) USING BTREE + INDEX `idx_dag_node_graph_id` (`graph_id`) USING BTREE, + INDEX `idx_dag_node_owner_id` (`owner_id`) USING BTREE ); -- ---------------------------- -- Table structure for dataset_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dataset_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -85,14 +84,15 @@ CREATE TABLE IF NOT EXISTS `dataset_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_dataset_name` (`dataset_name` ASC) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_project_id` (`project_id` ASC) USING BTREE + INDEX `idx_dataset_name` (`dataset_name`) USING BTREE, + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_project_id` (`project_id`) USING BTREE ); -- ---------------------------- -- Table structure for dataset_read_log -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dataset_read_log` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -110,33 +110,37 @@ CREATE TABLE IF NOT EXISTS `dataset_read_log` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `dataset_read_log_UK` (`session_id` ASC, `start` ASC, `end` ASC) USING BTREE + UNIQUE INDEX `dataset_read_log_UK` (`session_id`, `start`, `end`) USING BTREE ); -- ---------------------------- -- Table structure for dataset_read_session -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dataset_read_session` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', - `dataset_name` varchar(255) NOT NULL, - `dataset_version` varchar(255) NOT NULL, - `table_name` varchar(255) NOT NULL, - `start` varchar(255) NULL DEFAULT NULL, - `start_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, - `end` varchar(255) NULL DEFAULT NULL, - `end_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, - `batch_size` bigint NOT NULL, - `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `session_id` varchar(255) NOT NULL, + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', + `dataset_name` varchar(255) NOT NULL, + `dataset_version` varchar(255) NOT NULL, + `table_name` varchar(255) NOT NULL, + `current` varchar(255) NULL DEFAULT NULL, + `current_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `start` varchar(255) NULL DEFAULT NULL, + `start_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `end` varchar(255) NULL DEFAULT NULL, + `end_inclusive` tinyint UNSIGNED NOT NULL DEFAULT 1, + `batch_size` bigint NOT NULL, + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `session_id` varchar(255) NOT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `dataset_read_session_UN` (`session_id` ASC, `dataset_name` ASC, `dataset_version` - ASC) USING BTREE + UNIQUE INDEX `dataset_read_session_UN` (`session_id`, `dataset_name`, `dataset_version` + ) USING BTREE ); -- ---------------------------- -- Table structure for dataset_version -- ---------------------------- + CREATE TABLE IF NOT EXISTS `dataset_version` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -154,15 +158,16 @@ CREATE TABLE IF NOT EXISTS `dataset_version` `size` bigint NOT NULL, `index_table` varchar(255) NOT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `unq_swds_version_name` (`dataset_id` ASC, `version_name` ASC) USING BTREE, - INDEX `idx_dataset_id` (`dataset_id` ASC) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_version_order` (`version_order` ASC) USING BTREE + UNIQUE INDEX `unq_swds_version_name` (`dataset_id`, `version_name`) USING BTREE, + INDEX `idx_dataset_id` (`dataset_id`) USING BTREE, + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_version_order` (`version_order`) USING BTREE ); -- ---------------------------- -- Table structure for job_dataset_version_rel -- ---------------------------- + CREATE TABLE IF NOT EXISTS `job_dataset_version_rel` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -171,13 +176,14 @@ CREATE TABLE IF NOT EXISTS `job_dataset_version_rel` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_dataset_version_id` (`dataset_version_id` ASC) USING BTREE, - INDEX `idx_job_id` (`job_id` ASC) USING BTREE + INDEX `idx_dataset_version_id` (`dataset_version_id`) USING BTREE, + INDEX `idx_job_id` (`job_id`) USING BTREE ); -- ---------------------------- -- Table structure for job_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `job_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -197,16 +203,17 @@ CREATE TABLE IF NOT EXISTS `job_info` `is_deleted` tinyint UNSIGNED NOT NULL DEFAULT 0, `resource_pool` varchar(255) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_job_uuid` (`job_uuid` ASC) USING BTREE, - INDEX `idx_base_image` (`runtime_version_id` ASC) USING BTREE, - INDEX `idx_job_status` (`job_status` ASC) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_swmp_version_id` (`model_version_id` ASC) USING BTREE + UNIQUE INDEX `uk_job_uuid` (`job_uuid`) USING BTREE, + INDEX `idx_base_image` (`runtime_version_id`) USING BTREE, + INDEX `idx_job_status` (`job_status`) USING BTREE, + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_swmp_version_id` (`model_version_id`) USING BTREE ); -- ---------------------------- -- Table structure for model_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `model_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -217,14 +224,15 @@ CREATE TABLE IF NOT EXISTS `model_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_project_id` (`project_id` ASC) USING BTREE, - INDEX `idx_swmp_name` (`model_name` ASC) USING BTREE + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_project_id` (`project_id`) USING BTREE, + INDEX `idx_swmp_name` (`model_name`) USING BTREE ); -- ---------------------------- -- Table structure for model_version -- ---------------------------- + CREATE TABLE IF NOT EXISTS `model_version` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -240,15 +248,16 @@ CREATE TABLE IF NOT EXISTS `model_version` `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `eval_jobs` text NOT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `unq_swmp_version_name` (`model_id` ASC, `version_name` ASC) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_swmp_id` (`model_id` ASC) USING BTREE, - INDEX `idx_version_order` (`version_order` ASC) USING BTREE + UNIQUE INDEX `unq_swmp_version_name` (`model_id`, `version_name`) USING BTREE, + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_swmp_id` (`model_id`) USING BTREE, + INDEX `idx_version_order` (`version_order`) USING BTREE ); -- ---------------------------- -- Table structure for panel_plugin -- ---------------------------- + CREATE TABLE IF NOT EXISTS `panel_plugin` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -260,12 +269,13 @@ CREATE TABLE IF NOT EXISTS `panel_plugin` `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `deleted_time` datetime NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uniq` (`name` ASC, `version` ASC, `deleted_time` ASC) USING BTREE + UNIQUE INDEX `uniq` (`name`, `version`, `deleted_time`) USING BTREE ); -- ---------------------------- -- Table structure for panel_setting -- ---------------------------- + CREATE TABLE IF NOT EXISTS `panel_setting` ( `user_id` bigint NOT NULL, @@ -280,6 +290,7 @@ CREATE TABLE IF NOT EXISTS `panel_setting` -- ---------------------------- -- Table structure for project_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `project_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -292,13 +303,18 @@ CREATE TABLE IF NOT EXISTS `project_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `unq_project_name_owner` (`project_name` ASC, `owner_id` ASC) USING BTREE, - INDEX `idx_create_user_id` (`owner_id` ASC) USING BTREE -); + UNIQUE INDEX `unq_project_name_owner` (`project_name`, `owner_id`) USING BTREE, + INDEX `idx_create_user_id` (`owner_id`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 4 + CHARACTER SET = utf8 + COLLATE = utf8_general_ci + ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for runtime_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `runtime_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -309,14 +325,15 @@ CREATE TABLE IF NOT EXISTS `runtime_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_project_id` (`project_id` ASC) USING BTREE, - INDEX `idx_runtime_name` (`runtime_name` ASC) USING BTREE + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_project_id` (`project_id`) USING BTREE, + INDEX `idx_runtime_name` (`runtime_name`) USING BTREE ); -- ---------------------------- -- Table structure for runtime_version -- ---------------------------- + CREATE TABLE IF NOT EXISTS `runtime_version` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -331,15 +348,16 @@ CREATE TABLE IF NOT EXISTS `runtime_version` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `unq_runtime_version_name` (`runtime_id` ASC, `version_name` ASC) USING BTREE, - INDEX `idx_owner_id` (`owner_id` ASC) USING BTREE, - INDEX `idx_runtime_id` (`runtime_id` ASC) USING BTREE, - INDEX `idx_version_order` (`version_order` ASC) USING BTREE + UNIQUE INDEX `unq_runtime_version_name` (`runtime_id`, `version_name`) USING BTREE, + INDEX `idx_owner_id` (`owner_id`) USING BTREE, + INDEX `idx_runtime_id` (`runtime_id`) USING BTREE, + INDEX `idx_version_order` (`version_order`) USING BTREE ); -- ---------------------------- -- Table structure for step -- ---------------------------- + CREATE TABLE IF NOT EXISTS `step` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -355,13 +373,14 @@ CREATE TABLE IF NOT EXISTS `step` `concurrency` int NOT NULL, `task_num` int NOT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_step_uuid` (`step_uuid` ASC) USING BTREE, - INDEX `idx_step_job_id` (`job_id` ASC) USING BTREE + UNIQUE INDEX `uk_step_uuid` (`step_uuid`) USING BTREE, + INDEX `idx_step_job_id` (`job_id`) USING BTREE ); -- ---------------------------- -- Table structure for system_setting -- ---------------------------- + CREATE TABLE IF NOT EXISTS `system_setting` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -372,6 +391,7 @@ CREATE TABLE IF NOT EXISTS `system_setting` -- ---------------------------- -- Table structure for task_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `task_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -386,15 +406,16 @@ CREATE TABLE IF NOT EXISTS `task_info` `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `output_path` text NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_task_uuid` (`task_uuid` ASC) USING BTREE, - INDEX `idx_agent_id` (`agent_id` ASC) USING BTREE, - INDEX `idx_job_id` (`step_id` ASC) USING BTREE, - INDEX `idx_task_status` (`task_status` ASC) USING BTREE + UNIQUE INDEX `uk_task_uuid` (`task_uuid`) USING BTREE, + INDEX `idx_agent_id` (`agent_id`) USING BTREE, + INDEX `idx_job_id` (`step_id`) USING BTREE, + INDEX `idx_task_status` (`task_status`) USING BTREE ); -- ---------------------------- -- Table structure for trash -- ---------------------------- + CREATE TABLE IF NOT EXISTS `trash` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -409,13 +430,14 @@ CREATE TABLE IF NOT EXISTS `trash` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_project_id` (`project_id` ASC) USING BTREE, - INDEX `idx_operator_id` (`operator_id` ASC) USING BTREE + INDEX `idx_project_id` (`project_id`) USING BTREE, + INDEX `idx_operator_id` (`operator_id`) USING BTREE ); -- ---------------------------- -- Table structure for user_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `user_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -426,12 +448,17 @@ CREATE TABLE IF NOT EXISTS `user_info` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_user_name` (`user_name` ASC) USING BTREE -); + UNIQUE INDEX `uk_user_name` (`user_name`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 3 + CHARACTER SET = utf8 + COLLATE = utf8_general_ci + ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for user_role_info -- ---------------------------- + CREATE TABLE IF NOT EXISTS `user_role_info` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -439,12 +466,17 @@ CREATE TABLE IF NOT EXISTS `user_role_info` `role_code` varchar(32) NOT NULL, `role_description` varchar(255) NOT NULL, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_role_name` (`role_name` ASC) USING BTREE -); + UNIQUE INDEX `uk_role_name` (`role_name`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 4 + CHARACTER SET = utf8 + COLLATE = utf8_general_ci + ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for user_role_rel -- ---------------------------- + CREATE TABLE IF NOT EXISTS `user_role_rel` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -454,15 +486,20 @@ CREATE TABLE IF NOT EXISTS `user_role_rel` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_project_role` (`user_id` ASC, `role_id` ASC, `project_id` ASC) USING BTREE, - INDEX `idx_user_id` (`user_id` ASC) USING BTREE, - INDEX `idx_role_id` (`role_id` ASC) USING BTREE, - INDEX `idx_project_id` (`project_id` ASC) USING BTREE -); + UNIQUE INDEX `uk_project_role` (`user_id`, `role_id`, `project_id`) USING BTREE, + INDEX `idx_user_id` (`user_id`) USING BTREE, + INDEX `idx_role_id` (`role_id`) USING BTREE, + INDEX `idx_project_id` (`project_id`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 5 + CHARACTER SET = utf8 + COLLATE = utf8_general_ci + ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for view_config -- ---------------------------- + CREATE TABLE IF NOT EXISTS `view_config` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'PK', @@ -473,5 +510,5 @@ CREATE TABLE IF NOT EXISTS `view_config` `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_config_name` (`config_name` ASC, `owner_id` ASC, `project_id` ASC) USING BTREE + UNIQUE INDEX `uk_config_name` (`config_name`, `owner_id`, `project_id`) USING BTREE ); From 87ef619ff17b47ac62fbd10bc1a0e4d6f5f16299 Mon Sep 17 00:00:00 2001 From: DreamlandLiu <205407@qq.com> Date: Wed, 23 Nov 2022 11:21:18 +0800 Subject: [PATCH 3/3] add copyright --- .../v0_3_2/V0_3_2_001__create_schema.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql index 7ae50bdca9..72be739936 100644 --- a/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql +++ b/server/controller/src/main/resources/db/migration/v0_3_2/V0_3_2_001__create_schema.sql @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Starwhale, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + -- ---------------------------- -- Table structure for agent_info -- ----------------------------