nurdaulet-shamilov

Apr 15th, 2019 04:49 PM

Laravel 5.8 , I have problem with building chatter on fresh project, I followed steps in https://github.com/thedevdojo/chatter but during migration, it showing this error , I dont have any other migration file, it is trying to create table forum, which is the name of database

andrewo0

Apr 16th, 2019 03:48 AM

@nurdaulet-shamilov

try a migartion on all files except the 2016_07_29_171128_create_foreign_keys.php after you have done this run the migartion on the 2016_07_29_171128_create_foreign_keys.php file

i think it has to do with tables that have not yet been migrated.

mark-west

Apr 16th, 2019 10:03 AM

Pasting my response from another post: In Laravel 5.8 the standard data type for id's is changed to bigIncrements, when formulating foreign key constraints laravel expects bigInteger as datatype for the modal_id fields in intermediate tables (if the referenced table uses bigIncrements).

andrewo0

Apr 16th, 2019 10:09 AM

your right that has changed in 5.8 thanks @mark-westgeest

@nurdaulet-shamilov take a look at teh comment of @mark-westgeest

nurdaulet-shamilov

Apr 16th, 2019 10:15 AM

@mark-westgeest and @andrewo0 I am totally new in laravel, what exactly do I need to change?

mark-west

Apr 16th, 2019 10:27 AM

Take a look at your users table migration. Check if the datatype of id is increments or bigIncrements. Then change the datatype of user_id in chatter_discussion accordingly (integer if datatype of id in users table was increments and bigInteger if the datatype was bigIncrements).

The default is now bigIncrements for id's and bigInteger for foreign key constraints in intermediate tables. If you have a column in an intermediate table with the datatype bigInteger, the foreign key expects the id column of the related table to be bigIncrments. Here is an example of one of my recent migrations:

					$table->bigIncrements('id');

        $table->integer('genre_id')->unsigned();
        $table->foreign('genre_id')->references('id')->on('genres');

        $table->bigInteger('story_id')->unsigned();
        $table->foreign('story_id')->references('id')->on('stories');

Note that I use integer for genre_id and bigInteger for story_id, this is because I made the table genres in Laravel 5.6 and the table stories in 5.8 with the new defaults.

reyna1081us

Apr 11th, 2023 02:48 AM