database/migrations/ — create + alter
<?php
// 1) create_employees_table.php — make a new table
public function up(): void
{
Schema::create('employees', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('age');
$table->string('email')->unique();
$table->text('address');
$table->integer('pincode')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('employees');
}
// 2) alter_employees_table_with_department.php — change an existing table
public function up(): void
{
Schema::table('employees', function (Blueprint $table) {
$table->string('department')->nullable();
});
}
public function down(): void
{
Schema::table('employees', function (Blueprint $table) {
$table->dropColumn('department');
});
}
Output — php artisan migrate
$ php artisan migrate
INFO Running migrations.
create_employees_table DONE
alter_employees_table_with_department DONE
Resulting
employees table (MySQL):id BIGINT UNSIGNED PK
name VARCHAR(255)
age INT
email VARCHAR(255) UNIQUE
address TEXT
pincode INT nullable
department VARCHAR(255) nullable
created_at / updated_at TIMESTAMP