Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
57 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 ...
Muhammed Salama's user avatar
0 votes
1 answer
149 views

Laravel 11 migration: preserving original attributes when updating existing column

Starting from Laravel 11, migrations are required to include all attributes of a column in such cases, even those that are not being modified. Otherwise, those attributes will be lost. However, this ...
rozsazoltan's user avatar
0 votes
1 answer
43 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 ...
Sonny's user avatar
  • 8,316
-2 votes
1 answer
54 views

Database Migration Failed in laravel

Schema::create('jobs', function (Blueprint $table) { $table->id(); $table->string('title'); $table->text('description'); $table->unsignedInteger('salary'); $table->...
inta3's user avatar
  • 7
0 votes
1 answer
143 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) { $...
Watheq Alshowaiter's user avatar
1 vote
0 answers
68 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 ...
spyro95's user avatar
  • 146
0 votes
1 answer
95 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 ...
mstdmstd's user avatar
  • 3,013
0 votes
1 answer
83 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 ...
Ahmad Ahmad's user avatar
0 votes
0 answers
21 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 ...
Mahmoud M. Matouk's user avatar
0 votes
0 answers
25 views

Laravel 11 migrations for foreign keys in different tables [duplicate]

I've tried to solve this for two days and am finally throwing in the towel to ask for help. I am trying to get a database setup with a number of tables, relevant here is: Table: Collections: Schema::...
Trick Jarrett's user avatar
0 votes
0 answers
90 views

Laravel 10 migrations. Alter table to increase timestamp precision

I'm currently working with a Laravel application. Having some difficulties with writing a migration that alters the already existing table. What I am trying to achieve is to increase the precision of ...
Baykov Nikita's user avatar
1 vote
0 answers
41 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 ...
Furqan Freed's user avatar
0 votes
0 answers
83 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 ...
Peter de Groot's user avatar
4 votes
1 answer
2k views

Using float columns in Laravel 11 migrations

The upgrade notes for Laravel 11 say: The float column type now creates a FLOAT equivalent column without total digits and places (digits after decimal point), but with an optional $precision ...
miken32's user avatar
  • 42.7k
0 votes
1 answer
356 views

Laravel softDelete migration issue

We recently tried to add a soft delete to an existing model through a new migration. Everything works fine locally, but it was failing our unit Test because it could not find the deleted_at column of ...
dawgbone98's user avatar
0 votes
0 answers
71 views

Pivot table migration not using custom table name

I'm trying to make a pivot table in Laravel but I'm using spanish terms for the names: products - productos | distributors - distribuidores here is part of the migrations for each: distributors ...
Adrian Osuna's user avatar
-1 votes
1 answer
61 views

Laravel migration error throwing directory from old host even after migration to new host

I migrated my laravel saas site from one host to another but its throwing error: There is no existing directory at "/home4/username/abc.com/storage/logs" and it could not be created: ...
Komal Shree's user avatar
0 votes
0 answers
777 views

Laravel- Why "personal_access_tokens" table is created even after removing the migration file

I created a new project using Laravel version 10, generating several migration files. Subsequently, I removed certain pre-existing files that were present upon project creation from the migration ...
Ansh Bargoti's user avatar
0 votes
1 answer
121 views

Is there a way to disable foreign key constraints when any "down" function triggers?

I'm discussing an efficient approach to execute the Schema::disableForeignKeyConstraints() whenever an artisan migrate:refresh command is executed. For instance, we can integrate it into the migration ...
A. El-zahaby's user avatar
  • 1,160
2 votes
3 answers
602 views

Laravel migration to change an unsignedMediumInteger column

I have a need to create a migration that changes an existing unsignedMediumInteger column to nullable(). I have the following in my migration: use Illuminate\Database\Migrations\Migration; use ...
user3467896's user avatar
0 votes
0 answers
73 views

Error when running custom artisan command 'php artisan migrate:multiple'

Laravel Version 9.52.16 PHP Version 8.1.4 Database Driver & Version MySQL Description 2023_04_08_065850_create_business_categories_table don't even exist in any of the migrations folder but still ...
Faizan Kamal's user avatar
  • 2,152
0 votes
1 answer
78 views

Should i write migrations every time i want to create table in Laravel?

So basicly i have started working with laravel. And to this moment i have been writing migrations and defining the fields there. And after that i should create a model related to it and define the ...
p1rate_k1ng's user avatar
0 votes
2 answers
422 views

Laravel changing column type to enum

I am trying to change a varchar column to an enum type. I wrote and ran my migration - create new column, logic to set the values, drop old column, rename new column. At first thought it all went well,...
Charlie Walker's user avatar
0 votes
2 answers
58 views

Why is my Laravel database migration does not work?

I'm currently taking Laravel 8 From Scratch by Jeffry Way. I'm currently in episode 54 when I faced the error below after trying to migrate:fresh --seed. I'm pretty sure I followed everything from the ...
lance2k's user avatar
  • 367
2 votes
2 answers
1k views

How to run migration for tables inside Modules in laravel

I am working on Laravel^9.19" project with php^8.1, I created a Modules folder and then I created a migration files inside, my structure is like this : --app --Modules ----user ------Database ----...
Abdul Rahman Al Hourani's user avatar
0 votes
1 answer
34 views

Laravel how to store more foreign data together with the foreign key (on creation)

I have a many to many relation ship between my Job and Company models. Here is a small part of the migration that handles the relation: $table->bigInteger('company_id')->unsigned(); $table->...
Spartis's user avatar
  • 59
0 votes
1 answer
35 views

Puzzled student, not being able to figure out why my migrations won't work

I'm running into problems with Laravel migrations and creating database tables. Specifically with the constraints. When I execute the command php artisan:migrate fresh I get the following error: ...
Mario Mancev's user avatar
0 votes
1 answer
177 views

I tried Php Laravel Migration, but got some errors, could anyone help me solve this?

Had an Error running Php laravel Migration. I tried php artisan make:migration rename_name_in_users --table=users, which was successful and edited the following; public function up(): void { ...
Michael's user avatar
-1 votes
1 answer
301 views

Laravel - artisan migrate takes long time about 3 sec for each table on Ubuntu 22.04 & 23.04

I have installed the latest version of ubuntu 23.04, and there was a problem with artisan migrate. The problem is the process takes about 3 sec for each table to be created! as stated in the image ...
MElhalees's user avatar
1 vote
1 answer
238 views

Proper way to access migrations files building custom refresh/seed in Laravel

Looking for a smarter way to do this. I have 4 migrations files (out of MANY dozen) that are related. I also have a seeder for these. Doing php artisan migrate:fresh --seed takes a good 30-45 seconds ...
Phil Tune's user avatar
  • 3,285
0 votes
0 answers
51 views

Set laravel migration default value equal current database record or null

This is a migration for Blog database of a website that I'm developing for my own resume as portfolio: public function up(): void { Schema::create('blogs', function (Blueprint $table) { $...
user avatar
1 vote
1 answer
693 views

Calling Commands From Other Commands, and answer prompts with yes

I want to create a console command that help me through a site deployment by calling other Artisan commands (a migration, followed by a series of functions that will fill the table with data.) ...
Hoyt Jolly's user avatar
1 vote
1 answer
395 views

How to make bit column like in SQL Server using Laravel Database Migration

So I'm creating a new table, replicating an existing table, and one of them has a column of type bit, like this: I already understand the concept of migration and have made it often, but to create ...
Muhammad Faisal's user avatar
2 votes
1 answer
592 views

Laravel Migrations | Blueprint Class and Schema Class

I am new to Laravel Backend PHP Framework and recently I came to a "Blueprint" and "Schema" classes. On top of my file I use : ` use Illuminate\Database\Migrations\Migration; use ...
Amrudin's user avatar
  • 31
1 vote
2 answers
7k views

How Can I Set the Default Value of a DATE Column to the Current date with Laravel Migrations?

I'm having some issues with creating a migration, one of the columns I have on the table is a DATE type, not DATETIME or TIMESTAMPS. And the problem is that I can't find a way to define the default ...
E. Galdamez's user avatar
0 votes
0 answers
390 views

SQLite error with Laravel migration and storedAs column

I installed a fresh Laravel 10 project. And added a new column to the users migration: $table->integer('test')->nullable()->storedAs('5 * 6'); And I get this error when running the migration:...
nathan's user avatar
  • 13
0 votes
1 answer
366 views

I don't use migrations in Laravel, is that a problem for server initial response time?

I simply don't use the migrations in Laravel. I just create the table from phpMyAdmin, and than I use php artisan to make a model. After that, I make the adjustments in the model file. I know this ...
Baran Arda's user avatar
0 votes
2 answers
155 views

Error when runing factories and seeders laravel

I've created my first api in Laravel, and I'm having trouble generating the database from the migations. Every time I run php artisan migrate even after using composer dump-autoload and generating ...
Aleix 's user avatar
  • 127
-1 votes
1 answer
131 views

I got error while migrating laravel migrations in arch linux

Illuminate\Database\QueryException could not find driver (Connection: mysql, SQL: create table migrations` (`id` int unsigned not null auto_increment primary key, migration` varchar(255) not null, `...
Boburjon's user avatar
0 votes
2 answers
77 views

Laravel Seeder throws SQLSTATE[42000]: Syntax error or access violation

I am having the following db tables // Table 1: Foos id, foo_name, foo_type, created_at, updated_at // Table 2: Bars id, bar_name, bar_type, parent_id, foo_id [ForeignKey], created_at, updated_at // ...
ltdev's user avatar
  • 4,457
2 votes
1 answer
243 views

Why creating table in migration error with created_at table?

Uploading laravel 9 project on remote server with ubuntu 18.04 I got error migrating: 2023_01_18_053125_create_user_meetings_table .........................................................................
mstdmstd's user avatar
  • 3,013
-1 votes
1 answer
37 views

Foreign key constraint is incorrectly formed (with inno db)

When running: Schema::create('files', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->id(); $table->string('path'); $table->timestamps(); }); Schema::create('...
echocage's user avatar
0 votes
0 answers
188 views

How can I fix <Laravel could not find driver> when I do php artisan migrate?

I have tried to make a migration and it is not possible, the user entered has the necessary permissions and the password are also correct, but when executing the "php artisan migrate" ...
Carlos Cámaras Miguel's user avatar
0 votes
2 answers
445 views

I cannot delete data which have many-to-many relationship in laravel 9

I am using PHP 8.2.0, MySQL 8.2.0, and Laravel 9.48.0. This is my database migrations file pivot table (category_menu): public function up() { Schema::create('category_menu', function (...
Khairil Azri's user avatar
0 votes
0 answers
317 views

Laravel migration does not create cross schema foreign key in PostgreSQL database

I have 2 schemas on the same PostgreSQL database but on separate schemas (logs and auth). When I run the following migrations the foreign key is not created in the database (it doesn't throw any ...
adamsc's user avatar
  • 1
-1 votes
1 answer
166 views

How can I in migration to set index name automatically manually?

In laravel 9 app running migration with statement(mysql database) : $table->foreignId('notification_config_id') ->nullable() ->references('id') ->on('notification_configs') ->...
mstdmstd's user avatar
  • 3,013
2 votes
0 answers
86 views

How to customize Laravel default notifications architecture along with custom columns in notifications table migration without repeating provided code

As Laravel shipped with a default notification module. It provides us following notifications_table. id type notifiable_type notifiable_id data read_at created_at updated_at fd71b94e-a0fc-42d5-9cfc-...
M-Khawar's user avatar
  • 963
2 votes
3 answers
962 views

Laravel Artisan Migrate Drop Column using Sqlite throws exception

I'm trying to set up some unit tests in a legacy Laravel project. This project has a lot of migration scripts creating and updating the database. This migrations work fine on a MySQL database, however ...
Richard Parnaby-King's user avatar
0 votes
1 answer
247 views

What's the down method for foreignIdFor()?

If I run this in my migration up method, what do I put in the down method? $table->foreignIdFor(MyClass::class)->nullable()->constrained(); Thanks!
SeaBass's user avatar
  • 1,744
0 votes
1 answer
1k views

Laravel Migration Rollback of Index with Column Change

I'm trying to test a migration rollback after changing a column type and setting the index. /** * Reverse the migrations. * * @return void */ public function down() { ...
Second2None's user avatar
  • 1,600

1
2 3 4 5
11