-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path6.AUTH_RENAME_COLUMNS.sql
41 lines (37 loc) · 1.14 KB
/
6.AUTH_RENAME_COLUMNS.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
DROP PROCEDURE IF EXISTS change_column_name;
DELIMITER //
CREATE PROCEDURE change_column_name()
BEGIN
IF EXISTS(SELECT NULL
FROM information_schema.columns
WHERE table_schema = database()
AND table_name = 'account_access'
AND column_name = 'SecurityLevel'
)
THEN
ALTER TABLE account_access CHANGE SecurityLevel gmlevel tinyint(3) unsigned;
END IF;
IF EXISTS(SELECT NULL
FROM information_schema.columns
WHERE table_schema = database()
AND table_name = 'account_access'
AND column_name = 'AccountID'
)
THEN
ALTER TABLE account_access CHANGE AccountID id int(10) unsigned;
END IF;
IF EXISTS(SELECT NULL
FROM information_schema.columns
WHERE table_schema = database()
AND table_name = 'account'
AND column_name = 'session_key_auth'
)
THEN
ALTER TABLE account CHANGE session_key_auth session_key binary(40);
END IF;
END;
//
DELIMITER ;
CALL change_column_name();
DROP PROCEDURE change_column_name;
ALTER TABLE account DROP COLUMN session_key_bnet;