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

Clarify installation #12

Open
carlofraue79 opened this issue Apr 30, 2019 · 11 comments
Open

Clarify installation #12

carlofraue79 opened this issue Apr 30, 2019 · 11 comments

Comments

@carlofraue79
Copy link

Hi
I'm working on laravel 5.8 and after install with composer i'm update manually the files config/app.php and
also manually update the databases after the run command "php artisan migrate" i'm receive as output the following error
php artisan migrate
Migrating: 2019_04_30_125539_create_groups_tables

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table groups add constraint groups_user_id_foreign foreign key (use r_id) references users (id) on delete cascade)

for what reasons?

@musonza
Copy link
Owner

musonza commented Apr 30, 2019

What's the users table migration file name?

@carlofraue79
Copy link
Author

@musonza the file name is 2014_10_12_000000_create_users_table.php
is correct or i'm missing something step ?

@musonza
Copy link
Owner

musonza commented Apr 30, 2019

Is your table engine set to InnoDB? You can also set it with $table->engine = 'InnoDB'.

@carlofraue79
Copy link
Author

@musonza the output after install again your package and execute the command:
php artisan migrate
Migrating: 2019_04_30_151147_create_groups_tables

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table groups add constraint groups_user_id_foreign foreign key (use r_id) references users (id) on delete cascade)

at C:\xampp\htdocs\xxxx\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {

664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Exception trace:

1 PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")
C:\xampp\htdocs\xxx\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

2 PDOStatement::execute()
C:\xampp\htdocs\xxx\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

Please use the argument -v to see more details.

@musonza
Copy link
Owner

musonza commented Apr 30, 2019

@carlofraue79
Copy link
Author

The query SHOW VARIABLES LIKE '%ENGINE%' show

"default_storage_engine" "InnoDB"
"default_tmp_storage_engine" "InnoDB"
"disabled_storage_engines" ""
"internal_tmp_disk_storage_engine" "InnoDB"

i have also set $table->engine='InnoDB'; but the result is not change.
I have installed MySQL Server on my Windows 10 System.

@musonza
Copy link
Owner

musonza commented Apr 30, 2019

for now comment out this

$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');

When i get a chance i will look at it. If it's not test database then i would say wait for the fix or if you can fix send a PR

@carlofraue79
Copy link
Author

@musonza if i found the fix i can sent a PR

@asjsrep
Copy link

asjsrep commented Jul 19, 2019

Set

$this->useBigIncrements = false;

in the migration constructor if your user table ID was created without bigIncrements i.e increments

@sarfaraz2120
Copy link

sarfaraz2120 commented Jun 9, 2020

Hi author thanks for these wounder full package, Iam having question how to add a Member later if we decide to add a new member.
//Add these member to which group because we have n number of groups, can u pls point me out
// add n number of users to a particular group
$group->addMembers([$userId, $userId2, ...]);

Thanks in advance

@sarfaraz2120
Copy link

actually iam thinking it like these way simple

$group->addMembers($groupId, $membersArray);

Iam not experience user in laravel pls let me know if it exist like these way?

Thanks in advance

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

4 participants