31 lines
932 B
PHP
31 lines
932 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('indexes', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('table_id')->constrained('tables')->cascadeOnDelete();
|
|
$table->string('index_name');
|
|
$table->json('columns'); // Array of column names
|
|
$table->boolean('is_unique')->default(false);
|
|
$table->boolean('is_primary')->default(false);
|
|
$table->string('index_type')->default('btree');
|
|
$table->text('definition')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->unique(['table_id', 'index_name'], 'unique_index');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('indexes');
|
|
}
|
|
};
|