1.37->1.36->1.37 fail

Current Development version likely to have breaking changes
Post Reply
dougmccrary
Posts: 1172
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

1.37->1.36->1.37 fail

Post by dougmccrary »

So, to check something, I went from 1.37 back to 1.36.
Now, trying to go back to 1.37:

Code: Select all

Database successfully upgraded to version 1.37.27.^M
Upgrading DB to 1.37.28 from 1.36.33^M
ERROR 1050 (42S01) at line 17: Table 'Snapshots_Events' already exists^M
Output: Checking for Snapshot_Events table^M
Checking for Snapshot_Events table^M
Command 'mysql --defaults-file=/etc/mysql/debian.cnf -hlocalhost zm < /usr/share/zoneminder/db/zm_update-1.37.28.sql' exited with status: 1^M
Error updating db.^M
dpkg: error processing package zoneminder (--configure):^M
 installed zoneminder package post-installation script subprocess returned error exit status 1^M
I don't understand what it's doing or how to fix it...help?
This on Ubuntu 22.04 minimal desktop.
User avatar
makers_mark
Posts: 18
Joined: Sun Jul 05, 2020 7:23 pm

Re: 1.37->1.36->1.37 fail

Post by makers_mark »

dougmccrary wrote: Wed Jun 07, 2023 3:26 am So, to check something, I went from 1.37 back to 1.36.
Now, trying to go back to 1.37:

Code: Select all

Database successfully upgraded to version 1.37.27.^M
Upgrading DB to 1.37.28 from 1.36.33^M
ERROR 1050 (42S01) at line 17: Table 'Snapshots_Events' already exists^M
Output: Checking for Snapshot_Events table^M
Checking for Snapshot_Events table^M
Command 'mysql --defaults-file=/etc/mysql/debian.cnf -hlocalhost zm < /usr/share/zoneminder/db/zm_update-1.37.28.sql' exited with status: 1^M
Error updating db.^M
dpkg: error processing package zoneminder (--configure):^M
 installed zoneminder package post-installation script subprocess returned error exit status 1^M
I don't understand what it's doing or how to fix it...help?
This on Ubuntu 22.04 minimal desktop.
You can see the zm_update-1.37.28.sql file here:
https://github.com/ZoneMinder/zoneminde ... .37.28.sql
What it's doing is simply renaming a table in the database from 'Snapshot_Events' to 'Snapshots_Events', note the extra 's'. Since you downgraded then went to upgrade back using the same database, you have both of them. So the renaming in the sql update file fails because the new table name already exists.
To fix it, there are lots of ways. Do you use snapshots? It seems like this is just a testing ground server for you, and if not, you should always backup your zm database before doing something like that. It's one simple line to execute.
One way to fix this is to go to the file /usr/share/zoneminder/db/zm_update-1.37.28.sql and insert this line towards the top:

Code: Select all

DROP TABLE IF EXISTS Snapshots_Events;
Or drop the pre-1.37.28 one by changing the above to ....'Snapshot_Events'.

Just know what your doing if you use or rely on snapshots in some way.

Example to change it to drop 'Snapshot_Events':

Code: Select all

--
-- Rename Snapshot_Events to Snapshots_Events
--
DROP TABLE IF EXISTS Snapshot_Events; 
SELECT 'Checking for Snapshot_Events table';
SET @s = (SELECT IF(
  (SELECT COUNT(*)
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE table_name = 'Snapshot_Events'
  AND table_schema = DATABASE()
  ) > 0,
"ALTER TABLE `Snapshot_Events` RENAME TO `Snapshots_Events`",
"SELECT 'Snapshot_Events doesnt exist, good.'"
));

PREPARE stmt FROM @s;
EXECUTE stmt;
dougmccrary
Posts: 1172
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: 1.37->1.36->1.37 fail

Post by dougmccrary »

Thanks! Got me on track.

What I saw (while in 1.34....) was Snapshot_Events and Snapshots.
Deleted Snapshot_Events table and update to 1.37.40 was successful. Wound up with just Snapshots.
Post Reply