Member-only story

Simplified Guide to Laravel Migrations: Step-by-Step Instructions

I Nyoman Jyotisa
3 min readOct 25, 2024

--

In Laravel, migrations offer a structured way to modify and maintain your database schema. Think of them as a code-based alternative to tools like phpMyAdmin. Migrations help ensure that your development environments and team members are all working with the same database structure.

For example, when starting a new project, you can simply clone it, run php artisan migrate, and have an up-to-date database instantly. Since migrations are written in code, they follow the same version control as the rest of your project.

The make:migration Command in Laravel

Basic Usage
Creating a new migration is easy with Artisan. Use the following command:

php artisan make:migration CreatePostsTable

Here’s a simple naming convention to follow:

  • Use PascalCase.
  • Start with “Create.”
  • Follow with the table name.
  • End with “Table.”

Artisan generates a new migration file, names it in snake_case for readability, and adds a timestamp prefix.

Example:

INFO Created migration [2022_09_12_142156_create_posts_table].

--

--

No responses yet