doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 387 forks source link

Migrations return an error message when running doctrine:migrations:migrate [Oracle database] #1417

Closed marcelowzd closed 3 months ago

marcelowzd commented 3 months ago

Bug Report

When trying to execute the migrations created by Doctrine on Oracle database, the CLI tool returns the error "An exception occurred while executing a query: ORA-01843: not a valid month".

I'm currently using Symfony 7 with the following composer packages related to doctrine: "doctrine/dbal": "^3", "doctrine/doctrine-bundle": "^2.11", "doctrine/doctrine-migrations-bundle": "^3.3", "doctrine/orm": "^3.1",

Oracle database version is 12c (12.1.0.2.0)

EDIT

The problem also happens when trying to persist an entity that has a TIMESTAMP column.

Summary

It's not possible to run any migrations for any entities managed by doctrine because when it tries to insert into the table "DOCTRINE_MIGRATION_VERSIONS", which has a timestmap(0) column, the error shown above occurs.

Current behaviour

While trying to run migrations, an error is shown.

How to reproduce

  1. Create a simple entity called "test" with just one field of type string which will be managed by doctrine;
  2. Run php bin/console make:migration (Symfony);
  3. Run php bin/console doctrine:migrations:migrate;
  4. Error shown.

Expected behaviour

No errors while running migrations

derrabus commented 3 months ago

Do you use the Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession middleware?

marcelowzd commented 3 months ago

Do you use the Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession middleware?

No, i wasn't. After adding the configuration to services.yaml, it now works perfectly.

I'll leave the solution here in case anyone needs it.

oracle.listener: class: Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession tags:

Thanks for the fast reply!

derrabus commented 3 months ago

The tag doesn't make sense though. 😬