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

Postgres Migration Problema #32

Open
pedrosoares opened this issue Nov 28, 2016 · 2 comments
Open

Postgres Migration Problema #32

pedrosoares opened this issue Nov 28, 2016 · 2 comments

Comments

@pedrosoares
Copy link

I'm using postgres and when i migrate the error bellow shows up.
'''
Migration table created successfully.

[Illuminate\Database\QueryException]
SQLSTATE[42830]: Invalid foreign key: 7 ERROR: there is no unique constrai
nt matching given keys for referenced table "roles" (SQL: alter table "user
s" add constraint "users_role_level_foreign" foreign key ("role_level") ref
erences "roles" ("level"))

[PDOException]
SQLSTATE[42830]: Invalid foreign key: 7 ERROR: there is no unique constrai
nt matching given keys for referenced table "roles"
'''

@FPGL
Copy link

FPGL commented Dec 5, 2016

It says that roles.level must be unique. Try adding a unique() constraint:

Schema::create('roles', function (Blueprint $table) {
...
$table->integer('level')->unique()->default(1)->unsigned()->index();

@brunocs86
Copy link

Tks

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

No branches or pull requests

3 participants