inventur/database/migrations/2021_07_10_000000_add_bons.php
2021-07-18 01:04:13 +02:00

64 lines
1.4 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;
class AddBons extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$builder = Capsule::schema();
$builder->table('articles', function($table) {
$table->softDeletes();
});
$builder->create(
'bons',
function ($table) {
$table->increments('id');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
}
);
$builder->create(
'bonitems',
function ($table) {
$table->increments('id');
$table->unsignedInteger('bon_id');
$table->foreign('bon_id')->references('id')->on('bons');
$table->unsignedInteger('article_id');
$table->foreign('article_id')->references('id')->on('articles');
$table->unsignedInteger('count');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$builder = Capsule::schema();
$builder->table('articles', function($table) {
$table->dropSoftDeletes();
});
$builder->drop('bons');
$builder->drop('bonitems');
}
}