mirror of
https://github.com/xfarrow/blink
synced 2025-03-18 12:30:04 +01:00
add sql
This commit is contained in:
parent
711e6d210a
commit
e36091bb05
13
backend/sql/0-create_databse.sql
Normal file
13
backend/sql/0-create_databse.sql
Normal file
@ -0,0 +1,13 @@
|
||||
-- Database: Blink
|
||||
|
||||
-- DROP DATABASE IF EXISTS "Blink";
|
||||
|
||||
CREATE DATABASE "Blink"
|
||||
WITH
|
||||
OWNER = pg_database_owner
|
||||
ENCODING = 'UTF8'
|
||||
LC_COLLATE = 'Italian_Italy.1252'
|
||||
LC_CTYPE = 'Italian_Italy.1252'
|
||||
TABLESPACE = pg_default
|
||||
CONNECTION LIMIT = -1
|
||||
IS_TEMPLATE = False;
|
21
backend/sql/1-create_person.sql
Normal file
21
backend/sql/1-create_person.sql
Normal file
@ -0,0 +1,21 @@
|
||||
-- Table: public.Person
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Person";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Person"
|
||||
(
|
||||
id integer NOT NULL DEFAULT nextval('"Person_id_seq"'::regclass),
|
||||
email character varying(128) COLLATE pg_catalog."default" NOT NULL,
|
||||
password character varying(128) COLLATE pg_catalog."default" NOT NULL,
|
||||
displayname character varying(128) COLLATE pg_catalog."default" NOT NULL,
|
||||
date_of_birth date,
|
||||
available boolean,
|
||||
enabled boolean NOT NULL DEFAULT false,
|
||||
place_of_living character varying(128) COLLATE pg_catalog."default",
|
||||
CONSTRAINT "Person_pkey" PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Person"
|
||||
OWNER to pg_database_owner;
|
19
backend/sql/2-create_activation_link.sql
Normal file
19
backend/sql/2-create_activation_link.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- Table: public.ActivationLink
|
||||
|
||||
-- DROP TABLE IF EXISTS public."ActivationLink";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."ActivationLink"
|
||||
(
|
||||
identifier character varying COLLATE pg_catalog."default" NOT NULL,
|
||||
person_id integer NOT NULL,
|
||||
CONSTRAINT "ActivationLink_pkey" PRIMARY KEY (identifier),
|
||||
CONSTRAINT "PersonActivationLinkFK" FOREIGN KEY (person_id)
|
||||
REFERENCES public."Person" (id) MATCH SIMPLE
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."ActivationLink"
|
||||
OWNER to pg_database_owner;
|
18
backend/sql/3-create_organization.sql
Normal file
18
backend/sql/3-create_organization.sql
Normal file
@ -0,0 +1,18 @@
|
||||
-- Table: public.Organization
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Organization";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Organization"
|
||||
(
|
||||
id integer NOT NULL DEFAULT nextval('"Organization_id_seq"'::regclass),
|
||||
name character varying(128) COLLATE pg_catalog."default" NOT NULL,
|
||||
location character varying COLLATE pg_catalog."default",
|
||||
description text COLLATE pg_catalog."default",
|
||||
is_hiring boolean,
|
||||
CONSTRAINT "Organization_pkey" PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Organization"
|
||||
OWNER to pg_database_owner;
|
21
backend/sql/4-create_organization_post.sql
Normal file
21
backend/sql/4-create_organization_post.sql
Normal file
@ -0,0 +1,21 @@
|
||||
-- Table: public.OrganizationPost
|
||||
|
||||
-- DROP TABLE IF EXISTS public."OrganizationPost";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."OrganizationPost"
|
||||
(
|
||||
id integer NOT NULL DEFAULT nextval('"OrganizationPost_id_seq"'::regclass),
|
||||
organization_id integer NOT NULL,
|
||||
content text COLLATE pg_catalog."default" NOT NULL,
|
||||
CONSTRAINT "OrganizationPost_pkey" PRIMARY KEY (id),
|
||||
CONSTRAINT "OrganizationIdFk" FOREIGN KEY (organization_id)
|
||||
REFERENCES public."Organization" (id) MATCH SIMPLE
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
NOT VALID
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."OrganizationPost"
|
||||
OWNER to postgres;
|
24
backend/sql/5-create_organization_administrator.sql
Normal file
24
backend/sql/5-create_organization_administrator.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- Table: public.OrganizationAdministrator
|
||||
|
||||
-- DROP TABLE IF EXISTS public."OrganizationAdministrator";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."OrganizationAdministrator"
|
||||
(
|
||||
id_person integer NOT NULL,
|
||||
id_organization integer NOT NULL,
|
||||
CONSTRAINT "OrganizationAdministrator_pkey" PRIMARY KEY (id_organization, id_person),
|
||||
CONSTRAINT "OrganizationAdministratorOrganizationId" FOREIGN KEY (id_organization)
|
||||
REFERENCES public."Organization" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
NOT VALID,
|
||||
CONSTRAINT "OrganizationAdministratorUserId" FOREIGN KEY (id_person)
|
||||
REFERENCES public."Person" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."OrganizationAdministrator"
|
||||
OWNER to pg_database_owner;
|
Loading…
x
Reference in New Issue
Block a user