bubble_chart StackLab

Database Migration

19 steps · pending Not started · person_outline Guest
arrow_back Back

Create the migrations folder

Instead of putting all of our SQL directly into phpMyAdmin, we'll save it in a migration file. This makes the database setup easier to:

    1. keep in version control
    2. share with other developers
    3. reproduce on another computer
    4. update later
A simple PHP project can look like this:
code text
your-project/
│
├── app/
│
├── database/
│   └── migrations/
│
├── public/
│
└── index.php
Inside database/migrations, create:
code text
database/
└── migrations/
    └── 001_initial_library.sql
The 001_ prefix tells us that this is the first migration. As the application grows, additional migrations can follow the same pattern:
code text
001_initial_library.sql
002_add_categories.sql
003_add_users.sql
This makes it easy to understand the order in which database changes were introduced.

login Sign in to save your progress permanently. info Progress is saved in your browser session
format_list_numbered Step 4 of 19