Customizing Ecto's primary key migration sequences

The Ecto migration’s documentation about primary keys states:

By default, all :identity column will be bigints. You may provide optional
parameters for :start_value and :increment to customize the created
sequence. Config example:

      config :app, App.Repo, migration_primary_key: [type: :identity]

However, when I define a table like this:

  create table(:sample_type, primary_key: false) do
    add :type, :bigserial, primary_key: true
    add :name, :string
  end

and in the config set:

config :myapp, MyApp.Repo,
  migration_primary_key: [start_value: 1, increment: 1000],
  migration_timestamps: [type: :utc_datetime]

it doesn’t seem to customize the sequence for the primary key with the start_value and increment.

Defining the primary key this way doesn’t help either:

    create table(:sample_type, primary_key: false) do
      add :type, :bigserial, primary_key: true, start_value: 1, increment: 1000
      add :name, :string

Diving into the code reveals that those options are documented but not implemented. Am I looking in the wrong place? I can think of a workaround with altering the sequence after creation, but it appears a bit odd that the feature is documented but not implemented.

Nitpick: this is using bigserial but I believe the code to handle options like start_value and increment is specifically only used for type :identity:

Unsure if switching the type will fix things, but it certainly isn’t helping :slight_smile:

What you pointed out certainly helps for explicit definition in:

add :type, :identity, primary_key: true, start_value: 1, increment:

However, it doesn’t seem to respect the migration_primary_key options defined in:

config :myapp, MyApp.Repo,
  migration_primary_key: [start_value: 1, increment: 1000],

I believe it’s a bug.