-- -- Created by SQL::Translator::Producer::PostgreSQL -- Created on Thu Jul 21 10:44:35 2022 -- ; -- -- Table: session -- CREATE TABLE "session" ( "id" serial NOT NULL, "user_id" integer NOT NULL, "state" json DEFAULT '{}'::json, PRIMARY KEY ("id") ); ; -- -- Table: user -- CREATE TABLE "user" ( "id" serial NOT NULL, "email" text NOT NULL, "name" text NOT NULL, "passw" text NOT NULL, "telegram_xid" integer NOT NULL, PRIMARY KEY ("id") ); ; -- -- Table: tracker -- CREATE TABLE "tracker" ( "id" serial NOT NULL, "user_id" integer NOT NULL, "type" text NOT NULL, "url" text NOT NULL, "name" text, "key" text NOT NULL, "me_id" integer NOT NULL, "options" json DEFAULT '{}'::json NOT NULL, PRIMARY KEY ("id") ); CREATE INDEX "tracker_idx_user_id" on "tracker" ("user_id"); ; -- -- Table: time -- CREATE TABLE "time" ( "id" serial NOT NULL, "ctime" timestamptz NOT NULL, "user_id" integer NOT NULL, "tracker_id" integer NOT NULL, "project_xid" integer NOT NULL, "task_xid" integer NOT NULL, "comment" text NOT NULL, PRIMARY KEY ("id") ); CREATE INDEX "time_idx_tracker_id" on "time" ("tracker_id"); CREATE INDEX "time_idx_user_id" on "time" ("user_id"); ; -- -- Foreign Key Definitions -- ; ALTER TABLE "tracker" ADD CONSTRAINT "tracker_fk_user_id" FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; ; ALTER TABLE "time" ADD CONSTRAINT "time_fk_tracker_id" FOREIGN KEY ("tracker_id") REFERENCES "tracker" ("id") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; ; ALTER TABLE "time" ADD CONSTRAINT "time_fk_user_id" FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; ;