CREATE TABLE `person` (
`person_id` ULID PRIMARY KEY NOT NULL,
`party_id` text NOT NULL,
`person_type_id` ULID NOT NULL,
`person_first_name` text NOT NULL,
`person_middle_name` text,
`person_last_name` text NOT NULL,
`previous_name` text,
`honorific_prefix` text,
`honorific_suffix` text,
`gender_id` ULID NOT NULL,
`sex_id` ULID NOT NULL,
`elaboration` text,
`created_at` TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
`created_by` text DEFAULT 'UNKNOWN',
`updated_at` TIMESTAMPTZ,
`updated_by` text,
`deleted_at` TIMESTAMPTZ,
`deleted_by` text,
`activity_log` text,
FOREIGN KEY (`party_id`) REFERENCES `party`(`party_id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`person_type_id`) REFERENCES `person_type`(`person_type_id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`gender_id`) REFERENCES `gender_type`(`gender_type_id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`sex_id`) REFERENCES `sex_type`(`sex_type_id`) ON UPDATE no action ON DELETE no action,
CONSTRAINT "elaboration_check_valid_json" CHECK(json_valid("person"."elaboration") OR "person"."elaboration" IS NULL)
)