-
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.
- Loading branch information
Showing
16 changed files
with
442 additions
and
6 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
26 changes: 26 additions & 0 deletions
26
common/src/database/schema/redis/_001_create_subscriptions_table.rs
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,26 @@ | ||
use anyhow::{Context, Result}; | ||
use async_trait::async_trait; | ||
use redis::AsyncCommands; | ||
use crate::database::redis::RedisMigration; | ||
use crate::database::redisdomain::RedisDomain; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct CreateSubscriptionsTable; | ||
migration!(CreateSubscriptionsTable, 1, "create subscriptions table"); | ||
|
||
#[async_trait] | ||
impl RedisMigration for CreateSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, conn: &mut Connection) -> Result<()> { | ||
let key = format!("{}:{}:{}", RedisDomain::Subscription, RedisDomain::Any, RedisDomain::Any); | ||
let subs : Vec<String> = conn.keys(key).await.context("Unable to list keys")?; | ||
if !subs.is_empty() { | ||
let _: () = conn.del(subs).await.context("Failed to delete subscription data")?; | ||
} | ||
Ok(()) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
common/src/database/schema/redis/_002_create_bookmarks_table.rs
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,26 @@ | ||
use anyhow::{Context, Result}; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::database::redisdomain::RedisDomain; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
use redis::AsyncCommands; | ||
|
||
pub(super) struct CreateBookmarksTable; | ||
migration!(CreateBookmarksTable, 2, "create bookmarks table"); | ||
|
||
#[async_trait] | ||
impl RedisMigration for CreateBookmarksTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, conn: &mut Connection) -> Result<()> { | ||
let key = format!("{}:{}:{}", RedisDomain::BookMark, RedisDomain::Any, RedisDomain::Any); | ||
let bms : Vec<String> = conn.keys(key).await.context("Unable to list keys")?; | ||
if !bms.is_empty() { | ||
let _: () = conn.del(bms).await.context("Failed to delete bookmark data")?; | ||
} | ||
Ok(()) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
common/src/database/schema/redis/_003_create_heartbeats_table.rs
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,26 @@ | ||
use anyhow::{Context, Result}; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::database::redisdomain::RedisDomain; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
use redis::AsyncCommands; | ||
|
||
pub(super) struct CreateHeartbeatsTable; | ||
migration!(CreateHeartbeatsTable, 3, "create heartbeats table"); | ||
|
||
#[async_trait] | ||
impl RedisMigration for CreateHeartbeatsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, conn: &mut Connection) -> Result<()> { | ||
let key = format!("{}:{}:{}", RedisDomain::Heartbeat, RedisDomain::Any, RedisDomain::Any); | ||
let hbs : Vec<String> = conn.keys(key).await.context("Unable to list keys")?; | ||
if !hbs.is_empty() { | ||
let _: () = conn.del(hbs).await.context("Failed to delete hearthbeat data")?; | ||
} | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_004_add_last_event_seen_field_in_heartbeats_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddLastEventSeenFieldInHeartbeatsTable; | ||
migration!( | ||
AddLastEventSeenFieldInHeartbeatsTable, | ||
4, | ||
"add last_event_seen field in heartbeats table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddLastEventSeenFieldInHeartbeatsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_005_add_uri_field_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddUriFieldInSubscriptionsTable; | ||
migration!( | ||
AddUriFieldInSubscriptionsTable, | ||
5, | ||
"add uri field in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddUriFieldInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_006_add_content_format_field_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddContentFormatFieldInSubscriptionsTable; | ||
migration!( | ||
AddContentFormatFieldInSubscriptionsTable, | ||
6, | ||
"add content_format field in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddContentFormatFieldInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...n/src/database/schema/redis/_007_add_ignore_channel_error_field_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddIgnoreChannelErrorFieldInSubscriptionsTable; | ||
migration!( | ||
AddIgnoreChannelErrorFieldInSubscriptionsTable, | ||
7, | ||
"add ignore_channel_error field in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddIgnoreChannelErrorFieldInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_008_add_princs_filter_fields_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddPrincsFilterFieldsInSubscriptionsTable; | ||
migration!( | ||
AddPrincsFilterFieldsInSubscriptionsTable, | ||
8, | ||
"add princs_filter fields in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddPrincsFilterFieldsInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
common/src/database/schema/redis/_009_alter_outputs_format.rs
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,19 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AlterOutputsFormat; | ||
migration!(AlterOutputsFormat, 9, "alter outputs format"); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AlterOutputsFormat { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_010_add_revision_field_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddRevisionFieldInSubscriptionsTable; | ||
migration!( | ||
AddRevisionFieldInSubscriptionsTable, | ||
10, | ||
"add revision field in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddRevisionFieldInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/database/schema/redis/_011_add_locale_fields_in_subscriptions_table.rs
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,23 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use crate::database::redis::RedisMigration; | ||
use crate::migration; | ||
use deadpool_redis::*; | ||
|
||
pub(super) struct AddLocaleFieldsInSubscriptionsTable; | ||
migration!( | ||
AddLocaleFieldsInSubscriptionsTable, | ||
11, | ||
"add locale fields in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl RedisMigration for AddLocaleFieldsInSubscriptionsTable { | ||
async fn up(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _conn: &mut Connection) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.