First Commit
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2025 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Create Cash Flow Tables
|
||||
*/
|
||||
class CreateCashFlowTables
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Categorias de Fluxo de Caixa
|
||||
if (!Capsule::schema()->hasTable('cash_flow_categories')) {
|
||||
Capsule::schema()->create('cash_flow_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('idbus')->nullable();
|
||||
$table->unsignedBigInteger('iduser')->nullable();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['income', 'expense']);
|
||||
$table->string('color')->default('#6c757d');
|
||||
$table->string('icon')->default('bi bi-tag');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('idbus');
|
||||
$table->index('iduser');
|
||||
});
|
||||
}
|
||||
|
||||
// Transações de Fluxo de Caixa
|
||||
if (!Capsule::schema()->hasTable('cash_flow_transactions')) {
|
||||
Capsule::schema()->create('cash_flow_transactions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('idbus')->nullable();
|
||||
$table->unsignedBigInteger('iduser')->nullable();
|
||||
$table->unsignedBigInteger('category_id');
|
||||
$table->string('description');
|
||||
$table->decimal('amount', 15, 2);
|
||||
$table->enum('type', ['income', 'expense']);
|
||||
$table->enum('status', ['pending', 'paid', 'cancelled'])->default('pending');
|
||||
$table->date('transaction_date');
|
||||
$table->date('due_date')->nullable();
|
||||
$table->date('payment_date')->nullable();
|
||||
$table->boolean('is_personal')->default(false);
|
||||
$table->text('notes')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('idbus');
|
||||
$table->index('iduser');
|
||||
$table->index('category_id');
|
||||
$table->index('transaction_date');
|
||||
});
|
||||
}
|
||||
|
||||
// Análises e Previsões (IA)
|
||||
if (!Capsule::schema()->hasTable('cash_flow_analysis')) {
|
||||
Capsule::schema()->create('cash_flow_analysis', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('idbus')->nullable();
|
||||
$table->unsignedBigInteger('iduser')->nullable();
|
||||
$table->date('analysis_date');
|
||||
$table->json('summary_data');
|
||||
$table->text('recommendations')->nullable();
|
||||
$table->json('projections')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('idbus');
|
||||
$table->index('iduser');
|
||||
$table->index('analysis_date');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Capsule::schema()->dropIfExists('cash_flow_analysis');
|
||||
Capsule::schema()->dropIfExists('cash_flow_transactions');
|
||||
Capsule::schema()->dropIfExists('cash_flow_categories');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user