Environment
Executing the CLI migration:
fails with exit code 255 and the following generic exception:
The migration partially modifies the database but leaves the installed-version marker at 3.20.18.
The restored database contains:
The unmodified database-migrate command failed under both v4.5.5 and v4.5.8.
I then generated the migration SQL with:
and tested the generated statements against freshly restored copies of the original v3 database to identify the underlying SQL errors.
Their CREATE TABLE definitions already contain foreign key relationships.
Later in the same generated migration, seven additional statements attempt to add those same foreign keys.
For example:
MariaDB reports:
I confirmed using information_schema.REFERENTIAL_CONSTRAINTS and SHOW CREATE TABLE that the foreign keys already existed after the table creation.
This behavior is present in the SQL generated by both v4.5.5 and v4.5.8 from the restored v3 database.
That allowed execution to proceed further, where it failed on:
With:
The v4.5.8 schema already creates chv_tags_albums with that composite primary key, so the old named unique index does not exist.
There are corresponding migration statements for chv_tags_files and chv_tags_users.
Comparing the official v4.5.5, v4.5.7, and v4.5.8 packages:
I have not verified that the original v3 database schema is identical to a pristine v3.20.18 installation, so I can't conclusively rule out historical schema differences.
Questions:
- Source version: Chevereto Paid v3.20.18
- Target versions tested: Chevereto Pro v4.5.5 and v4.5.8
- OS: Ubuntu 22.04.5 LTS
- Web server: OpenLiteSpeed 1.8.3
- PHP: 8.2.35 (LSPHP)
- Database: MariaDB 10.6.23
- Database table prefix: chv_
- Installation type: Existing paid v3 installation, upgrading to v4 Pro
Problem
I'm attempting to upgrade an existing v3.20.18 installation to Chevereto Pro v4.5.8.Executing the CLI migration:
Bash:
php app/bin/cli -C database-migrate
Code:
LogicException in app/legacy/install/installer.php
Error executing the Chevereto update query.
>>>
Try running each of the following statements
in the database console to find the conflict.
Reproduction
To eliminate possible effects from a previous unsuccessful upgrade attempt, I created a separate test database and restored a January 2026 SQL backup of my working v3.20.18 installation.The restored database contains:
- 10,751 image records
- 129 albums
- 4 users
- chevereto_version_installed = 3.20.18
- No existing chv_tags_* tables or chv_variables table
The unmodified database-migrate command failed under both v4.5.5 and v4.5.8.
I then generated the migration SQL with:
Bash:
php app/bin/cli -C database-migrate -d
Finding 1: Duplicate foreign key constraints
The generated migration SQL creates these tables:
Code:
chv_tags_albums
chv_tags_files
chv_tags_users
Their CREATE TABLE definitions already contain foreign key relationships.
Later in the same generated migration, seven additional statements attempt to add those same foreign keys.
For example:
SQL:
ALTER TABLE `chv_tags_albums`
ADD CONSTRAINT `chv_tags_albums_ibfk_1`
FOREIGN KEY (tag_album_tag_id)
REFERENCES `chv_tags` (tag_id)
ON DELETE CASCADE;
Code:
ERROR 1005 (HY000):
Can't create table chevereto_recovery.chv_tags_albums
(errno: 121 "Duplicate key on write or update")
I confirmed using information_schema.REFERENTIAL_CONSTRAINTS and SHOW CREATE TABLE that the foreign keys already existed after the table creation.
This behavior is present in the SQL generated by both v4.5.5 and v4.5.8 from the restored v3 database.
Finding 2: Redundant primary-key migration in v4.5.8
As a diagnostic test only, I removed the seven duplicate foreign-key additions from a copy of the v4.5.8 migration SQL.That allowed execution to proceed further, where it failed on:
SQL:
ALTER TABLE `chv_tags_albums`
DROP INDEX tag_album_UNIQUE,
ADD PRIMARY KEY (
tag_album_tag_id,
tag_album_album_id,
tag_album_user_id
);
Code:
ERROR 1091 (42000):
Can't DROP INDEX `tag_album_UNIQUE`;
check that it exists
The v4.5.8 schema already creates chv_tags_albums with that composite primary key, so the old named unique index does not exist.
There are corresponding migration statements for chv_tags_files and chv_tags_users.
Comparing the official v4.5.5, v4.5.7, and v4.5.8 packages:
- v4.5.5 defines named UNIQUE indexes on these three tables.
- v4.5.7 and v4.5.8 instead define composite primary keys.
Expected behavior
A direct upgrade from v3.20.18 should generate a migration sequence that applies the necessary schema changes without recreating existing constraints or attempting to drop nonexistent indexes.Additional context
The source installation (a small, personal project/website installed and mantained by an idiot; that is, me) is 5+ years old and may have had historical DB customizations (I don't think I would have pushed any novice SQL changes to production, but it remains a nagging possibility). However, the same errors occur using a restored backup that predates my recent upgrade attempts.I have not verified that the original v3 database schema is identical to a pristine v3.20.18 installation, so I can't conclusively rule out historical schema differences.
Questions:
- Is this a known issue with direct v3 → v4 migrations, particularly under MariaDB 10.6?
- Are the duplicate foreign-key statements and tag-table primary-key alterations expected in the same generated migration?
- Is there a recommended intermediate upgrade path, or a supported workaround?
- Would it help if I provided redacted migration SQL, the relevant schema definitions, or additional CLI output?
