diff --git a/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/down.sql b/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/down.sql new file mode 100644 index 0000000..c33f425 --- /dev/null +++ b/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/down.sql @@ -0,0 +1,53 @@ +ALTER TABLE episode RENAME TO old_table; + +CREATE TABLE episode ( + title TEXT NOT NULL, + uri TEXT, + local_uri TEXT, + description TEXT, + epoch INTEGER NOT NULL DEFAULT 0, + length INTEGER, + duration INTEGER, + guid TEXT, + played INTEGER, + podcast_id INTEGER NOT NULL, + favorite INTEGER DEFAULT 0, + archive INTEGER DEFAULT 0, + PRIMARY KEY (title, podcast_id) +); + +INSERT INTO episode (title, uri, local_uri, description, epoch, length, duration, guid, played, podcast_id, favorite, archive) +SELECT title, uri, local_uri, description, epoch, length, duration, guid, played, podcast_id, 0, 0 +FROM old_table; + +Drop table old_table; + +ALTER TABLE podcast RENAME TO old_table; +CREATE TABLE `podcast` ( + `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, + `title` TEXT NOT NULL, + `link` TEXT NOT NULL, + `description` TEXT NOT NULL, + `image_uri` TEXT, + `source_id` INTEGER NOT NULL UNIQUE, + `favorite` INTEGER NOT NULL DEFAULT 0, + `archive` INTEGER NOT NULL DEFAULT 0, + `always_dl` INTEGER NOT NULL DEFAULT 0 +); + +INSERT INTO podcast ( + id, + title, + link, + description, + image_uri, + source_id +) SELECT id, + title, + link, + description, + image_uri, + source_id +FROM old_table; + +Drop table old_table; \ No newline at end of file diff --git a/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/up.sql b/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/up.sql new file mode 100644 index 0000000..f1afbf2 --- /dev/null +++ b/hammond-data/migrations/2018-06-30-141659_remove_dead_fields/up.sql @@ -0,0 +1,66 @@ +ALTER TABLE episode RENAME TO old_table; + +CREATE TABLE episode ( + title TEXT NOT NULL, + uri TEXT, + local_uri TEXT, + description TEXT, + epoch INTEGER NOT NULL DEFAULT 0, + length INTEGER, + duration INTEGER, + guid TEXT, + played INTEGER, + podcast_id INTEGER NOT NULL, + PRIMARY KEY (title, podcast_id) +); + +INSERT INTO episode ( + title, + uri, + local_uri, + description, + epoch, + length, + duration, + guid, + played, + podcast_id +) SELECT title, + uri, + local_uri, + description, + epoch, length, + duration, + guid, + played, + podcast_id +FROM old_table; + +Drop table old_table; + +ALTER TABLE podcast RENAME TO old_table; +CREATE TABLE `podcast` ( + `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, + `title` TEXT NOT NULL, + `link` TEXT NOT NULL, + `description` TEXT NOT NULL, + `image_uri` TEXT, + `source_id` INTEGER NOT NULL UNIQUE +); + +INSERT INTO podcast ( + id, + title, + link, + description, + image_uri, + source_id +) SELECT id, + title, + link, + description, + image_uri, + source_id +FROM old_table; + +Drop table old_table; diff --git a/hammond-data/src/models/episode.rs b/hammond-data/src/models/episode.rs index b9232fe..2aaf2f7 100644 --- a/hammond-data/src/models/episode.rs +++ b/hammond-data/src/models/episode.rs @@ -26,8 +26,6 @@ pub struct Episode { duration: Option, guid: Option, played: Option, - favorite: bool, - archive: bool, podcast_id: i32, } @@ -154,29 +152,6 @@ impl Episode { self.played = value; } - /// Represents the archiving policy for the episode. - pub fn archive(&self) -> bool { - self.archive - } - - /// Set the `archive` policy. - /// - /// If true, the download cleanr will ignore the episode - /// and the corresponding media value will never be automaticly deleted. - pub fn set_archive(&mut self, b: bool) { - self.archive = b - } - - /// Get the `favorite` status of the `Episode`. - pub fn favorite(&self) -> bool { - self.favorite - } - - /// Set `favorite` status. - pub fn set_favorite(&mut self, b: bool) { - self.favorite = b - } - /// `Podcast` table foreign key. pub fn podcast_id(&self) -> i32 { self.podcast_id @@ -205,8 +180,6 @@ pub struct EpisodeWidgetQuery { length: Option, duration: Option, played: Option, - // favorite: bool, - // archive: bool, podcast_id: i32, } @@ -319,29 +292,6 @@ impl EpisodeWidgetQuery { self.played = value; } - // /// Represents the archiving policy for the episode. - // pub fn archive(&self) -> bool { - // self.archive - // } - - // /// Set the `archive` policy. - // /// - // /// If true, the download cleanr will ignore the episode - // /// and the corresponding media value will never be automaticly deleted. - // pub fn set_archive(&mut self, b: bool) { - // self.archive = b - // } - - // /// Get the `favorite` status of the `Episode`. - // pub fn favorite(&self) -> bool { - // self.favorite - // } - - // /// Set `favorite` status. - // pub fn set_favorite(&mut self, b: bool) { - // self.favorite = b - // } - /// `Podcast` table foreign key. pub fn podcast_id(&self) -> i32 { self.podcast_id diff --git a/hammond-data/src/models/podcast.rs b/hammond-data/src/models/podcast.rs index a0090aa..90445ff 100644 --- a/hammond-data/src/models/podcast.rs +++ b/hammond-data/src/models/podcast.rs @@ -19,9 +19,6 @@ pub struct Podcast { link: String, description: String, image_uri: Option, - favorite: bool, - archive: bool, - always_dl: bool, source_id: i32, } @@ -83,41 +80,6 @@ impl Podcast { self.image_uri = value.map(|x| x.to_string()); } - /// Represents the archiving policy for the episode. - pub fn archive(&self) -> bool { - self.archive - } - - /// Set the `archive` policy. - pub fn set_archive(&mut self, b: bool) { - self.archive = b - } - - /// Get the `favorite` status of the `Podcast` Feed. - pub fn favorite(&self) -> bool { - self.favorite - } - - /// Set `favorite` status. - pub fn set_favorite(&mut self, b: bool) { - self.favorite = b - } - - /// Represents the download policy for the `Podcast` Feed. - /// - /// Reserved for the use with a Download manager, yet to be implemented. - /// - /// If true Podcast Episode should be downloaded automaticly/skipping - /// the selection queue. - pub fn always_download(&self) -> bool { - self.always_dl - } - - /// Set the download policy. - pub fn set_always_download(&mut self, b: bool) { - self.always_dl = b - } - /// `Source` table foreign key. pub fn source_id(&self) -> i32 { self.source_id diff --git a/hammond-data/src/schema.rs b/hammond-data/src/schema.rs index cf22457..365129d 100644 --- a/hammond-data/src/schema.rs +++ b/hammond-data/src/schema.rs @@ -10,8 +10,6 @@ table! { duration -> Nullable, guid -> Nullable, played -> Nullable, - favorite -> Bool, - archive -> Bool, podcast_id -> Integer, } } @@ -23,9 +21,6 @@ table! { link -> Text, description -> Text, image_uri -> Nullable, - favorite -> Bool, - archive -> Bool, - always_dl -> Bool, source_id -> Integer, } } @@ -39,4 +34,4 @@ table! { } } -allow_tables_to_appear_in_same_query!(episode, podcast, source,); +allow_tables_to_appear_in_same_query!(episode, podcast, source);