-
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.
database: rename princs_filter to client_filter
- Loading branch information
Showing
6 changed files
with
76 additions
and
13 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
27 changes: 27 additions & 0 deletions
27
common/src/database/schema/postgres/_014_alter_client_filter_in_subscriptions.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,27 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use deadpool_postgres::Transaction; | ||
|
||
use crate::{database::postgres::PostgresMigration, migration}; | ||
|
||
pub(super) struct AlterClientFilterInSubscriptionsTable; | ||
migration!( | ||
AlterClientFilterInSubscriptionsTable, | ||
14, | ||
"renames fields and adds filter type and flags to subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl PostgresMigration for AlterClientFilterInSubscriptionsTable { | ||
async fn up(&self, tx: &mut Transaction) -> Result<()> { | ||
tx.execute("ALTER TABLE subscriptions RENAME COLUMN princs_filter_op TO client_filter_op", &[]).await?; | ||
tx.execute("ALTER TABLE subscriptions RENAME COLUMN princs_filter_value TO client_filter_value", &[]).await?; | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, tx: &mut Transaction) -> Result<()> { | ||
tx.execute("ALTER TABLE subscriptions RENAME COLUMN client_filter_op TO princs_filter_op", &[]).await?; | ||
tx.execute("ALTER TABLE subscriptions RENAME COLUMN client_filter_value TO princs_filter_value", &[]).await?; | ||
Ok(()) | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
common/src/database/schema/sqlite/_014_alter_client_filter_in_subscriptions.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,30 @@ | ||
use anyhow::{anyhow, Result}; | ||
use rusqlite::Connection; | ||
|
||
use crate::database::sqlite::SQLiteMigration; | ||
use crate::migration; | ||
|
||
pub(super) struct AlterClientFilterInSubscriptionsTable; | ||
migration!( | ||
AlterClientFilterInSubscriptionsTable, | ||
14, | ||
"renames fields and adds filter type and flags to subscriptions table" | ||
); | ||
|
||
impl SQLiteMigration for AlterClientFilterInSubscriptionsTable { | ||
fn up(&self, conn: &Connection) -> Result<()> { | ||
conn.execute("ALTER TABLE subscriptions RENAME COLUMN princs_filter_op TO client_filter_op", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
conn.execute("ALTER TABLE subscriptions RENAME COLUMN princs_filter_value TO client_filter_value", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
Ok(()) | ||
} | ||
|
||
fn down(&self, conn: &Connection) -> Result<()> { | ||
conn.execute("ALTER TABLE subscriptions RENAME COLUMN client_filter_op TO princs_filter_op", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
conn.execute("ALTER TABLE subscriptions RENAME COLUMN client_filter_value TO princs_filter_value", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
Ok(()) | ||
} | ||
} |
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