Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 951 | 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' );
952 lars 27
                    $table->float( 'weight' )->default( '0.00' );
256 lars 28
                    $table->text( 'description' )->default( '' );
249 lars 29
                    $table->string( 'ean', 13 )->default( '' );
30
                    $table->string( 'kennung' )->default( '' );
31
                    $table->string( 'short_line_1' )->default( '' );
278 lars 32
                    $table->string( 'created_by' )->default( '' );
33
                    $table->string( 'updated_by' )->default( '' );
249 lars 34
                    $table->timestamps();
35
                } );
36
            }
37
            if ( !ScHema::hasColumn( 'items', 'name' ) )
38
            {
39
                Schema::table( 'items', function ( Blueprint $table )
40
                {
41
                    $table->string( "name" )->default( '' )->after( 'id' );
42
                } );
43
            }
44
            if ( !ScHema::hasColumn( 'items', 'directory_id' ) )
45
            {
46
                Schema::table( 'items', function ( Blueprint $table )
47
                {
577 lars 48
                    $table->bigInteger( "directory_id" )->nullable()->after( "name" );
584 lars 49
                    $table->foreignId( 'directory_id' )->constrained()->cascadeOnUpdate()->nullOnDelete();
249 lars 50
                } );
51
            }
3 lars 52
        }
249 lars 53
 
54
        /**
55
         * Reverse the migrations.
56
         *
57
         * @return void
58
         */
577 lars 59
        public function down(): void
249 lars 60
        {
61
            Schema::dropIfExists( 'items' );
3 lars 62
        }
577 lars 63
    };