From ebdc11b259474c475696963cff0fc6416ce1642f Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:36:12 -0700 Subject: [PATCH] Create Chateau sql model --- migrations/2024-03-26-004608_init/up.sql | 6 +++--- src/models.rs | 11 +++++++++++ src/schema.rs | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/migrations/2024-03-26-004608_init/up.sql b/migrations/2024-03-26-004608_init/up.sql index 344d8f79..9b62cda0 100644 --- a/migrations/2024-03-26-004608_init/up.sql +++ b/migrations/2024-03-26-004608_init/up.sql @@ -49,9 +49,9 @@ CREATE INDEX static_hulls ON gtfs.static_feeds USING GIST (hull); CREATE TABLE gtfs.chateaus ( chateau text NOT NULL PRIMARY KEY, - static_feeds text[], - realtime_feeds text[], - languages_avaliable text[], + static_feeds text[] NOT NULL, + realtime_feeds text[] NOT NULL, + languages_avaliable text[] NOT NULL, hull GEOMETRY(POLYGON,4326) ); diff --git a/src/models.rs b/src/models.rs index ae27d6b2..b3b9c991 100644 --- a/src/models.rs +++ b/src/models.rs @@ -34,3 +34,14 @@ pub struct StaticDownloadAttempt { pub mark_for_redo: bool, pub http_response_code: Option, } + +#[derive(Queryable, Selectable, Insertable, Debug, Clone)] +#[diesel(table_name = crate::schema::gtfs::chateaus)] +#[diesel(check_for_backend(diesel::pg::Pg))] +pub struct Chateau { + pub chateau: String, + pub static_feeds: Vec>, + pub realtime_feeds: Vec>, + pub languages_avaliable: Vec>, + pub hull: Option>, +} diff --git a/src/schema.rs b/src/schema.rs index 743c0fdb..aabd13ac 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -28,9 +28,9 @@ pub mod gtfs { gtfs.chateaus (chateau) { chateau -> Text, - static_feeds -> Nullable>>, - realtime_feeds -> Nullable>>, - languages_avaliable -> Nullable>>, + static_feeds -> Array>, + realtime_feeds -> Array>, + languages_avaliable -> Array>, hull -> Nullable, } }