CREATE DATABASE IF NOT EXISTS cashflow_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE cashflow_db;

CREATE TABLE IF NOT EXISTS transactions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  tx_date DATE NOT NULL,
  type ENUM('masuk','keluar') NOT NULL,
  category VARCHAR(100) NOT NULL,
  note VARCHAR(255) NULL,
  amount BIGINT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_tx_date ON transactions(tx_date);
CREATE INDEX idx_type ON transactions(type);
