Unable to insert new Conference via CLI #54886
-
I got up to Customizing EasyAdmin and everything worked fine so far. I wanted to insert a new record into conference table (PostgreSQL):
I would love to get advice on why id is not incrementing itself while migration looks like this:
and what would be the proper way to insert new records via CLI into a table with autoincrementing id. I have thoroughly googled the subject and found a suggestion:
but found nothing similar in FastTrack. How do I properly create autoincrementing id via symfony console make:entity if possible at all? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your migration is weird 😅 Please provide the output of |
Beta Was this translation helpful? Give feedback.
-
Yeah, probably my thinking is weird as I never touched SF before ). I've checked id definitions and compared them with the file I downloaded from the repo, they look the same, at least here: What I did I changed id to this: |
Beta Was this translation helpful? Give feedback.
Ok so I think your original issue is that the sequence created by Doctrine is not used as
DEFAULT
for your ID, which would match doctrine/dbal#3619 (comment).Still, you should configure your strategy as
SEQUENCE
, because the PostgreSQLIDENTITY
strategy will change when you upgrade DBAL to v4 (see https://github.com/doctrine/orm/blob/4.0.x/UPGRADE.md#deprecated-reliance-on-the-non-optimal-defaults-that-come-with-the-auto-identifier-generation-strategy)So, you’d have to get the sequence’s next value by yourself (using
SELECT NEXTVAL('conference_id_seq')
) and assign it to the ID.But in fact the ORM would do it for you if you used it. Why do you want to insert rows by hand?