Added migration to remove album from the db
This commit is contained in:
parent
83efbb0d4f
commit
a65fdfdd4d
20
src/migrations/migration3_remove_img.rs
Normal file
20
src/migrations/migration3_remove_img.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use j_db::database::Database;
|
||||||
|
use j_db::migration::Migration;
|
||||||
|
|
||||||
|
pub struct Migration3RemoveImage {}
|
||||||
|
|
||||||
|
impl Migration for Migration3RemoveImage {
|
||||||
|
fn up(&self, db: &Database) -> j_db::error::Result<()> {
|
||||||
|
db.db.drop_tree("Album")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn down(&self, _db: &Database) -> j_db::error::Result<()> {
|
||||||
|
// Nothing to do
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version(&self) -> u64 {
|
||||||
|
3
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,10 +2,12 @@ use crate::migrations::migration2_remove_imgur::Migration2RemoveImgur;
|
|||||||
use j_db::database::Database;
|
use j_db::database::Database;
|
||||||
use j_db::migration;
|
use j_db::migration;
|
||||||
use j_db::migration::Direction;
|
use j_db::migration::Direction;
|
||||||
|
use crate::migrations::migration3_remove_img::Migration3RemoveImage;
|
||||||
|
|
||||||
mod migration2_remove_imgur;
|
mod migration2_remove_imgur;
|
||||||
|
mod migration3_remove_img;
|
||||||
|
|
||||||
const CURRENT_DB_VERSION: u64 = 2;
|
const CURRENT_DB_VERSION: u64 = 3;
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
pub fn do_migration(db: &Database) {
|
pub fn do_migration(db: &Database) {
|
||||||
@ -20,6 +22,14 @@ pub fn do_migration(db: &Database) {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
3 => {
|
||||||
|
migration::do_migration::<Migration3RemoveImage>(
|
||||||
|
db,
|
||||||
|
Migration3RemoveImage {},
|
||||||
|
Direction::Up,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user