<?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('subscriptions', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->date('first_billing_date');
            $table->foreignId('client_id')->constrained('clients')->onDelete('cascade');
            $table->enum('repeat_type', ['days', 'weeks', 'months', 'years']);
            $table->decimal('amount_charge', 8, 2);
            $table->text('note')->nullable();
            $table->date('next_billing_date')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('subscriptions');
    }
};
