Skip to content

Commit 61d8526

Browse files
Merge pull request #4506 from ZoneMinder/copilot/fix-orphaned-monitorid-field
Remove orphaned MonitorIds column from Users table
2 parents 6f89220 + 262da35 commit 61d8526

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

db/zm_update-1.37.76.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11

2+
--
3+
-- This updates a 1.37.75 database to 1.37.76
4+
--
5+
-- Remove the orphaned MonitorIds column from the Users table.
6+
-- This field was removed from zm_create.sql.in but was never dropped
7+
-- for existing installations. Data was migrated to Monitors_Permissions
8+
-- table in zm_update-1.37.27.sql
9+
--
10+
11+
SET @s = (SELECT IF(
12+
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
13+
AND table_name = 'Users'
14+
AND column_name = 'MonitorIds'
15+
) > 0
16+
,
17+
"ALTER TABLE Users DROP COLUMN MonitorIds",
18+
"SELECT 'Users MonitorIds column already removed.'"
19+
));
20+
21+
PREPARE stmt FROM @s;
22+
EXECUTE stmt;
23+
224
set @exist := (select count(*) from information_schema.statistics where table_name = 'Monitor_Status' and index_name = 'Monitor_Status_UpdatedOn_idx' and table_schema = database());
325
set @sqlstmt := if( @exist > 0, 'DROP INDEX Monitor_Status_UpdatedOn_idx ON Monitor_Status', "SELECT 'Monitor_Status_UpdatedOn_idx INDEX is already removed.'");
426
PREPARE stmt FROM @sqlstmt;

0 commit comments

Comments
 (0)