-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fu: add database schema v1 for subscription to support future migrations
- Loading branch information
Showing
5 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
use crate::database::redis::RedisDatabase; | ||
|
||
pub mod v1; | ||
|
||
pub fn register_migrations(_redis_db: &mut RedisDatabase) { | ||
// for future changes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod subscription; | ||
|
||
pub const VERSION: &str = module_path!(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use crate::subscription::*; | ||
|
||
use super::VERSION; | ||
|
||
#[derive(Debug, PartialEq, Clone, Eq, Serialize, Deserialize)] | ||
pub struct SubscriptionRedisData { | ||
version: String, | ||
uuid: SubscriptionUuid, | ||
internal_version: InternalVersion, | ||
revision: Option<String>, | ||
uri: Option<String>, | ||
enabled: bool, | ||
princs_filter: PrincsFilter, | ||
parameters: SubscriptionParameters, | ||
outputs: Vec<SubscriptionOutput>, | ||
} | ||
|
||
impl SubscriptionRedisData { | ||
pub fn from_subscription_data(from: &SubscriptionData) -> Self { | ||
Self { | ||
version: VERSION.to_string(), | ||
uuid: *from.uuid(), | ||
internal_version: from.internal_version(), | ||
revision: from.revision().cloned(), | ||
uri: from.uri().cloned(), | ||
enabled: from.enabled(), | ||
princs_filter: from.princs_filter().clone(), | ||
parameters: from.parameters().clone(), | ||
outputs: from.outputs().to_vec(), | ||
} | ||
} | ||
pub fn into_subscription_data(self) -> SubscriptionData { | ||
let mut sd = SubscriptionData::new(&self.parameters.name, &self.parameters.query); | ||
sd.set_revision(self.revision). | ||
set_uuid(self.uuid). | ||
set_uri(self.uri). | ||
set_enabled(self.enabled). | ||
set_princs_filter(self.princs_filter). | ||
set_parameters(self.parameters). | ||
set_outputs(self.outputs); | ||
sd.set_internal_version(self.internal_version); | ||
sd | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters