From 7daedeba21b038b309f97e5571208128af8a19bc Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Wed, 28 Aug 2024 17:04:30 +0800 Subject: [PATCH] [Fix][admin] Fix the SQL auto initialization issue of PG (#3756) Signed-off-by: Zzm0809 <934230207@qq.com> --- .../pgsql/V20240506.1.0.2__baseline.sql | 3 -- .../pgsql/V20240729.1.1.0__release.sql | 20 ++++++------- .../pgsql/V20240827.1.1.1__release.sql | 30 +++++++++++++++++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/dinky-admin/src/main/resources/db/migration/pgsql/V20240506.1.0.2__baseline.sql b/dinky-admin/src/main/resources/db/migration/pgsql/V20240506.1.0.2__baseline.sql index baa91d8e1f..8cfd7b2dee 100644 --- a/dinky-admin/src/main/resources/db/migration/pgsql/V20240506.1.0.2__baseline.sql +++ b/dinky-admin/src/main/resources/db/migration/pgsql/V20240506.1.0.2__baseline.sql @@ -3440,7 +3440,6 @@ EXECUTE FUNCTION trigger_set_timestamp(); -- ---------------------------- -- Records of public.dinky_sys_menu -- ---------------------------- -BEGIN; -- insert into public.dinky_sys_menu -- values (1, -1, '首页', '/home', './Home', 'home', 'HomeOutlined', 'C', 0, 1, '2023-08-11 14:06:52', -- '2023-09-25 18:26:45', null); @@ -3891,8 +3890,6 @@ insert into public.dinky_sys_menu values (156, 150, ' 刷新', '/registration/datasource/detail/refresh', null, 'registration:datasource:detail:refresh', 'ReloadOutlined', 'F', 0, 154, '2024-01-18 22:13:47', '2024-01-18 22:13:47', null); -COMMIT; - -- ---------------------------- -- Table structure for public.dinky_sys_role_menu diff --git a/dinky-admin/src/main/resources/db/migration/pgsql/V20240729.1.1.0__release.sql b/dinky-admin/src/main/resources/db/migration/pgsql/V20240729.1.1.0__release.sql index 775b52af87..64bfa0b9f2 100644 --- a/dinky-admin/src/main/resources/db/migration/pgsql/V20240729.1.1.0__release.sql +++ b/dinky-admin/src/main/resources/db/migration/pgsql/V20240729.1.1.0__release.sql @@ -1,11 +1,11 @@ -INSERT INTO public.dinky_sys_menu (parent_id, name, path, component, perms, icon, type, display, order_num, create_time, +INSERT INTO public.dinky_sys_menu (id,parent_id, name, path, component, perms, icon, type, display, order_num, create_time, update_time, note) -VALUES (-1, '工作台', '/home', './Home', 'home', 'HomeOutlined', 'C', 0, 1, '2024-07-29 11:53:38', +VALUES (157, -1, '工作台', '/home', './Home', 'home', 'HomeOutlined', 'C', 0, 1, '2024-07-29 11:53:38', '2024-07-29 11:53:38', NULL); -INSERT INTO public.dinky_sys_menu (parent_id, name, path, component, perms, icon, type, display, order_num, +INSERT INTO public.dinky_sys_menu (id,parent_id, name, path, component, perms, icon, type, display, order_num, create_time, update_time, note) -VALUES (164, '仪表盘列表', '/dashboard/list', './Dashboard', 'dashboard:list', 'UnorderedListOutlined', 'F', 0, 167, +VALUES (158 ,164, '仪表盘列表', '/dashboard/list', './Dashboard', 'dashboard:list', 'UnorderedListOutlined', 'F', 0, 167, '2024-07-29 15:37:46', '2024-07-29 15:37:46', NULL); UPDATE public.dinky_sys_menu @@ -25,15 +25,15 @@ SET path = '/dashboard/list/view', perms='dashboard:list:view' WHERE path = '/dashboard/view'; -INSERT INTO public.dinky_sys_menu (parent_id, name, path, component, perms, icon, type, display, order_num, +INSERT INTO public.dinky_sys_menu (id,parent_id, name, path, component, perms, icon, type, display, order_num, create_time, update_time, note) -VALUES (164, '看板布局', '/dashboard/dashboard-layout', './Dashboard/DashboardLayout', 'dashboard:dashboard-layout', +VALUES (159, 164, '看板布局', '/dashboard/dashboard-layout', './Dashboard/DashboardLayout', 'dashboard:dashboard-layout', 'DashboardOutlined', 'F', 0, 168, '2024-07-29 16:16:45', '2024-07-29 16:17:28', NULL); -INSERT INTO public.dinky_sys_menu (parent_id, name, path, component, perms, icon, type, display, order_num, +INSERT INTO public.dinky_sys_menu (id,parent_id, name, path, component, perms, icon, type, display, order_num, create_time, update_time, note) -VALUES (164, '添加看板', '/dashboard/chart/add', NULL, 'dashboard:chart:add', 'AreaChartOutlined', 'F', 0, 167, +VALUES (160, 164, '添加看板', '/dashboard/chart/add', NULL, 'dashboard:chart:add', 'AreaChartOutlined', 'F', 0, 167, '2024-06-21 10:53:33', '2024-06-21 10:53:33', NULL); -INSERT INTO public.dinky_sys_menu (parent_id, name, path, component, perms, icon, type, display, order_num, +INSERT INTO public.dinky_sys_menu (id,parent_id, name, path, component, perms, icon, type, display, order_num, create_time, update_time, note) -VALUES (164, '修改看板', '/dashboard/chart/edit', NULL, 'dashboard:chart:edit', 'BarChartOutlined', 'F', 0, 168, +VALUES (161, 164, '修改看板', '/dashboard/chart/edit', NULL, 'dashboard:chart:edit', 'BarChartOutlined', 'F', 0, 168, '2024-06-21 10:54:26', '2024-06-21 10:54:26', NULL); \ No newline at end of file diff --git a/dinky-admin/src/main/resources/db/migration/pgsql/V20240827.1.1.1__release.sql b/dinky-admin/src/main/resources/db/migration/pgsql/V20240827.1.1.1__release.sql index 96f0d88b98..b13d733631 100644 --- a/dinky-admin/src/main/resources/db/migration/pgsql/V20240827.1.1.1__release.sql +++ b/dinky-admin/src/main/resources/db/migration/pgsql/V20240827.1.1.1__release.sql @@ -7,7 +7,7 @@ CREATE OR REPLACE FUNCTION public.drop_index_if_exists( DECLARE index_exists int; BEGIN - -- 检查索引是否存在 + -- Check if the index exists SELECT count(*) INTO index_exists FROM pg_indexes @@ -23,4 +23,30 @@ END; $$ LANGUAGE plpgsql; -SELECT public.drop_index_if_exists('public', 'cluster_un_idx1', 'dinky_cluster'); \ No newline at end of file +SELECT public.drop_index_if_exists('public', 'cluster_un_idx1', 'dinky_cluster'); + + +CREATE TABLE IF NOT EXISTS public.dinky_dashboard +( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR(255), + remark TEXT, + chart_theme VARCHAR(255), + layouts TEXT, + create_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +COMMENT ON COLUMN public.dinky_dashboard.id IS 'ID'; +COMMENT ON COLUMN public.dinky_dashboard.name IS 'name'; +COMMENT ON COLUMN public.dinky_dashboard.remark IS 'remark'; +COMMENT ON COLUMN public.dinky_dashboard.chart_theme IS 'chart theme'; +COMMENT ON COLUMN public.dinky_dashboard.layouts IS 'layouts'; +COMMENT ON COLUMN public.dinky_dashboard.create_time IS 'create time'; +COMMENT ON COLUMN public.dinky_dashboard.update_time IS 'update time'; + +CREATE OR REPLACE TRIGGER update_dinky_dashboard_update_time + BEFORE UPDATE + ON public.dinky_dashboard + FOR EACH ROW +EXECUTE FUNCTION trigger_set_timestamp(); \ No newline at end of file