-- подключаемся к базе данных
\connect tasks;

CREATE TYPE task_manager.task_status AS ENUM('todo','in_progress','paused','test','review','done');

CREATE TABLE task_manager.task(
  "id" SERIAL PRIMARY KEY UNIQUE,
  "id_sprint" INTEGER NOT NULL,
  "id_user" INTEGER,
  "id_project" INTEGER NOT NULL,
  "title" TEXT NOT NULL,
  "description" TEXT NOT NULL,
  "date_start" DATE DEFAULT now(),
  "duration" INTEGER,
  "status" task_manager.task_status DEFAULT 'todo',
  FOREIGN KEY (id_user) REFERENCES task_manager.user(id) ON DELETE SET NULL,
  FOREIGN KEY (id_sprint) REFERENCES task_manager.sprint(id) ON DELETE SET NULL,
  FOREIGN KEY (id_project) REFERENCES task_manager.project(id) ON DELETE CASCADE
);