Bird
0
0

Find the mistake in this migration snippet:

medium📝 Debug Q7 of 15
Laravel - Database Basics and Migrations
Find the mistake in this migration snippet:
$table->integer('age')->nullable(false)->default(null);
Adefault(null) is invalid syntax
Binteger() cannot have default values
CSetting nullable(false) conflicts with default(null)
Dnullable() must be true to allow nulls
Step-by-Step Solution
Solution:
  1. Step 1: Analyze nullable and default usage

    Setting nullable(false) means the column cannot be null.
  2. Step 2: Check default value compatibility

    Setting default(null) conflicts because null is not allowed.
  3. Final Answer:

    Setting nullable(false) conflicts with default(null) -> Option C
  4. Quick Check:

    nullable(false) disallows null, default(null) conflicts [OK]
Quick Trick: nullable(false) disallows null, so default(null) is invalid [OK]
Common Mistakes:
  • Assuming default(null) works with nullable(false)
  • Thinking integer columns can't have defaults
  • Confusing nullable(true) and nullable(false)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes