-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.sql
More file actions
59 lines (48 loc) · 3.38 KB
/
Copy pathfix.sql
File metadata and controls
59 lines (48 loc) · 3.38 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- Event ID
SET @new_event_id = (SELECT MAX(event_id) + 1 FROM events);
SET @query = CONCAT('ALTER TABLE events MODIFY COLUMN event_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_event_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- State ID
SET @new_state_id = (SELECT MAX(state_id) + 1 FROM states);
SET @query = CONCAT('ALTER TABLE states MODIFY COLUMN state_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_state_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Recorder Runs
SET @new_run_id = (SELECT MAX(run_id) + 1 FROM recorder_runs);
SET @query = CONCAT('ALTER TABLE recorder_runs MODIFY COLUMN run_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_run_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Schema Changes
SET @new_change_id = (SELECT MAX(change_id) + 1 FROM schema_changes);
SET @query = CONCAT('ALTER TABLE schema_changes MODIFY COLUMN change_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_change_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- State Attributes
SET @new_attributes_id = (SELECT MAX(attributes_id) + 1 FROM state_attributes);
SET @query = CONCAT('ALTER TABLE state_attributes MODIFY COLUMN attributes_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_attributes_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Statistics
SET @new_statistics_id = (SELECT MAX(id) + 1 FROM statistics);
SET @query = CONCAT('ALTER TABLE statistics MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_statistics_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Statistics Meta
SET @new_statistics_meta_id = (SELECT MAX(id) + 1 FROM statistics_meta);
SET @query = CONCAT('ALTER TABLE statistics_meta MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_statistics_meta_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Event Data
SET @new_data_id = (SELECT MAX(data_id) + 1 FROM event_data);
SET @query = CONCAT('ALTER TABLE event_data MODIFY COLUMN data_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_data_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Statistics Runs
SET @new_statistics_run_id = (SELECT MAX(run_id) + 1 FROM statistics_runs);
SET @query = CONCAT('ALTER TABLE statistics_runs MODIFY COLUMN run_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_statistics_run_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Statistics Short Term
SET @new_statistics_short_term_id = (SELECT MAX(id) + 1 FROM statistics_short_term);
SET @query = CONCAT('ALTER TABLE statistics_short_term MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_statistics_short_term_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- States Meta
SET @new_metadata_id = (SELECT MAX(metadata_id) + 1 FROM states_meta);
SET @query = CONCAT('ALTER TABLE states_meta MODIFY COLUMN metadata_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_metadata_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Event Types
SET @new_event_type_id = (SELECT MAX(event_type_id) + 1 FROM event_types);
SET @query = CONCAT('ALTER TABLE event_types MODIFY COLUMN event_type_id INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=', @new_event_type_id);
PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;