Describe the bug
Currently when using an *_increment() field as part of a migration the specified column
is automatically added as the promary ley.
This can cause issues if you want an autoincremented column that is not a primary key.
An example of this is when using UUID column as a primary key and you need an autoincremented column for a reference purpose (eg invoice number)
A bool to specify defining the column as primary key on the column definition would be the simplest way with backwards compatibility
with self.schema.create("invoice") as table:
table.uuid("id").primary()
table.big_increments("reference", primary=False)
table.tiny_increments("group", primary=False)
To Reproduce
see workaround below
Expected behavior
an example of how to workaround this issue with a single column in a migration
with self.schema.create("invoice") as table:
table.uuid("id") # dont set the uuid colun as primary yet
table.big_increments("reference"). # add the increments (also tags it as primary key)
table.uuid("company_id")
table.string("status").default("PAYMENT_PENDING")
table.timestamps()
with self.schema.table("invoice") as table:
table.drop_primary("invoice_reference_primary") # drop the primary key off the incremented column
table.primary("id") # mark the id column as the primary key
NOTE: This is not ideal and ONLY works if you have a single autoincrement column.
Screenshots or code snippets
N/A
Desktop (please complete the following information):
What database are you using?
- Type: Postgres, MySQL, SQLite
- Version N/A
- Masonite ORM 2.24.0 & 3.x
Additional context
Being able to specify the start and increment index for the column would be nice too
Describe the bug
Currently when using an *_increment() field as part of a migration the specified column
is automatically added as the promary ley.
This can cause issues if you want an autoincremented column that is not a primary key.
An example of this is when using UUID column as a primary key and you need an autoincremented column for a reference purpose (eg invoice number)
A bool to specify defining the column as primary key on the column definition would be the simplest way with backwards compatibility
To Reproduce
see workaround below
Expected behavior
an example of how to workaround this issue with a single column in a migration
NOTE: This is not ideal and ONLY works if you have a single autoincrement column.
Screenshots or code snippets
N/A
Desktop (please complete the following information):
What database are you using?
Additional context
Being able to specify the start and increment index for the column would be nice too