Files
finansePRO/app/Database/Migrations/2026-07-06-200004_AddReceiptIdToOperations.php
T
2026-07-12 19:21:35 +02:00

24 lines
747 B
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddReceiptIdToOperations extends Migration
{
public function up(): void
{
$this->forge->addColumn('operations', [
'receipt_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true, 'after' => 'category_id'],
]);
// Kasacja paragonu nie kasuje operacji, tylko zrywa powiazanie.
$this->forge->addForeignKey('receipt_id', 'receipts', 'id', 'SET NULL', 'SET NULL', 'operations_receipt_id_fk');
}
public function down(): void
{
$this->forge->dropForeignKey('operations', 'operations_receipt_id_fk');
$this->forge->dropColumn('operations', 'receipt_id');
}
}