Subversion-Projekte lars-tiefland.zeldi.de_alt

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?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(): void
        {
            if ( !Schema::hasTable( 'items' ) )
            {
                Schema::create( 'items', function ( Blueprint $table )
                {
                    $table->id();
                    $table->foreignId( "manufacturer_id" )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
                    $table->foreignId( "directory_id" )->unsigned( false )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
                    $table->foreignId( "shipping_group_id" )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
                    $table->string( "name" )->default( '' );
                    $table->string( "slug" )->default( '' );
                    $table->unsignedTinyInteger( 'status' )->default( '0' );
                    $table->float( 'weight' )->default( '0.00' );
                    $table->text( 'description' )->default( '' );
                    $table->string( 'ean', 13 )->default( '' );
                    $table->string( 'kennung' )->default( '' );
                    $table->string( 'short_line_1' )->default( '' );
                    $table->string( 'created_by' )->default( '' );
                    $table->string( 'updated_by' )->default( '' );
                    $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()->after( "name" );
                    $table->foreignId( 'directory_id' )->constrained()->cascadeOnUpdate()->nullOnDelete();
                } );
            }
        }

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