+1 vote

I can make composite foreign key (foreign key with multiple column) by create project from a migrated database, but i cannot find away to create a new one in skipper

in Solved by (130 points)
recategorized by

2 Answers

+1 vote

Simply create two or more primary keys in the target entity and create an association to this entity. Skipper automatically creates composite FK.

by Skipper developer (141k points)

I have same problem as jin:
Skipper generate migrations in laravel 6x as:

Schema::table('vendors', function (Blueprint $table) {
        $table->foreign('customer_cd', 'customer_sub_cd')->references('customer_cd', 'customer_sub_cd')->on('customers')->onDelete('NO ACTION')->onUpdate('NO ACTION');
    });

Instead of correct must be:

Schema::table('vendors', function (Blueprint $table) {
        $table->foreign(['customer_cd', 'customer_sub_cd'])->references(['customer_cd', 'customer_sub_cd'])->on('customers')->...

Please try our latest version from here https://www.skipper18.com/support/402/downloads-skipper-beta

We're currently greatly improving Laravel migration exports. In case any of these fixes will not work, please send me your project to [email protected] so we can test it here.

Thank you

+1 vote

Issues with composite foreign keys are fixed in latest beta 3.2.25.1691.

  • Laravel support for associations to non-primary fields (New!) (support-ticket)
  • Laravel support for associations to composite non-primary fields (New!) (support-ticket)
  • Fixed Laravel migration for creating new composite association (support-ticket)

https://www.skipper18.com/support/402/downloads-skipper-beta

by Skipper developer (141k points)

Thank Ludek for support quickly
Skipper beta servion 3.2.25.1691 resolved the problem for me.