invoiceninja/app/Console/Commands/stubs/migration/create.stub

45 lines
1.2 KiB
Text
Raw Normal View History

2016-12-08 15:41:35 +02:00
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class $CLASS$ extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
2016-12-08 20:00:13 +02:00
Schema::create(strtolower('$TABLE$'), function (Blueprint $table) {
2016-12-08 15:41:35 +02:00
$table->increments('id');
$table->unsignedInteger('user_id')->index();
$table->unsignedInteger('account_id')->index();
$table->unsignedInteger('client_id')->index()->nullable();
2016-12-08 20:00:13 +02:00
2016-12-08 15:41:35 +02:00
$FIELDS$
$table->timestamps();
2016-12-08 20:00:13 +02:00
$table->softDeletes();
2016-12-08 15:41:35 +02:00
$table->boolean('is_deleted')->default(false);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
$table->unsignedInteger('public_id')->index();
$table->unique( ['account_id', 'public_id'] );
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
2016-12-08 20:00:13 +02:00
Schema::dropIfExists(strtolower('$TABLE$'));
2016-12-08 15:41:35 +02:00
}
}