0 votes

Hi,
how I can set a custom name for the primary key name?
With Laravel, I can do this:

$table->primary(['centrodilavoro_id','lavorazione_id'], 'CUSTOM_NAME);

Thanks!
Roberto

asked in Feature Request by (140 points)
recategorized by

1 Answer

0 votes

Hello Roberto,

currently there are only two modes of how PK/FK names are generated. Automatically by Laravel or automatically with predefined UUID values by Skipper.

You can switch for the second mode in project settings:
enter image description here

UUID-like PK/FK names are here because Laravel sometimes generates too long name which causing DB errors, so we decided to solve it via automatically generated uuids on Skipper side.

But is there any reason to allow also custom PK/FK names? What is the use case for such a feature?

Thanks!

answered by Skipper developer (135k points)

Hi,
thanks for the answer.
The issue is due to Laravel generations of the name, that sometimes as too long, with DB errors.
The generated names is a good solution to avoid DB errors during migration, but the names as little understanding.

Thanks!

Can you please be more specific about what you mean by "but the names as little understanding." ?

Does it mean that auto-generated names in current for are sufficient for you or you need human-readable names FK/PK names in the database?

Exactly, the auto-generated names are not human-readble.
In this example, the key name are not related to the field key.

$table->primary(['centrodilavoro_id','lavorazione_id'], 'IX_2cd618e7de18454f9bd2f26ac47e3dfd');

ok, so what you need is per-index and per-foreign key custom name configuration.

I believe we will be able to implement it. Custom per-object names will have priority over default/uuid-like names.

Checking this feature but we're not sure how to implement it correctly. There is an issue with single-column primary keys.

Currently, we're exporting it as:

$table->bigInteger('id')->autoIncrement()->unsigned();

but there is no way how to pass the custom index to such a definition. On the other side, when we define index as $table->primary() there is no way how to set it as autoincrement.

Can you please send me details about how you're configuring such indexes?