fizz icon indicating copy to clipboard operation
fizz copied to clipboard

Create Auto inc fields

Open guxx opened this issue 7 years ago • 2 comments

Hello

how do i create a migration with an integer field auto_incremental ? This field won't be the id or key.

guxx avatar Aug 06 '18 16:08 guxx

I think you might want to have a look at this https://www.geeksforgeeks.org/sql-sequences/

de-perotti avatar Aug 11 '19 16:08 de-perotti

There could be several approaches to achieve it.

  1. Of course, the simplest way with the current version of Fizz could be using sql() so you can run your own SQL.
  2. Supporting a user-defined option (e.g. custom or constraint) could be one option. currently, only a few options are supported.
    • https://github.com/gobuffalo/fizz#supported-options
    • e.g. t.Column("my_col", "int", {"custom": "GENERATED ALWAYS AS IDENTITY"})
  3. Adding auto_increment option could also be an option but I am not sure how many developers need it

I would like to postpone this to the next version.

sio4 avatar Sep 12 '22 11:09 sio4