Subversion-Projekte lars-tiefland.laravel_shop

Revision

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