Skip to content

Commit

Permalink
feat: validation schema updates (#241)
Browse files Browse the repository at this point in the history
* feat: validation schema updates

* fix: circular dependency

* fix: update liquibase/changes/feat_240.sql

Co-authored-by: David Gamez <[email protected]>

* fix: update liquibase/changes/feat_240.sql

Co-authored-by: David Gamez <[email protected]>

---------

Co-authored-by: David Gamez <[email protected]>
  • Loading branch information
cka-y and davidgamez authored Jan 18, 2024
1 parent afd376f commit f8c14ff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions liquibase/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<include file="changes/feat_77.sql" relativeToChangelogFile="true"/>
<include file="changes/feat_88.sql" relativeToChangelogFile="true"/>
<include file="changes/feat_149.sql" relativeToChangelogFile="true"/>
<include file="changes/feat_240.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
29 changes: 29 additions & 0 deletions liquibase/changes/feat_240.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- 1. Add Table ValidationReport
CREATE TABLE ValidationReport (
id VARCHAR(255) PRIMARY KEY,
validator_version VARCHAR(255)
);

-- 2. Adding a table linking GTFSDataset to the validation report to avoid circular dependency warning from sqlacodegen
CREATE TABLE ValidationReportGTFSDataset (
dataset_id VARCHAR(255) REFERENCES GTFSDataset(id),
validation_report_id VARCHAR(255) REFERENCES ValidationReport UNIQUE,
PRIMARY KEY (validation_report_id, dataset_id)
);

-- 3. Create custom type for severity
CREATE TYPE severity_type AS ENUM ('ERROR', 'WARNING', 'INFO');

-- 4. Add Table Notice
CREATE TABLE Notice (
dataset_id VARCHAR(255) REFERENCES GTFSDataset(id),
validation_report_id VARCHAR(255) REFERENCES ValidationReport(id),
notice_code VARCHAR(255),
severity severity_type,
total_notices INT NOT NULL CHECK (total_notices > 0),
PRIMARY KEY (dataset_id, validation_report_id, notice_code)
);

-- 5. Add indexes for the Notice table
CREATE INDEX idx_notice_dataset_id ON Notice(dataset_id);
CREATE INDEX idx_notice_dataset_id_validation_id ON Notice(dataset_id, validation_report_id);

0 comments on commit f8c14ff

Please sign in to comment.