Insights into Company
← PHP & Laravel

Migrations and Job Portal Schema

Understand the idea. Compare it. Explain it. Test yourself.

Question 1 of 7

What is a Laravel migration?

Solution and explanation

  • Migrations are version-controlled database schema definitions.
php artisan make:migration create_products_table

Schema::create('products', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->decimal('price', 10, 2);
    $table->timestamps();
});

php artisan migrate
php artisan migrate:rollback
php artisan migrate:refresh
php artisan migrate:fresh
rollback undoes the latest migration batch. refresh rolls back every migration and runs them again. fresh drops all tables and migrates from scratch.
  • Warning: refresh and fresh delete data.
  • Never run them against production or a shared database; use new forward-only migrations there.
Practice explaining this
Question 2 of 7

What do up() and down() do?

Practice question · write your own answer
  • Define the concept in one or two sentences.
  • Give a small example and trace what happens.
  • Explain one limitation, trade-off, or common mistake.
Practice explaining this
Question 3 of 7

How do foreign keys and indexes work?

Practice question · write your own answer
  • Define the concept in one or two sentences.
  • Give a small example and trace what happens.
  • Explain one limitation, trade-off, or common mistake.
Practice explaining this
Question 4 of 7

How would you model companies, jobs and applications?

Practice question · write your own answer
  • Define the concept in one or two sentences.
  • Give a small example and trace what happens.
  • Explain one limitation, trade-off, or common mistake.
Practice explaining this
Question 5 of 7

How do you create a safe production schema change?

Practice question · write your own answer
  • Define the concept in one or two sentences.
  • Give a small example and trace what happens.
  • Explain one limitation, trade-off, or common mistake.
Practice explaining this
Question 6 of 7

How do unique constraints prevent duplicate jobs?

Practice question · write your own answer
  • Define the concept in one or two sentences.
  • Give a small example and trace what happens.
  • Explain one limitation, trade-off, or common mistake.
Practice explaining this
Question 7 of 7

How do you roll back a migration?

Solution and explanation

  • Migrations are version-controlled database schema definitions.
php artisan make:migration create_products_table

Schema::create('products', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->decimal('price', 10, 2);
    $table->timestamps();
});

php artisan migrate
php artisan migrate:rollback
php artisan migrate:refresh
php artisan migrate:fresh
rollback undoes the latest migration batch. refresh rolls back every migration and runs them again. fresh drops all tables and migrates from scratch.
  • Warning: refresh and fresh delete data.
  • Never run them against production or a shared database; use new forward-only migrations there.
Practice explaining this