40 lines
982 B
PHP
40 lines
982 B
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('rooms', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
|
||
|
$table->unsignedBigInteger('building_id');
|
||
|
$table->string('name');
|
||
|
|
||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||
|
$table->timestamp('deleted_at')->nullable();
|
||
|
|
||
|
$table->foreign('building_id')->references('id')->on('buildings')->onDelete('cascade');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::dropIfExists('rooms');
|
||
|
}
|
||
|
};
|