How to define autogenerated integer primary key?

I have a following (existing) MySQL table:

create table table_name
    id                              int auto_increment primary key,

How do I define an Ecto model and migrations which give me 1:1 schema?

By default, Ecto gives me bigint, so I’ve tried:

create table("table_name", primary_key: false) do
    add :id, :int, primary_key: true, increment: 1, start_value: 1

but increment and start_value only work for identity type.

Setting @primary_key {:id, :integer, autogenerate: true} in a model gives me:

field :id does not support :autogenerate because it uses a primitive type :integer

Leaving :id as type here results in PK not being generated.

Any ideas?

Thank you!

Could you “not set” those options leaving just primary_key: true?

Also not sure why you get errors around identity, which afaik is a postgres only column type.

Not setting those fields (and leaving out @primary_key which I can’t set for :integer) simply results in:

(MyXQL.Error) (1364) Field 'id' doesn't have a default value