<?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('records', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('schema');
            $table->string('status');
            $table->jsonb('data');
            $table->jsonb('_sys');
            $table->jsonb('_file');

            $table->index(['schema', 'status']);
        });

        Schema::create('edges', function (Blueprint $table) {
            $table->uuid('source');
            $table->uuid('target');
            $table->string('sourceSchema');
            $table->string('targetSchema');
            $table->string('field');
            $table->string('rank');

            $table->unique(['source', 'target', "field"]);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('records');
        Schema::dropIfExists('edges');
    }
};
