Skip to content

Commit

Permalink
updating to DMFR v0.5.0 schema (#275)
Browse files Browse the repository at this point in the history
* updating to DMFR v0.5.0 schema

https://github.com/transitland/distributed-mobility-feed-registry/releases/tag/v0.5.0

* Add description to sqlite, postgres schema

---------

Co-authored-by: Ian Rees <[email protected]>
  • Loading branch information
drewda and irees committed Jul 17, 2023
1 parent 3f44183 commit 840cee3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dmfr/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ReadRegistry(reader io.Reader) (*Registry, error) {
reg.Operators = loadReg.Operators
reg.Secrets = loadReg.Secrets
if reg.Schema == "" {
reg.Schema = "https://dmfr.transit.land/json-schema/dmfr.schema-v0.4.0.json"
reg.Schema = "https://dmfr.transit.land/json-schema/dmfr.schema-v0.5.0.json"
}
operators := []tl.Operator{}
for _, rfeed := range loadReg.Feeds {
Expand Down
6 changes: 3 additions & 3 deletions dmfr/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ func TestRegistry_Write(t *testing.T) {
{
"feed",
`{"feeds":[{"id":"test","spec":"gtfs"}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.4.0.json","feeds":[{"id":"test","spec":"gtfs"}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.5.0.json","feeds":[{"id":"test","spec":"gtfs"}]}`,
},
{
"feed sorted",
`{"feeds":[{"id":"z","spec":"gtfs"},{"id":"a","spec":"gtfs"}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.4.0.json","feeds":[{"id":"a","spec":"gtfs"},{"id":"z","spec":"gtfs"}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.5.0.json","feeds":[{"id":"a","spec":"gtfs"},{"id":"z","spec":"gtfs"}]}`,
},
{
"nested operators moved to top level",
`{"feeds": [{"id": "z","spec": "gtfs","operators": [{"onestop_id": "o"}]}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.4.0.json","feeds":[{"id":"z","spec":"gtfs"}],"operators":[{"onestop_id":"o","associated_feeds":[{"feed_onestop_id":"z"}]}]}`,
`{"$schema":"https://dmfr.transit.land/json-schema/dmfr.schema-v0.5.0.json","feeds":[{"id":"z","spec":"gtfs"}],"operators":[{"onestop_id":"o","associated_feeds":[{"feed_onestop_id":"z"}]}]}`,
},
}
for _, tc := range tcs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ BEGIN;

ALTER TABLE feed_states ADD COLUMN fetch_wait integer;

END;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;

ALTER TABLE current_feeds ADD COLUMN description text;

COMMIT;
1 change: 1 addition & 0 deletions internal/schema/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS "current_feeds" (
"urls" BLOB,
"languages" BLOB,
"name" varchar(255),
"description" varchar(255),
"file" varchar(255) NOT NULL,
"feed_tags" BLOB
);
Expand Down
2 changes: 2 additions & 0 deletions test/data/server/server-test.dmfr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
{
"spec": "gtfs",
"id": "BA",
"name": "BART",
"description": "Bay Area Rapid Transit",
"urls": {
"static_current": "../test/data/external/bart.zip"
}
Expand Down
1 change: 1 addition & 0 deletions tl/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Feed struct {
FeedID string `json:"id" db:"onestop_id"`
SupersedesIDs Strings `json:"supersedes_ids,omitempty" db:"-"`
Name String `json:"name,omitempty"`
Description String `json:"description,omitempty"`
Spec string `json:"spec,omitempty"`
URLs FeedUrls `json:"urls,omitempty" db:"urls"`
Languages FeedLanguages `json:"languages,omitempty"`
Expand Down

0 comments on commit 840cee3

Please sign in to comment.