-- Create transactions table for transaction history
CREATE TABLE transactions (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    amount BIGINT NOT NULL COMMENT 'Amount in bigint format (positive for credits, negative for debits)',
    type VARCHAR(50) NOT NULL COMMENT 'Transaction type: DEPOSIT, WITHDRAWAL, TASK_BONUS, CANCELLATION_OF_WITHDRAWAL',
    task_id INT NULL COMMENT 'Task ID for TASK_BONUS type',
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_user_id_created_at (user_id, created_at DESC),
    INDEX idx_user_id_type (user_id, type),
    FOREIGN KEY (user_id) REFERENCES db_users_a(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



