Mager updated
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('object_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('objects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->string('name', 255);
|
||||
$table->string('description', 255)->nullable();
|
||||
// If you keep the column name as 'type_id', specify the table explicitly
|
||||
$table->foreignId('type_id')->constrained('object_types')->nullOnDelete();
|
||||
// Indexes for faster lookups
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('reference');
|
||||
$table->index('type_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('objects');
|
||||
Schema::dropIfExists('object_types');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user