This commit is contained in:
2026-07-12 19:21:35 +02:00
parent f2d944b117
commit 41cb412cb0
49 changed files with 3170 additions and 52 deletions
@@ -0,0 +1,28 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateReceiptCategoryMap extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'item_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'category_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('id', true);
// Znormalizowana nazwa pozycji jest kluczem uczenia (jedno mapowanie na nazwe).
$this->forge->addUniqueKey('item_name');
$this->forge->addForeignKey('category_id', 'categories', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('receipt_category_map', true, ['ENGINE' => 'InnoDB']);
}
public function down(): void
{
$this->forge->dropTable('receipt_category_map', true);
}
}