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

51 lines
1.6 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('debt_types', function(Blueprint $table){
$table->id();
$table->string('name',50)->unique();
$table->string('description',125)->nullable();
$table->unsignedTinyInteger('deleted')->default(0);
$table->timestamps();
});
Schema::create('debts', function (Blueprint $table) {
$table->id();
$table->string('reference',125)->nullable();
$table->string('invoice_nu',125)->nullable();
$table->date('issue_date')->nullable();
$table->date('due_date')->nullable();
$table->decimal('amount', 11, 4)->nullable();
$table->decimal('interest', 11, 8)->nullable();
$table->date('interest_start_date')->nullable();
$table->string('description',125)->nullable();
$table->foreignId('account_id')->references('id')->on('accounts');
$table->foreignId('type_id')->references('id')->on('debt_types');
$table->unsignedTinyInteger('active')->default(1);
$table->unsignedTinyInteger('deleted')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('debt_types');
Schema::dropIfExists('debts');
}
};