Created
August 20, 2020 19:35
-
-
Save djaiss/616f57acabe2352d14d40cecccf5ce04 to your computer and use it in GitHub Desktop.
Example of `is_dummy` field in the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateHardwareTable extends Migration | |
{ | |
/** | |
* Run the migrations. | |
*/ | |
public function up() | |
{ | |
// necessary for SQLlite | |
Schema::enableForeignKeyConstraints(); | |
Schema::create('hardware', function (Blueprint $table) { | |
$table->id(); | |
$table->unsignedBigInteger('company_id'); | |
$table->unsignedBigInteger('employee_id')->nullable(); | |
$table->string('name'); | |
$table->string('serial_number')->nullable(); | |
$table->boolean('is_dummy')->default(false); | |
$table->timestamps(); | |
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade'); | |
$table->foreign('employee_id')->references('id')->on('employees')->onDelete('set null'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment