
Migrations & Schema Builder
Migrations creation, schema builder, column types, indexes, foreign keys, rollbacks, seeders, factories
1Which artisan command allows creating a new migration?
Which artisan command allows creating a new migration?
Answer
The make:migration command generates a new migration file in the database/migrations folder with an automatic timestamp. This command accepts a descriptive migration name and can use --create or --table options to automatically generate base code. Using this command ensures standardized structure and consistent naming of migrations.
2Which Schema Builder method allows creating a new table?
Which Schema Builder method allows creating a new table?
Answer
The Schema::create() method allows creating a new table in the database. It takes two parameters: the table name and a closure that receives a Blueprint object to define columns. This method is used in the up() method of migrations to create new data structures.
3Which column type should be used to store an auto-incrementing UNSIGNED BIGINT identifier?
Which column type should be used to store an auto-incrementing UNSIGNED BIGINT identifier?
Answer
The id() method creates an auto-incrementing UNSIGNED BIGINT column that serves as primary key. This is the recommended type for identifiers since Laravel 6, replacing increments(). This method automatically configures auto-increment and primary key constraint, simplifying table definition.
Which method allows adding created_at and updated_at columns to a table?
Which artisan command executes all pending migrations?
+17 interview questions
Other Laravel interview topics
PHP Basics
PHP OOP Essentials
Composer & Autoloading
Laravel Fundamentals
Laravel Routing
Blade Templates
Request & Response
Eloquent ORM Basics
Eloquent Relationships
Validation & Forms
Authentication
Authorization & Policies
API Resources & Authentication
Middleware
Service Container & DI
Queues & Jobs
Events & Listeners
Notifications & Mail
File Storage
Testing & PHPUnit
Caching
Livewire & Inertia
Eloquent Advanced
Repository Pattern
Laravel Packages
Performance Optimization
Security Best Practices
Laravel Octane
Laravel Distributed Systems
Observability & Monitoring
Deployment & DevOps
Master Laravel for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free