Teren-app/database/migrations/2024_10_20_113420_create_contracts_table.php
Simon Pocrnjič 90a5858320 first commit
2024-10-28 21:08:16 +01:00

48 lines
1.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('contract_types', function(Blueprint $table){
$table->id();
$table->string('name',50);
$table->string('description',125)->nullable();
$table->unsignedTinyInteger('deleted')->default(0);
$table->timestamps();
});
Schema::create('contracts', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('reference', 125)->nullable();
$table->date('start_date');
$table->date('end_date')->nullable();
$table->string('description', 255)->nullable();
$table->foreignIdFor(\App\Models\Person\Person::class, 'client_id');
$table->foreignIdFor(\App\Models\Person\Person::class, 'debtor_id');
$table->foreignId('type_id')->references('id')->on('contract_types');
$table->unsignedTinyInteger('active')->default(1);
$table->unsignedTinyInteger('deleted')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('contract_types');
Schema::dropIfExists('contracts');
}
};