-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
636 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.00-schema/00-schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CREATE SCHEMA IF NOT EXISTS register; | ||
|
15 changes: 5 additions & 10 deletions
15
...Register/src/Altinn.Register.Persistence/Migration/v0.00-schema/01-default-privileges.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
-- grant on tables | ||
ALTER DEFAULT PRIVILEGES FOR USER "${YUNIQL-USER}" IN SCHEMA register | ||
GRANT SELECT, | ||
INSERT, | ||
UPDATE, | ||
REFERENCES, | ||
DELETE, | ||
TRUNCATE, | ||
TRIGGER ON TABLES TO "${APP-USER}"; | ||
ALTER DEFAULT PRIVILEGES FOR USER "${YUNIQL-USER}" IN SCHEMA register GRANT | ||
SELECT | ||
, INSERT, UPDATE, REFERENCES, DELETE, TRUNCATE, TRIGGER ON TABLES TO "${APP-USER}"; | ||
|
||
-- grant on sequences | ||
ALTER DEFAULT PRIVILEGES FOR USER "${YUNIQL-USER}" IN SCHEMA register | ||
GRANT ALL ON SEQUENCES TO "${APP-USER}"; | ||
ALTER DEFAULT PRIVILEGES FOR USER "${YUNIQL-USER}" IN SCHEMA register GRANT ALL ON SEQUENCES TO "${APP-USER}"; | ||
|
12 changes: 12 additions & 0 deletions
12
src/Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.01-party/00-enums.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Enum: register.party_type | ||
CREATE TYPE register.party_type AS ENUM( | ||
'person', | ||
'organization' | ||
); | ||
|
||
-- Enum: register.party_source | ||
CREATE TYPE register.party_source AS ENUM( | ||
'folkeregistered', | ||
'enhetsregisteret' | ||
); | ||
|
6 changes: 6 additions & 0 deletions
6
src/Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.01-party/01-identifiers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Domain: register.person_identifier | ||
CREATE DOMAIN register.person_identifier AS text CONSTRAINT fmtchk CHECK (value ~ '^[0-9]{11}$'); | ||
|
||
-- Domain: register.organization_identifier | ||
CREATE DOMAIN register.organization_identifier AS text CONSTRAINT fmtchk CHECK (value ~ '^[0-9]{9}$'); | ||
|
16 changes: 16 additions & 0 deletions
16
src/Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.01-party/02-address.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- Composite: register._address (private - implementation detail) | ||
CREATE TYPE register._address AS ( | ||
municipal_number text, | ||
municipal_name text, | ||
street_name text, | ||
house_number text, | ||
house_letter text, | ||
apartment_number text, | ||
postal_code text, | ||
city text | ||
); | ||
|
||
-- Domain: register.address | ||
-- No checks at this time, but create a domain so they can be added later | ||
CREATE DOMAIN register.address AS register._address; | ||
|
22 changes: 22 additions & 0 deletions
22
src/Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.01-party/03-party-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Table: register.party | ||
CREATE TABLE register.party( | ||
uuid uuid PRIMARY KEY NOT NULL, | ||
id bigint NOT NULL, | ||
party_type register.party_type NOT NULL, | ||
name text NOT NULL, | ||
person_identifier register.person_identifier, | ||
organization_identifier register.organization_identifier, | ||
created timestamp with time zone NOT NULL, | ||
updated timestamp with time zone NOT NULL, | ||
CONSTRAINT type_identifier_check CHECK ((party_type = 'person'::register.party_type AND person_identifier IS NOT NULL AND organization_identifier IS NULL) OR (party_type = 'organization'::register.party_type AND person_identifier IS NULL AND organization_identifier IS NOT NULL)) | ||
) | ||
TABLESPACE pg_default; | ||
|
||
CREATE UNIQUE INDEX uq_party_uuid ON register.party(uuid) INCLUDE (uuid, id, party_type, name, person_identifier, organization_identifier) TABLESPACE pg_default; | ||
|
||
CREATE UNIQUE INDEX uq_party_id ON register.party(id) INCLUDE (uuid, id, party_type, name, person_identifier, organization_identifier) TABLESPACE pg_default; | ||
|
||
CREATE UNIQUE INDEX uq_person_identifier ON register.party(person_identifier) INCLUDE (uuid, id, party_type, name, person_identifier, organization_identifier) TABLESPACE pg_default; | ||
|
||
CREATE UNIQUE INDEX uq_organization_identifier ON register.party(organization_identifier) INCLUDE (uuid, id, party_type, name, person_identifier, organization_identifier) TABLESPACE pg_default; | ||
|
11 changes: 11 additions & 0 deletions
11
...ister/src/Altinn.Register.Persistence/Migration/v0.01-party/04-party-source-ref-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Table: register.party_source_ref | ||
CREATE TABLE register.party_source_ref( | ||
party_uuid uuid NOT NULL REFERENCES register.party(uuid) ON DELETE CASCADE ON UPDATE CASCADE, | ||
source register.party_source NOT NULL, | ||
source_identifier text NOT NULL, | ||
source_created timestamp with time zone, | ||
source_updated timestamp with time zone, | ||
PRIMARY KEY (party_uuid, source, source_identifier) | ||
) | ||
TABLESPACE pg_default; | ||
|
13 changes: 13 additions & 0 deletions
13
...Altinn.Register/src/Altinn.Register.Persistence/Migration/v0.01-party/05-person-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- Table: register.person | ||
CREATE TABLE register.person( | ||
uuid uuid PRIMARY KEY NOT NULL REFERENCES register.party(uuid) ON DELETE CASCADE ON UPDATE CASCADE, | ||
first_name text NOT NULL, | ||
middle_name text, | ||
last_name text NOT NULL, | ||
address register.address, | ||
mailing_address register.address, | ||
date_of_birth date, | ||
date_of_death date | ||
) | ||
TABLESPACE pg_default; | ||
|
15 changes: 15 additions & 0 deletions
15
....Register/src/Altinn.Register.Persistence/Migration/v0.01-party/06-organization-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Table: register.organization | ||
CREATE TABLE register.organization( | ||
uuid uuid PRIMARY KEY NOT NULL REFERENCES register.party(uuid) ON DELETE CASCADE ON UPDATE CASCADE, | ||
unit_status text, | ||
unit_type text, | ||
telephone_number text, | ||
mobile_number text, | ||
fax_number text, | ||
email_address text, | ||
internet_address text, | ||
mailing_address register.address, | ||
business_address register.address | ||
) | ||
TABLESPACE pg_default; | ||
|
Oops, something went wrong.