DEV Community

Cover image for Structuring Your Laravel App: Migrations In Folders
Ikechukwu Vincent
Ikechukwu Vincent

Posted on

Structuring Your Laravel App: Migrations In Folders

My first laravel app for production was a website for a financial service company. Just a website, it wasn't meant to manage their processes, even though I made provisions for job posting and applications among other things.

Sooner or later in building the website, I noticed the migration files is growing larger than what I wanted in a single folder. I must mention creating extra migrations to handle altering tables didn't help matters.

Quickly I started my second project which turns out to be a relatively big utility application. Shit began to get real. I needed to rethink my file structures starting from migration to business logic.

Then I figured out it would be better if I can group my migration files in folders. Related tables or migrations reside in the same folder. Without further ado let me quickly show you how to do that.

Let's say you want to group your migrations into 3 folder folders. Then in your terminal,

php artisan make:migration create_tablenames_table --path=database/migrations/admin
Enter fullscreen mode Exit fullscreen mode

This single command will create a table with the name “tablenames” inside the admin folder in the migrations folder.

You can go ahead and do this for the rest of the three folders. In the end, you will have a migration folder structure like this

Laravel Folder Structure, Organizing Your laravel app

  • I am Ikechukwu Vincent, Full Stack Web Developer, I work with Laravel and ReactJs
  • LinkedIn
  • Twitter

Top comments (0)