CREATE TABLE users
(
    id      SERIAL PRIMARY KEY,
    name    TEXT             NOT NULL,
    weight  DOUBLE PRECISION NOT NULL DEFAULT 10.0,
    balance BIGINT           NOT NULL DEFAULT 0
);

CREATE TABLE history
(
    id          SERIAL PRIMARY KEY,
    user_id     INTEGER NOT NULL,
    timestamp   BIGINT  NOT NULL,
    amount      BIGINT  NOT NULL,
    description TEXT
);

CREATE TABLE allowances
(
    id      SERIAL PRIMARY KEY,
    user_id INTEGER          NOT NULL,
    name    TEXT             NOT NULL,
    target  BIGINT           NOT NULL,
    balance BIGINT           NOT NULL DEFAULT 0,
    weight  DOUBLE PRECISION NOT NULL,
    colour  INTEGER
);

CREATE TABLE tasks
(
    id        SERIAL PRIMARY KEY,
    name      TEXT   NOT NULL,
    reward    BIGINT NOT NULL,
    assigned  INTEGER,
    schedule  TEXT,
    completed BIGINT,
    next_run  BIGINT
);

INSERT INTO users (name)
VALUES ('Seeseemelk'),
       ('Huffle');
