Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 597 | Revision 952 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
249 lars 3
    use Illuminate\Database\Migrations\Migration;
4
    use Illuminate\Database\Schema\Blueprint;
5
    use Illuminate\Support\Facades\Schema;
2 lars 6
 
577 lars 7
    return new class extends Migration
2 lars 8
    {
249 lars 9
        /**
10
         * Run the migrations.
11
         *
12
         * @return void
13
         */
14
        public function up(): void
15
        {
16
            if ( !Schema::hasTable( 'items' ) )
17
            {
18
                Schema::create( 'items', function ( Blueprint $table )
19
                {
20
                    $table->id();
584 lars 21
                    $table->foreignId( "manufacturer_id" )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
951 lars 22
                    $table->foreignId( "directory_id" )->unsigned( false )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
23
                    $table->foreignId( "shipping_group_id" )->unsigned( false )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
249 lars 24
                    $table->string( "name" )->default( '' );
25
                    $table->string( "slug" )->default( '' );
26
                    $table->unsignedTinyInteger( 'status' )->default( '0' );
256 lars 27
                    $table->text( 'description' )->default( '' );
249 lars 28
                    $table->string( 'ean', 13 )->default( '' );
29
                    $table->string( 'kennung' )->default( '' );
30
                    $table->string( 'short_line_1' )->default( '' );
278 lars 31
                    $table->string( 'created_by' )->default( '' );
32
                    $table->string( 'updated_by' )->default( '' );
249 lars 33
                    $table->timestamps();
34
                } );
35
            }
36
            if ( !ScHema::hasColumn( 'items', 'name' ) )
37
            {
38
                Schema::table( 'items', function ( Blueprint $table )
39
                {
40
                    $table->string( "name" )->default( '' )->after( 'id' );
41
                } );
42
            }
43
            if ( !ScHema::hasColumn( 'items', 'directory_id' ) )
44
            {
45
                Schema::table( 'items', function ( Blueprint $table )
46
                {
577 lars 47
                    $table->bigInteger( "directory_id" )->nullable()->after( "name" );
584 lars 48
                    $table->foreignId( 'directory_id' )->constrained()->cascadeOnUpdate()->nullOnDelete();
249 lars 49
                } );
50
            }
3 lars 51
        }
249 lars 52
 
53
        /**
54
         * Reverse the migrations.
55
         *
56
         * @return void
57
         */
577 lars 58
        public function down(): void
249 lars 59
        {
60
            Schema::dropIfExists( 'items' );
3 lars 61
        }
577 lars 62
    };