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

35 lines
1.5 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateReceipts extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'file_path' => ['type' => 'VARCHAR', 'constraint' => 255],
'original_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'mime' => ['type' => 'VARCHAR', 'constraint' => 100],
'merchant' => ['type' => 'VARCHAR', 'constraint' => 190, 'null' => true],
'receipt_date' => ['type' => 'DATE', 'null' => true],
'total' => ['type' => 'DECIMAL', 'constraint' => '12,2', 'null' => true],
'status' => ['type' => 'ENUM', 'constraint' => ['parsing', 'parsed', 'failed', 'imported'], 'default' => 'parsing'],
'raw_json' => ['type' => 'LONGTEXT', 'null' => true],
'error_msg' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('id', true);
$this->forge->addKey('status');
$this->forge->createTable('receipts', true, ['ENGINE' => 'InnoDB']);
}
public function down(): void
{
$this->forge->dropTable('receipts', true);
}
}