summaryrefslogtreecommitdiffstats
path: root/migrations/2020-06-07-161450_create_transaction/up.sql
blob: fb81016d085c12c936a5fe121eb25d775fdb7efa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
CREATE TABLE transactions (
    id SERIAL NOT NULL PRIMARY KEY,
    `date` timestamp NOT NULL DEFAULT current_timestamp(),
    sender bigint UNSIGNED NOT NULL,
    receiver bigint UNSIGNED NOT NULL,
    amount bigint UNSIGNED NOT NULL,
    sender_balance bigint UNSIGNED NOT NULL,
    receiver_balance bigint UNSIGNED NOT NULL,
    purpose varchar(70) NOT NULL,
    CONSTRAINT fk_sender_id FOREIGN KEY (sender) REFERENCES users (id),
    CONSTRAINT fk_receiver_id FOREIGN KEY (receiver) REFERENCES users (id)
);