-- drop tables here
DROP TABLE IF EXISTS Account;
DROP TABLE IF EXISTS Tactic;
DROP TABLE IF EXISTS Team;
DROP TABLE IF EXISTS User;
DROP TABLE IF EXISTS Member;
CREATE TABLE Account
(
    id       integer PRIMARY KEY AUTOINCREMENT,
    email    varchar UNIQUE NOT NULL,
    username varchar        NOT NULL,
    token    varchar UNIQUE NOT NULL,
    hash     varchar        NOT NULL
);

CREATE TABLE Tactic
(
    id            integer PRIMARY KEY AUTOINCREMENT,
    name          varchar                             NOT NULL,
    creation_date timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
    owner         integer                             NOT NULL,
    FOREIGN KEY (owner) REFERENCES Account
);

CREATE TABLE FormEntries(name varchar, description varchar);


CREATE TABLE Team
(
    id          integer PRIMARY KEY AUTOINCREMENT,
    name        varchar,
    picture     varchar,
    mainColor   varchar,
    secondColor varchar
);


CREATE TABLE Member(
    idTeam integer,
    idMember integer,
    role     char(1) CHECK (role IN ('C', 'P')),
    FOREIGN KEY (idTeam) REFERENCES Team (id),
    FOREIGN KEY (idMember) REFERENCES User (id)
);
