Skip to content

Commit c5c7f2f

Browse files
committed
Fix SQL script errors and missing
1 parent 2d91534 commit c5c7f2f

8 files changed

Lines changed: 61 additions & 647 deletions

File tree

sql/mysql/destroy.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
delete from sys_menu where name in ('AddApiKey', 'EditApiKey', 'DeleteApiKey');
2+
3+
delete from sys_menu where name = 'PluginApiKey';
4+
5+
drop table if exists sys_api_key;

sql/mysql/destroy_snowflake.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
delete from sys_menu where name in ('AddApiKey', 'EditApiKey', 'DeleteApiKey');
2+
3+
delete from sys_menu where name = 'PluginApiKey';
4+
5+
drop table if exists sys_api_key;

sql/mysql/init.sql

Lines changed: 9 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,12 @@
1-
INSERT INTO sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
2-
SELECT
3-
'api_key.menu',
4-
'PluginApiKey',
5-
'/plugins/api-key',
6-
11,
7-
'mdi:key-outline',
8-
1,
9-
'/plugins/api_key/views/index',
10-
NULL,
11-
1,
12-
1,
13-
1,
14-
'',
15-
'API Key 管理',
16-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'System' LIMIT 1) AS tmp_parent),
17-
CURRENT_TIMESTAMP,
18-
CURRENT_TIMESTAMP
19-
FROM DUAL
20-
WHERE NOT EXISTS (
21-
SELECT 1 FROM sys_menu WHERE name = 'PluginApiKey'
22-
);
1+
set @system_menu_id = (select id from sys_menu where name = 'System');
232

24-
UPDATE sys_menu
25-
SET
26-
title = 'api_key.menu',
27-
path = '/plugins/api-key',
28-
sort = 11,
29-
icon = 'mdi:key-outline',
30-
type = 1,
31-
component = '/plugins/api_key/views/index',
32-
perms = NULL,
33-
status = 1,
34-
display = 1,
35-
cache = 1,
36-
link = '',
37-
remark = 'API Key 管理',
38-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'System' LIMIT 1) AS tmp_parent),
39-
updated_time = CURRENT_TIMESTAMP
40-
WHERE name = 'PluginApiKey';
3+
insert into sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
4+
values ('api_key.menu', 'PluginApiKey', '/plugins/api-key', 11, 'mdi:key-outline', 1, '/plugins/api_key/views/index', null, 1, 1, 1, '', 'API Key 管理', @system_menu_id, now(), null);
415

42-
INSERT INTO sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
43-
SELECT
44-
'新增',
45-
'AddApiKey',
46-
NULL,
47-
0,
48-
NULL,
49-
2,
50-
NULL,
51-
'sys:apikey:add',
52-
1,
53-
0,
54-
1,
55-
'',
56-
NULL,
57-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
58-
CURRENT_TIMESTAMP,
59-
CURRENT_TIMESTAMP
60-
FROM DUAL
61-
WHERE NOT EXISTS (
62-
SELECT 1 FROM sys_menu WHERE name = 'AddApiKey'
63-
);
6+
set @api_key_menu_id = LAST_INSERT_ID();
647

65-
UPDATE sys_menu
66-
SET
67-
title = '新增',
68-
path = NULL,
69-
sort = 0,
70-
icon = NULL,
71-
type = 2,
72-
component = NULL,
73-
perms = 'sys:apikey:add',
74-
status = 1,
75-
display = 0,
76-
cache = 1,
77-
link = '',
78-
remark = NULL,
79-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
80-
updated_time = CURRENT_TIMESTAMP
81-
WHERE name = 'AddApiKey';
82-
83-
INSERT INTO sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
84-
SELECT
85-
'修改',
86-
'EditApiKey',
87-
NULL,
88-
0,
89-
NULL,
90-
2,
91-
NULL,
92-
'sys:apikey:edit',
93-
1,
94-
0,
95-
1,
96-
'',
97-
NULL,
98-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
99-
CURRENT_TIMESTAMP,
100-
CURRENT_TIMESTAMP
101-
FROM DUAL
102-
WHERE NOT EXISTS (
103-
SELECT 1 FROM sys_menu WHERE name = 'EditApiKey'
104-
);
105-
106-
UPDATE sys_menu
107-
SET
108-
title = '修改',
109-
path = NULL,
110-
sort = 0,
111-
icon = NULL,
112-
type = 2,
113-
component = NULL,
114-
perms = 'sys:apikey:edit',
115-
status = 1,
116-
display = 0,
117-
cache = 1,
118-
link = '',
119-
remark = NULL,
120-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
121-
updated_time = CURRENT_TIMESTAMP
122-
WHERE name = 'EditApiKey';
123-
124-
INSERT INTO sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
125-
SELECT
126-
'删除',
127-
'DeleteApiKey',
128-
NULL,
129-
0,
130-
NULL,
131-
2,
132-
NULL,
133-
'sys:apikey:del',
134-
1,
135-
0,
136-
1,
137-
'',
138-
NULL,
139-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
140-
CURRENT_TIMESTAMP,
141-
CURRENT_TIMESTAMP
142-
FROM DUAL
143-
WHERE NOT EXISTS (
144-
SELECT 1 FROM sys_menu WHERE name = 'DeleteApiKey'
145-
);
146-
147-
UPDATE sys_menu
148-
SET
149-
title = '删除',
150-
path = NULL,
151-
sort = 0,
152-
icon = NULL,
153-
type = 2,
154-
component = NULL,
155-
perms = 'sys:apikey:del',
156-
status = 1,
157-
display = 0,
158-
cache = 1,
159-
link = '',
160-
remark = NULL,
161-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
162-
updated_time = CURRENT_TIMESTAMP
163-
WHERE name = 'DeleteApiKey';
8+
insert into sys_menu (title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
9+
values
10+
('新增', 'AddApiKey', null, 0, null, 2, null, 'sys:apikey:add', 1, 0, 1, '', null, @api_key_menu_id, now(), null),
11+
('修改', 'EditApiKey', null, 0, null, 2, null, 'sys:apikey:edit', 1, 0, 1, '', null, @api_key_menu_id, now(), null),
12+
('删除', 'DeleteApiKey', null, 0, null, 2, null, 'sys:apikey:del', 1, 0, 1, '', null, @api_key_menu_id, now(), null);

sql/mysql/init_snowflake.sql

Lines changed: 8 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,8 @@
1-
INSERT INTO sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
2-
SELECT
3-
2049629108257816589,
4-
'api_key.menu',
5-
'PluginApiKey',
6-
'/plugins/api-key',
7-
11,
8-
'mdi:key-outline',
9-
1,
10-
'/plugins/api_key/views/index',
11-
NULL,
12-
1,
13-
1,
14-
1,
15-
'',
16-
'API Key 管理',
17-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'System' LIMIT 1) AS tmp_parent),
18-
CURRENT_TIMESTAMP,
19-
CURRENT_TIMESTAMP
20-
FROM DUAL
21-
WHERE NOT EXISTS (
22-
SELECT 1 FROM sys_menu WHERE name = 'PluginApiKey'
23-
);
24-
25-
UPDATE sys_menu
26-
SET
27-
title = 'api_key.menu',
28-
path = '/plugins/api-key',
29-
sort = 11,
30-
icon = 'mdi:key-outline',
31-
type = 1,
32-
component = '/plugins/api_key/views/index',
33-
perms = NULL,
34-
status = 1,
35-
display = 1,
36-
cache = 1,
37-
link = '',
38-
remark = 'API Key 管理',
39-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'System' LIMIT 1) AS tmp_parent),
40-
updated_time = CURRENT_TIMESTAMP
41-
WHERE name = 'PluginApiKey';
42-
43-
INSERT INTO sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
44-
SELECT
45-
2049629108257816590,
46-
'新增',
47-
'AddApiKey',
48-
NULL,
49-
0,
50-
NULL,
51-
2,
52-
NULL,
53-
'sys:apikey:add',
54-
1,
55-
0,
56-
1,
57-
'',
58-
NULL,
59-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
60-
CURRENT_TIMESTAMP,
61-
CURRENT_TIMESTAMP
62-
FROM DUAL
63-
WHERE NOT EXISTS (
64-
SELECT 1 FROM sys_menu WHERE name = 'AddApiKey'
65-
);
66-
67-
UPDATE sys_menu
68-
SET
69-
title = '新增',
70-
path = NULL,
71-
sort = 0,
72-
icon = NULL,
73-
type = 2,
74-
component = NULL,
75-
perms = 'sys:apikey:add',
76-
status = 1,
77-
display = 0,
78-
cache = 1,
79-
link = '',
80-
remark = NULL,
81-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
82-
updated_time = CURRENT_TIMESTAMP
83-
WHERE name = 'AddApiKey';
84-
85-
INSERT INTO sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
86-
SELECT
87-
2049629108257816591,
88-
'修改',
89-
'EditApiKey',
90-
NULL,
91-
0,
92-
NULL,
93-
2,
94-
NULL,
95-
'sys:apikey:edit',
96-
1,
97-
0,
98-
1,
99-
'',
100-
NULL,
101-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
102-
CURRENT_TIMESTAMP,
103-
CURRENT_TIMESTAMP
104-
FROM DUAL
105-
WHERE NOT EXISTS (
106-
SELECT 1 FROM sys_menu WHERE name = 'EditApiKey'
107-
);
108-
109-
UPDATE sys_menu
110-
SET
111-
title = '修改',
112-
path = NULL,
113-
sort = 0,
114-
icon = NULL,
115-
type = 2,
116-
component = NULL,
117-
perms = 'sys:apikey:edit',
118-
status = 1,
119-
display = 0,
120-
cache = 1,
121-
link = '',
122-
remark = NULL,
123-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
124-
updated_time = CURRENT_TIMESTAMP
125-
WHERE name = 'EditApiKey';
126-
127-
INSERT INTO sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
128-
SELECT
129-
2049629108257816592,
130-
'删除',
131-
'DeleteApiKey',
132-
NULL,
133-
0,
134-
NULL,
135-
2,
136-
NULL,
137-
'sys:apikey:del',
138-
1,
139-
0,
140-
1,
141-
'',
142-
NULL,
143-
(SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
144-
CURRENT_TIMESTAMP,
145-
CURRENT_TIMESTAMP
146-
FROM DUAL
147-
WHERE NOT EXISTS (
148-
SELECT 1 FROM sys_menu WHERE name = 'DeleteApiKey'
149-
);
150-
151-
UPDATE sys_menu
152-
SET
153-
title = '删除',
154-
path = NULL,
155-
sort = 0,
156-
icon = NULL,
157-
type = 2,
158-
component = NULL,
159-
perms = 'sys:apikey:del',
160-
status = 1,
161-
display = 0,
162-
cache = 1,
163-
link = '',
164-
remark = NULL,
165-
parent_id = (SELECT id FROM (SELECT id FROM sys_menu WHERE name = 'PluginApiKey' LIMIT 1) AS tmp_parent),
166-
updated_time = CURRENT_TIMESTAMP
167-
WHERE name = 'DeleteApiKey';
1+
insert into sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
2+
values (2147651050620981248, 'api_key.menu', 'PluginApiKey', '/plugins/api-key', 11, 'mdi:key-outline', 1, '/plugins/api_key/views/index', null, 1, 1, 1, '', 'API Key 管理', (select id from sys_menu where name = 'System' limit 1), now(), null);
3+
4+
insert into sys_menu (id, title, name, path, sort, icon, type, component, perms, status, display, cache, link, remark, parent_id, created_time, updated_time)
5+
values
6+
(2147651050625175552, '新增', 'AddApiKey', null, 0, null, 2, null, 'sys:apikey:add', 1, 0, 1, '', null, 2147651050620981248, now(), null),
7+
(2147651050629369856, '修改', 'EditApiKey', null, 0, null, 2, null, 'sys:apikey:edit', 1, 0, 1, '', null, 2147651050620981248, now(), null),
8+
(2147651050633564160, '删除', 'DeleteApiKey', null, 0, null, 2, null, 'sys:apikey:del', 1, 0, 1, '', null, 2147651050620981248, now(), null);

sql/postgresql/destroy.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
delete from sys_menu where name in ('AddApiKey', 'EditApiKey', 'DeleteApiKey');
2+
3+
delete from sys_menu where name = 'PluginApiKey';
4+
5+
drop table if exists sys_api_key;
6+
7+
select setval(pg_get_serial_sequence('sys_menu', 'id'), coalesce(max(id), 0) + 1, true) from sys_menu;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
delete from sys_menu where name in ('AddApiKey', 'EditApiKey', 'DeleteApiKey');
2+
3+
delete from sys_menu where name = 'PluginApiKey';
4+
5+
drop table if exists sys_api_key;

0 commit comments

Comments
 (0)