groups icon indicating copy to clipboard operation
groups copied to clipboard

Clarify installation

Open carlofraue79 opened this issue 5 years ago • 11 comments

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?

carlofraue79 avatar Apr 30 '19 13:04 carlofraue79

What's the users table migration file name?

musonza avatar Apr 30 '19 13:04 musonza

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

carlofraue79 avatar Apr 30 '19 14:04 carlofraue79

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

musonza avatar Apr 30 '19 14:04 musonza

@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.

carlofraue79 avatar Apr 30 '19 15:04 carlofraue79

What about your database engine? Check this for more information https://laracasts.com/discuss/channels/general-discussion/sqlstatehy000-general-error-1215-cannot-add-foreign-key-constraint?page=1

musonza avatar Apr 30 '19 15:04 musonza

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.

carlofraue79 avatar Apr 30 '19 15:04 carlofraue79

for now comment out this https://github.com/musonza/groups/blob/9bde27d614e53d1b16ade6339cd9a6f6a47ef82b/database/migrations/create_groups_tables.php#L30-L33

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

musonza avatar Apr 30 '19 15:04 musonza

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

carlofraue79 avatar Apr 30 '19 15:04 carlofraue79

Set

$this->useBigIncrements = false;

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

asjsrep avatar Jul 19 '19 06:07 asjsrep

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 avatar Jun 09 '20 16:06 sarfaraz2120

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

sarfaraz2120 avatar Jun 09 '20 17:06 sarfaraz2120