update SQL to create database

This commit is contained in:
xfarrow 2024-10-21 12:46:24 +02:00
parent 6023ee56d0
commit b0bfd1fe59
1 changed files with 39 additions and 5 deletions

View File

@ -4,6 +4,7 @@ CREATE TYPE RemotePosition as ENUM ('YES', 'NO', 'NOT_SPECIFIED', 'PARTIALLY');
CREATE TYPE ContractType as ENUM ('FULL-TIME','PART-TIME','INTERNSHIP','CONTRACT','FREELANCE','TEMPORARY','SEASONAL','APPRENTICESHIP','VOLUNTEER','ZERO-HOURS','FIXED-TERM','CASUAL','PROBATIONARY','SECONDMENT','JOB-SHARING'); CREATE TYPE ContractType as ENUM ('FULL-TIME','PART-TIME','INTERNSHIP','CONTRACT','FREELANCE','TEMPORARY','SEASONAL','APPRENTICESHIP','VOLUNTEER','ZERO-HOURS','FIXED-TERM','CASUAL','PROBATIONARY','SECONDMENT','JOB-SHARING');
CREATE TYPE ExperienceType as ENUM ('EDUCATION', 'WORK', 'VOLOUNTEER'); CREATE TYPE ExperienceType as ENUM ('EDUCATION', 'WORK', 'VOLOUNTEER');
CREATE TYPE SalaryFrequency as ENUM ('WEEKLY', 'YEARLY'); CREATE TYPE SalaryFrequency as ENUM ('WEEKLY', 'YEARLY');
CREATE TYPE InfoType AS ENUM ('EMAIL', 'PHONE', 'WEBSITE', 'GIT', 'MASTODON', 'YOUTUBE', 'FACEBOOK', 'INSTAGRAM', 'OTHER');
-- Table: Person -- Table: Person
CREATE TABLE IF NOT EXISTS "Person" ( CREATE TABLE IF NOT EXISTS "Person" (
@ -31,9 +32,8 @@ CREATE TABLE IF NOT EXISTS "ActivationLink" (
CREATE TABLE IF NOT EXISTS "Organization" ( CREATE TABLE IF NOT EXISTS "Organization" (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name CHARACTER VARYING(128) NOT NULL, name CHARACTER VARYING(128) NOT NULL,
location CHARACTER VARYING, location CHARACTER VARYING(256),
description TEXT, description CHARACTER VARYING(4096)
is_hiring BOOLEAN
); );
-- Table: OrganizationAdministrator -- Table: OrganizationAdministrator
@ -57,7 +57,8 @@ CREATE TABLE IF NOT EXISTS "JobOffer" (
organization_id INTEGER, organization_id INTEGER,
title CHARACTER VARYING(2048) NOT NULL, title CHARACTER VARYING(2048) NOT NULL,
description CHARACTER VARYING(4096), description CHARACTER VARYING(4096),
salary int4range, salary int4range,
salary_frequency SalaryFrequency,
salary_currency SalaryCurrency, salary_currency SalaryCurrency,
location CHARACTER VARYING(256), location CHARACTER VARYING(256),
remote RemotePosition NOT NULL, remote RemotePosition NOT NULL,
@ -98,7 +99,7 @@ CREATE TABLE IF NOT EXISTS "RequestResetPassword" (
id SERIAL, id SERIAL,
email CHARACTER VARYING(128) NOT NULL, email CHARACTER VARYING(128) NOT NULL,
secret CHARACTER VARYING NOT NULL, secret CHARACTER VARYING NOT NULL,
time_of_request timestamp without time zone NOT NULL DEFAULT now(), time_of_request TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
CONSTRAINT "RequestResetPassword_pkey" PRIMARY KEY (id) CONSTRAINT "RequestResetPassword_pkey" PRIMARY KEY (id)
); );
@ -115,3 +116,36 @@ CREATE TABLE IF NOT EXISTS "Experience" (
CONSTRAINT "OrganizationFk" FOREIGN KEY (organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT "OrganizationFk" FOREIGN KEY (organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT "PersonFk" FOREIGN KEY (person_id) REFERENCES "Person" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE CONSTRAINT "PersonFk" FOREIGN KEY (person_id) REFERENCES "Person" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
); );
-- Table: Message
CREATE TABLE IF NOT EXISTS "Message" (
id SERIAL PRIMARY KEY,
sender_id INTEGER NOT NULL,
sender_organization_id INTEGER NOT NULL,
receiver_id INTEGER,
receiver_organization_id INTEGER,
content CHARACTER VARYING(4096) NOT NULL,
timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL,
CONSTRAINT "SenderFK" FOREIGN KEY (sender_id) REFERENCES "Person" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "ReceiverFK" FOREIGN KEY (receiver_id) REFERENCES "Person" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "OrganizationSender" FOREIGN KEY (sender_organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "OrganizationReceiver" FOREIGN KEY (receiver_organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
);
-- Table: PersonContactInfo
CREATE TABLE IF NOT EXISTS "PersonContactInfo" (
id SERIAL PRIMARY KEY,
person_id INTEGER NOT NULL,
info CHARACTER VARYING(128) NOT NULL,
info_type InfoType NOT NULL,
CONSTRAINT "PersonFK" FOREIGN KEY (person_id) REFERENCES "Person" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
);
-- Table: OrganizationContactInfo
CREATE TABLE IF NOT EXISTS "OrganizationContactInfo" (
id SERIAL PRIMARY KEY,
organization_id INTEGER NOT NULL,
info CHARACTER VARYING(128) NOT NULL,
info_type InfoType NOT NULL,
CONSTRAINT "OrganizationFK" FOREIGN KEY (organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
)