520 questions
0 votes
1 answer
102 views
Laravel migration creates wrong columns and data mismatch in employers table
I’m building a job board project in Laravel, and I’m trying to establish a one-to-one relationship between User and Employer. However, my database table is not being generated correctly — the columns ...
0 votes
1 answer
64 views
How to add new field into unique index on Postgres with migration?
I have laravel 12/ postgresql 17 app and in a table with 2 fields unique field : Schema::create('posts', function (Blueprint $table) { $table->id(); $table->foreignId('action_id')->...
1 vote
0 answers
68 views
Laravel seeder only inserting one record; should insert 2500
I have a Laravel seeder that is only inserting one record when I have a factory and the seeder should insert 2500 records. Factory: public function definition(): array { $timestamp = $...
0 votes
1 answer
62 views
Method %s::%s does not exist Error During Laravel Migrations
I'm encountering a BadMethodCallException when running migrations on a pre-existing Laravel application. The error message I'm getting is: Method %s: %s does not exist. at vendor\laravel\framework\src\...
1 vote
1 answer
435 views
How to Seed Data from JSON Files in Laravel?
I have some JSON files, and I want to use them to seed my database in Laravel. Could someone guide me on how to achieve this? Specifically, I want to: Migrate the database tables required for the ...
0 votes
1 answer
693 views
From Laravel 11 migration: preserving original attributes when updating existing column
Starting from Laravel 11 (and unchanged in Laravel 12), migrations are required to include all attributes of a column in such cases, even those that are not being modified. Otherwise, those attributes ...
0 votes
1 answer
63 views
Rollback Failed Laravel Migration
I have more than once been in the situation where I'll be working on a migration, and the up() function fails. I would like the use the down() function of that migration, but running php artisan ...
-2 votes
1 answer
62 views
Database Migration Failed in laravel
Schema::create('jobs', function (Blueprint $table) { $table->id(); $table->string('title'); $table->text('description'); $table->unsignedInteger('salary'); $table->...
0 votes
1 answer
409 views
Postgres `generatedAs` and `storedAs` in Laravel migaration
I have this migration. I am using Postgres, I found that generatedAs and storedAs are supported by Postgres.. I am a beginner in Postgres. Schema::create('users', function (Blueprint $table) { $...
1 vote
0 answers
130 views
Laravel Testing with Multiple Databases: Preventing Migrations During Tests / Migrations failing
I'm working on a Laravel project that uses multiple MySQL databases. The main database (core_db) contains system tables like users, migrations, etc., while express_db and regio_db contain most of the ...
0 votes
1 answer
102 views
Why $table->dropForeign raised error in rollback?
I made a migration in Laravel 10.48.14 app : <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class ...
0 votes
1 answer
217 views
How to set migration execution order in Laravel using a command class
I'm trying to change the execution order of Laravel migrations because of foreign key constraints and I found some solutions like: 1- it can be done by renaming migration files to get it in the ...
0 votes
0 answers
24 views
override all method from model.php
Using Laravel V10.42.0 This is my route function Route::get('/posts', function () { return view('posts',[ 'posts' => Post::All() ]); }); This is my Posts.php file <?php ...
1 vote
0 answers
43 views
mysql is getting long lock while adding foreign key column as nullable and no default value with index on a big table
I am running Laravel Migration and this is how it looks on terminals adding a column state_id on the click table which contains millions of records. state_id is nullable and has no default value with ...
0 votes
0 answers
118 views
How to create a custom make:migration command in Laravel?
I want to make a new command in Laravel that creates a migrationfile and also prefills it with table definitions. I already know that the MigrationCreator uses stubs as template and populates it with ...