diff --git a/api/person_data.bal b/api/person_data.bal index 24f06e2..d36f70b 100644 --- a/api/person_data.bal +++ b/api/person_data.bal @@ -4,7 +4,7 @@ public distinct service class PersonData { private Person person; isolated function init(string? name = null, int? person_id = 0, Person? person = null) returns error? { - if(person != null) { // if roganization is provided, then use that and do not load from DB + if(person != null) { // if person is provided, then use that and do not load from DB self.person = person.cloneReadOnly(); return; } diff --git a/db/schema/2-avinya_types.sql b/db/schema/2-avinya_types.sql index 819b2f1..ce84967 100644 --- a/db/schema/2-avinya_types.sql +++ b/db/schema/2-avinya_types.sql @@ -3,20 +3,26 @@ USE avinya_db; CREATE TABLE IF NOT EXISTS avinya_type ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, active BOOLEAN NOT NULL, - global_type ENUM("Employee", "Customer", "Volunteer", "Applicant", "Team") NOT NULL, + global_type ENUM("Employee", "Customer", "Volunteer", "Applicant", "Organization", "Team") NOT NULL, name VARCHAR(255), foundation_type ENUM( - "Advisors", + "Executive", + "Advisor", "Educator", "Technology", "Operations", + "HR", "Parent", "Student" ), focus ENUM( - "Bootcamp", - "Healthcare", - "Information Technology" + "Foundation", + "Vocational-IT", + "Vocational-Healthcare", + "Vocational-Hospitality", + "Operations", + "HR", + "Technology" ), level INT ); diff --git a/db/schema/3-organization_and_address_tables.sql b/db/schema/3-organization_and_address_tables.sql index 379121a..bccc090 100644 --- a/db/schema/3-organization_and_address_tables.sql +++ b/db/schema/3-organization_and_address_tables.sql @@ -2,7 +2,7 @@ USE avinya_db; -- Address CREATE TABLE IF NOT EXISTS address ( - id INT NOT NULL PRIMARY KEY, + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, street_address VARCHAR(255) NOT NULL, phone INT, city_id INT NOT NULL, @@ -11,13 +11,13 @@ CREATE TABLE IF NOT EXISTS address ( -- Organization CREATE TABLE IF NOT EXISTS organization ( - id INT NOT NULL PRIMARY KEY, + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name_en VARCHAR(255) NOT NULL, name_ta VARCHAR(255), name_si VARCHAR(255), phone INT, - address_id INT NOT NULL, - avinya_type INT NOT NULL, + address_id INT, + avinya_type INT, FOREIGN KEY (address_id) REFERENCES address(id), FOREIGN KEY (avinya_type) REFERENCES avinya_type(id) ); diff --git a/db/schema/4-person.sql b/db/schema/4-person.sql index 0708405..cc6dda2 100644 --- a/db/schema/4-person.sql +++ b/db/schema/4-person.sql @@ -1,13 +1,25 @@ --- USE avinya_db; +USE avinya_db; --- -- Person --- CREATE TABLE IF NOT EXISTS person ( --- asgardeo_id VARCHAR(255) NOT NULL PRIMARY KEY, --- permanent_address INT NOT NULL, --- mailing_address INT NOT NULL, --- phone INT, --- organization INT, --- FOREIGN KEY (permanent_address) REFERENCES address(id), --- FOREIGN KEY (mailing_address) REFERENCES address(id), --- FOREIGN KEY (organization) REFERENCES organization(id), --- ); +-- Person +CREATE TABLE IF NOT EXISTS person ( + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + preferred_name VARCHAR(512) NOT NULL, + full_name VARCHAR(1024) DEFAULT NULL, + date_of_birth DATE DEFAULT NULL, + sex ENUM ("Male", "Female", "Not Specified") DEFAULT "Not Specified", + asgardeo_id VARCHAR(255) DEFAULT NULL, + permanent_address_id INT DEFAULT NULL, + mailing_address_id INT DEFAULT NULL, + phone INT DEFAULT 0, + organization_id INT DEFAULT NULL, + avinya_type_id INT DEFAULT NULL, + notes VARCHAR(1024) DEFAULT NULL, + nic_no VARCHAR(30) DEFAULT NULL, + passport_no VARCHAR(30) DEFAULT NULL, + id_no VARCHAR(30) DEFAULT NULL, + email VARCHAR(254) DEFAULT NULL, + FOREIGN KEY (permanent_address_id) REFERENCES address(id), + FOREIGN KEY (mailing_address_id) REFERENCES address(id), + FOREIGN KEY (organization_id) REFERENCES organization(id), + FOREIGN KEY (avinya_type_id) REFERENCES avinya_type(id) +);