| 4 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
use Illuminate\Database\Migrations\Migration;
|
|
|
4 |
use Illuminate\Database\Schema\Blueprint;
|
|
|
5 |
use Illuminate\Support\Facades\Schema;
|
|
|
6 |
|
|
|
7 |
return new class extends Migration
|
|
|
8 |
{
|
|
|
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();
|
|
|
21 |
$table->foreignId( "manufacturer_id" )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
|
|
|
22 |
$table->foreignId( "directory_id" )->unsigned( false )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
|
|
|
23 |
$table->foreignId( "shipping_group_id" )->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
|
|
|
24 |
$table->string( "name" )->default( '' );
|
|
|
25 |
$table->string( "slug" )->default( '' );
|
|
|
26 |
$table->unsignedTinyInteger( 'status' )->default( '0' );
|
|
|
27 |
$table->float( 'weight' )->default( '0.00' );
|
|
|
28 |
$table->text( 'description' )->default( '' );
|
|
|
29 |
$table->string( 'ean', 13 )->default( '' );
|
|
|
30 |
$table->string( 'kennung' )->default( '' );
|
|
|
31 |
$table->string( 'short_line_1' )->default( '' );
|
|
|
32 |
$table->string( 'created_by' )->default( '' );
|
|
|
33 |
$table->string( 'updated_by' )->default( '' );
|
|
|
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 |
{
|
|
|
48 |
$table->bigInteger( "directory_id" )->nullable()->after( "name" );
|
|
|
49 |
$table->foreignId( 'directory_id' )->constrained()->cascadeOnUpdate()->nullOnDelete();
|
|
|
50 |
} );
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Reverse the migrations.
|
|
|
56 |
*
|
|
|
57 |
* @return void
|
|
|
58 |
*/
|
|
|
59 |
public function down(): void
|
|
|
60 |
{
|
|
|
61 |
Schema::dropIfExists( 'items' );
|
|
|
62 |
}
|
|
|
63 |
};
|