24 lines
747 B
PHP
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');
|
|
}
|
|
}
|