web/database/migrations/2024_03_30_000032_create_la...

47 lines
1.2 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('land', function (Blueprint $table) {
$table->unsignedInteger('id', true)->primary();
$table->integer('map_index');
$table->integer('x');
$table->integer('y');
$table->integer('width');
$table->integer('height');
$table->unsignedInteger('guild_id')->nullable();
$table->tinyInteger('guild_level_limit');
$table->unsignedInteger('price')->default(0);
$table->enum('enable', ['YES', 'NO'])->default('NO');
$table->foreign('guild_id')->references('id')->on('guild');
});
// Populate the table data
$data = File::json(database_path('data/land.json'));
\App\Models\Game\Player\Land::upsert($data, ['id']);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('land');
}
};