Revision 66 | Revision 168 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpuse Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;class CreateItemsTable extends Migration{/*** Run the migrations.** @return void*/public function up(): void{if (!Schema::hasTable('items')) {Schema::create('items', function (Blueprint $table) {$table->id();$table->string("name")->default('');$table->bigInteger("directory_id")->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();$table->timestamps();});}if (!ScHema::hasColumn('items', 'name')) {Schema::table('items', function (Blueprint $table) {$table->string("name")->default('')->after('id');});}if (!ScHema::hasColumn('items', 'directory_id')) {Schema::table('items', function (Blueprint $table) {$table->bigInteger("directory_id")->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete()->after("name");});}}/*** Reverse the migrations.** @return void*/publicfunction down(): void{Schema::dropIfExists('items');}}