CREATE TABLE transactions (
    id              INT NOT NULL PRIMARY KEY AUTO_INCREMENT,

    updated_at      DATETIME NOT NULL,
    created_at      DATETIME NOT NULL,

    updated_by      CHAR(36) DEFAULT NULL,
    INDEX updated_by_index (updated_by),
    FOREIGN KEY (updated_by) REFERENCES users(id),
    created_by      CHAR(36) DEFAULT NULL,
    INDEX created_by_index (created_by),
    FOREIGN KEY (created_by) REFERENCES users(id),

    currency        ENUM('EUR', 'CHF', 'USD') NOT NULL DEFAULT 'EUR',
    gross_amount    FLOAT(10, 2)   NOT NULL DEFAULT 0.00,
    net_amount      FLOAT(10, 2)   NOT NULL DEFAULT 0.00,
    type            ENUM('payment', 'refund') NOT NULL DEFAULT 'payment',
    status          ENUM('ok', 'pending', 'canceled', 'error') NOT NULL DEFAULT 'pending',
    error           TEXT DEFAULT NULL,
    ref             VARCHAR(128) DEFAULT NULL,
    buyer_email     VARCHAR(128) DEFAULT NULL,
    buyer_phone     VARCHAR(128) DEFAULT NULL,
    card_number     VARCHAR(24) NULL,
    description     TEXT DEFAULT NULL,
    payment_method  TEXT DEFAULT NULL,
    receipt_url     VARCHAR(256) DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
