-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database upgrade from old part-db #67
Comments
I solved this problem. One of my users has the group_id 0. After i changed it to 2 in my sqldump, this problem is fixed, but i have a new problem:
Migration 20190902140506 failed during Execution. Error An exception occurred while executing 'ALTER TABLE groups ADD not_selectable TINYINT(1) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE perms_labels perms_labels INT NOT NULL, CHANGE last_modified last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL': SQLSTATE[42S22]: Column not found: 1054 Unknown column 'perms_labels' in 'groups' In AbstractMySQLDriver.php line 60: An exception occurred while executing 'ALTER TABLE groups ADD not_selectable TINYINT(1) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE comment SQLSTATE[42S22]: Column not found: 1054 Unknown column 'perms_labels' in 'groups' In PDOConnection.php line 83: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'perms_labels' in 'groups' In PDOConnection.php line 78: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'perms_labels' in 'groups' |
I changed line 178 in Version20190902140506.php, so that the column perms_labels is added: $this->addSql('ALTER TABLE groups ADD not_selectable TINYINT(1) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, add perms_labels INT NOT NULL, CHANGE last_modified last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL'); With this change the migration was successfull. Do i need the column perms_labels in the table groups? |
From which old Part-DB version has you upgraded? Could you send me a dump of the database (before upgrade)? I guess there is something not the way the migrations expect it. Also when an exception happens during the migrations, you should import your backup, to start over freshly. It is really difficult to debug migrations that was only partly done (and MySQL does not support transactions for schema changes, so there is no way to revert the changes automatically). |
I have sent you an email. I guess this is an issue specific to your database, therefore I am closing this issue. |
I think the problem is, that my first Part-DB-Version was 0.59 or 0.6. When the old version creates the database in Part-DB/updates/db_update_steps.php Because of this, there are several differences between my database and the database, which you expect with version 26. |
Describe the bug
I tried an upgrade from the old part-db-version, but it doesn't work. At some time i get an error message, see below. I also tried to drop the database and restore the backup, but the migration also didn't work.
Server Side
Additional context
pi@raspberrypi:/var/www/part-db $ php bin/console doctrine:migrations:migrate
WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)y
Migrating up to 20200502161750 from 0
++ migrating 1 (Creates an inital empty database)
SS skipped (Reason: Old Part-DB Database detected! Continue with upgrade...)
++ migrating 20190902140506 (Upgrade database from old Part-DB 0.5 Version (dbVersion 26))
Migration 20190902140506 failed during Execution. Error An exception occurred while executing 'ALTER TABLE users ADD CONSTRAINT FK_1483A5E9FE54D947 FOREIGN KEY (group_id) REFERENCES
groups
(id)':SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
partdb
.#sql-2fec_40
, CONSTRAINTFK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
))13:03:30 ERROR [console] Error thrown while running command "doctrine:migrations:migrate". Message: "An exception occurred while executing 'ALTER TABLE users ADD CONSTRAINT FK_1483A5E9FE54D947 FOREIGN KEY (group_id) REFERENCES
groups
(id)':\n\nSQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (partdb
.#sql-2fec_40
, CONSTRAINTFK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
))" ["exception" => Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException^ { …},"command" => "doctrine:migrations:migrate","message" => """ An exception occurred while executing 'ALTER TABLE users ADD CONSTRAINT FK_1483A5E9FE54D947 FOREIGN KEY (group_id) REFERENCESgroups
(id)':\n \n SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (partdb
.#sql-2fec_40
, CONSTRAINTFK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
)) """]In AbstractMySQLDriver.php line 49:
An exception occurred while executing 'ALTER TABLE users ADD CONSTRAINT FK_1483A5E9FE54D947 FOREIGN KEY (group_id) REFERENCES
groups
(id)':SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
partdb
.#sql-2fec_40
, CONSTRAINT
FK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
))In PDOConnection.php line 83:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
partdb
.#sql-2fec_40
, CONSTRAINT
FK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
))In PDOConnection.php line 78:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
partdb
.#sql-2fec_40
, CONSTRAINT
FK_1483A5E9FE54D947
FOREIGN KEY (group_id
) REFERENCESgroups
(id
))doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] []
pi@raspberrypi:/var/www/part-db $ php bin/console doctrine:migrations:migrate
WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)y
Migrating up to 20200502161750 from 1
++ migrating 20190902140506 (Upgrade database from old Part-DB 0.5 Version (dbVersion 26))
Migration 20190902140506 failed during Execution. Error An exception occurred while executing 'RENAME TABLE
attachement_types
TOattachment_types
;':SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists
13:04:44 ERROR [console] Error thrown while running command "doctrine:migrations:migrate". Message: "An exception occurred while executing 'RENAME TABLE
attachement_types
TOattachment_types
;':\n\nSQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists" ["exception" => Doctrine\DBAL\Exception\TableExistsException^ { …},"command" => "doctrine:migrations:migrate","message" => """ An exception occurred while executing 'RENAME TABLEattachement_types
TOattachment_types
;':\n \n SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists """]In AbstractMySQLDriver.php line 38:
An exception occurred while executing 'RENAME TABLE
attachement_types
TOattachment_types
;':SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists
In PDOConnection.php line 83:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists
In PDOConnection.php line 78:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachment_types' already exists
doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] []
The text was updated successfully, but these errors were encountered: