Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple primary key #16

Open
ghost opened this issue Mar 25, 2018 · 2 comments
Open

Multiple primary key #16

ghost opened this issue Mar 25, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 25, 2018

Syntax error or access violation: 1068 Multiple prima ry key defined (SQL: alter table mytable_version add primary key mytable_version_version_primary(version ))

with code:

  Schema::create('mytable_version', function(Blueprint $table) {
            $table->integer('ref_id')->primary();
            $table->integer('version')->primary();
            //add versionable columns
            $table->timestamps();
            $table->softDeletes();
        });
@crashkonijn
Copy link
Collaborator

Hello @AceWT,

This should fix your issue:

Schema::create('mytable_version', function(Blueprint $table) {
	$table->integer('ref_id');
	$table->integer('version');
	//add versionable columns
	$table->timestamps();
	$table->softDeletes();
	
	$table->primary(['ref_id', 'version']);
});

@danhunsaker
Copy link

The README is updated accordingly in #20...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants