Skip to content

Support for composite indexes #271

@DennisOng

Description

@DennisOng

Super useful package for quick prototyping. Glad to see this gaining traction and thanks for the effort you've put in.

Synopsis:

There doesn't seem to be a way to define composite indexes (for migrations) in the draft model files

Proposed Syntax:

models:
    Participation:
        project_id: bigInteger
        user_id: bigInteger
        name: string
        indexes:
          - unique: project_id, user_id
          - index: project_id, user_id
          - primary: project_id, user_id

Expected Behavior:

Schema::table('participations', function (Blueprint $table) {
    $table->bigInteger('project_id');
    $table->bigInteger('user_id');
    $table->string('name');
    $table->unique(['project_id', 'user_id']);
    $table->index(['project_id', 'user_id']);
    $table->primary(['project_id', 'user_id']);
});

I think the main drawback is introducing the YAML array syntax, since as far as I know no other draft files in Blueprint uses that syntax so far. Otherwise could be quite a handy addition. Happy to take a stab at it if the syntax's approved, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions