Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

grapple's avatar

Migration of Laravel Data

I have a site which has data at 3 levels, think Quiz, Question, Answer where:

Quizzes have Questions

and

Questions have answers.

I'm wanting to migrate this data from one Laravel instance to another (think multilingual) exact copy of database structure.

Is there a specific way to go about this in the Laravel world or is it just going to need me to write migration scripts. The problem being I need to maintain relationships but not ID's across the databases.

What I'm finding issue with at the moment is when I bring back my data for my quiz I can no longer access the relations once I switch to my new DB connection. Therefore I am having to build flat arrays of the related data to then loop through and save in the new DB.

Wondering how anybody else would approach this.

0 likes
3 replies
shez1983's avatar

laravel instance? you mean another laravel app? if the structure is the same you can just export database and import it in the new place.

grapple's avatar

sorry yes another laravel app but it's about passing a quiz from one DB to another as a piece of functionality for a user who has access to both laravel apps.

I'm wondering if there is a part of Laravel I'm not aware as yet that would handle migrating content from one app to another whilst maintaining relations but not IDs assuming the ID's may already be taking in the target DB.

shez1983's avatar

it all depends on the db of this other app - you will have to write a script that gets triggered..

Please or to participate in this conversation.