`TableMetadataStorage->complete` generates invalid SQL for Oracle when applying a new migration
wayne530 opened this issue · 1 comments
wayne530 commented
PHP 8.1.20
Oracle 10.x
doctrine/doctrine-migrations-bundle 3.2.4
doctrine/migrations 3.6.0
Repro steps:
- Create a new blank migration
- Populate
up
anddown
with something simple - add a column, remove a column, etc - Execute the migration with
--up
Expected:
The migration successfully executes and a new row is added to doctrine_migration_versions
for the newly applied migration.
Actual:
[error] Migration App\Migrations\Version20230721185327 failed during Post-Checks. Error: "An exception occurred while executing a query: ORA-01843: not a valid month"
In ExceptionConverter.php line 72:
[Doctrine\DBAL\Exception\DriverException (1843)]
An exception occurred while executing a query: ORA-01843: not a valid month
In investigating the issue more closely, I believe the issue is that we are passing the string 2023-07-21 14:28:06
as the second insert parameter, resulting in the following query:
insert into doctrine_migration_versions (version, executed_at, execution_time) values ('App\Migrations\Version20230721185327', '2023-07-21 14:28:06', 203);
which is invalid. The correct SQL statement would look like the following:
insert into doctrine_migration_versions (version, executed_at, execution_time) values ('App\Migrations\Version20230721185327', to_timestamp('2023-07-21 14:28:06', 'YYYY-MM-DD HH24:MI:SS'), 203);
--down
works fine because it simply deletes any existing rows.
wayne530 commented
This appears to be a doctrine/dbal
issue as this code relies on DBAL\Connection->insert()
.
Please see doctrine/dbal#6128.