USE bank_bkj;

CREATE TABLE categories (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

ALTER TABLE transactions ADD COLUMN category_id INT NULL;

ALTER TABLE transactions
ADD CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories (id) ON DELETE SET NULL;

INSERT INTO
    categories (name)
VALUES ('Gaji'),
    ('Bonus'),
    ('Denda'),
    ('Bayar Piutang'),
    ('Kebutuhan Kantor'),
    ('Lainnya');