-- 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 Admins ( id integer PRIMARY KEY REFERENCES Account ); 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, profile_picture 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, content varchar DEFAULT '{"components": []}' NOT NULL, court_type varchar CHECK ( court_type IN ('HALF', 'PLAIN')) NOT NULL, FOREIGN KEY (owner) REFERENCES Account ); CREATE TABLE Team ( id integer PRIMARY KEY AUTOINCREMENT NOT NULL, name varchar NOT NULL, picture varchar NOT NULL, main_color varchar NOT NULL, second_color varchar NOT NULL ); CREATE TABLE Member ( id_team integer NOT NULL, id_user integer NOT NULL, role text CHECK (role IN ('COACH', 'PLAYER')) NOT NULL, FOREIGN KEY (id_team) REFERENCES Team (id), FOREIGN KEY (id_user) REFERENCES Account (id) );