43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
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('columns', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('table_id')->constrained('tables')->cascadeOnDelete();
|
|
$table->string('column_name');
|
|
$table->string('data_type');
|
|
$table->string('udt_name')->nullable();
|
|
$table->integer('ordinal_position');
|
|
$table->boolean('is_nullable')->default(true);
|
|
$table->string('column_default')->nullable();
|
|
$table->integer('character_maximum_length')->nullable();
|
|
$table->integer('numeric_precision')->nullable();
|
|
$table->integer('numeric_scale')->nullable();
|
|
$table->string('datetime_precision')->nullable();
|
|
$table->text('comment')->nullable();
|
|
$table->boolean('is_primary_key')->default(false);
|
|
$table->boolean('is_foreign_key')->default(false);
|
|
$table->boolean('is_indexed')->default(false);
|
|
// Column mapping for target database
|
|
$table->string('target_column_name')->nullable();
|
|
$table->string('target_data_type')->nullable();
|
|
$table->boolean('exclude_from_migration')->default(false);
|
|
$table->timestamps();
|
|
|
|
$table->unique(['table_id', 'column_name'], 'unique_column');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('columns');
|
|
}
|
|
};
|