-- public.job_queues definition

-- Drop table

-- DROP TABLE public.job_queues;

CREATE TABLE public.job_queues (
	id serial4 NOT NULL,
	queue_category varchar(64) NOT NULL,
	queue_name varchar(64) NOT NULL,
	status int4 NULL,
	CONSTRAINT job_queues_pkey PRIMARY KEY (id)
);


-- public.jobs definition

-- Drop table

-- DROP TABLE public.jobs;

CREATE TABLE public.jobs (
	id serial4 NOT NULL,
	job_category varchar(64) NOT NULL,
	job_name varchar(64) NULL,
	job_details text NOT NULL,
	job_creator varchar(64) NOT NULL,
	job_logs text NULL,
	job_files varchar(300) NULL,
	created timestamp NOT NULL,
	updated timestamp NOT NULL,
	status int4 NULL,
	executor varchar(64) NULL,
	CONSTRAINT jobs_pkey PRIMARY KEY (id)
);


-- public.users definition

-- Drop table

-- DROP TABLE public.users;

CREATE TABLE public.users (
	id int4 DEFAULT nextval('user_id_seq'::regclass) NOT NULL,
	username varchar(32) NOT NULL,
	full_name varchar(64) NOT NULL,
	email varchar(100) NOT NULL,
	hashed_password varchar(64) NOT NULL,
	status int4 DEFAULT 0 NOT NULL
);
CREATE UNIQUE INDEX users_id_idx ON public.users USING btree (id);


-- public.queue_job definition

-- Drop table

-- DROP TABLE public.queue_job;

CREATE TABLE public.queue_job (
	id serial4 NOT NULL,
	queue_id int4 NOT NULL,
	job_id int4 NOT NULL,
	CONSTRAINT queue_job_pkey PRIMARY KEY (id),
	CONSTRAINT queue_job_job_id_fkey FOREIGN KEY (job_id) REFERENCES public.jobs(id),
	CONSTRAINT queue_job_queue_id_fkey FOREIGN KEY (queue_id) REFERENCES public.job_queues(id)
);


-- public.sessions definition

-- Drop table

-- DROP TABLE public.sessions;

CREATE TABLE public.sessions (
	id serial4 NOT NULL,
	user_id int4 NULL,
	session_id varchar(64) NOT NULL,
	created timestamp NULL,
	updated timestamp NULL,
	username varchar(32) NULL,
	full_name varchar(64) NULL,
	CONSTRAINT sessions_pkey PRIMARY KEY (id),
	CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id)
);