Closed RafaelKr closed 1 week ago
The sulu developers cleared this up to me. As we're just starting out we're able to clear our database and start it from scratch with the new identity default setting. https://github.com/sulu/sulu/issues/7663#issuecomment-2490358163
Issue
We started a new project with the Sulu CMS (https://github.com/sulu/sulu) using Postgres as our database.
Some time later we ran
composer recipes:update
and updateddoctrine/doctrine-bundle
. This update added those 2 lines to theconfig/packages/doctrine.yaml
:https://github.com/symfony/recipes/blob/b06f1ce2f7c3f7d5cb18fcce68c08a02cc1b271c/doctrine/doctrine-bundle/2.13/config/packages/doctrine.yaml#L17-L18
Now when trying to save anything which requires the generation of an identifier (creating a new entity, etc) we get errors like:
An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" of relation "the_table" violates not-null constraint
It seems like setting this config is only required after migrating to
doctrine/dbal
version 4: https://www.doctrine-project.org/projects/doctrine-dbal/en/stable/how-to/postgresql-identity-migration.html#migration-to-identity-columns-on-postgresqlThe Sulu project still uses
doctrine/dbal
version 3.93Reproduction
This can be quickly (~5 min) reproduced with the following steps:
admin
with passwordadmin
.If we now go back via the toolbar button the Snippet "Foo" should appear in the list.
To be able to do a recipe update we need to have a git repository. Initialize via inside the Sulu Terminal
Now we run (in the Sulu Terminal)
The output of git diff should show the new key
identity_generation_preferences
.If we now repeat the process of creating a snippet from above with the new name "Bar" Sulu will show "Error - There was an error when trying to save the form".
The network tab and the docker database logs (in the Postgres Terminal) will show a not-null constraint error:
ERROR: null value in column "id" of relation "ac_activities" violates not-null constraint
Clean up
Stop PHP in the Server Terminal (usually Ctrl+C on a Unix-like system)
In the Postgres Terminal:
Clean up docker container and its data (volume)
docker rm -v sulu-postgres
Delete postgres docker image
docker rmi postgres:16