Added IO_type migration.

Changed person_targets migration to use a foreign key to the io_types table
instead of an enum.
This commit is contained in:
Lukas Halbritter
2018-09-07 10:15:07 +02:00
parent 9a1983d42f
commit cc111ca2ed
3 changed files with 47 additions and 1 deletions
@@ -31,7 +31,9 @@ class CreatePersonTargetsTable extends Migration
// The type of the target. It can be either a payable or a
// receivable. A payable is of type 'expediture' and a receivable is
// of type 'income'.
$table->tinyInteger('io_type');
$table->integer('io_type')->unsigned();
$table->foreign('io_type')->references('id')->on('io_types')
->onDelete('no action');
// A reference text which describes the target
$table->string('reference');
@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateIOTypesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('io_types', function (Blueprint $table) {
$table->increments('id');
$table->string('type')
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('io_types');
}
}