Skip to content

Commit

Permalink
remove migrations env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiznokes committed Jul 24, 2024
1 parent 22c960d commit f97a29c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
9 changes: 0 additions & 9 deletions build.rs

This file was deleted.

2 changes: 0 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ debug := '0'

export NAME := 'cosmic-ext-applet-clipboard-manager'
export APPID := 'io.github.wiiznokes.' + NAME
export MIGRATIONS_FOLDER := share-dst / NAME / 'migrations'

bin-src := if debug == '1' { 'target/debug' / NAME } else { 'target/release' / NAME }

Expand Down Expand Up @@ -46,7 +45,6 @@ uninstall:
rm {{desktop-dst}}
rm {{icon-dst}}
rm {{env-dst}}
rm -r {{MIGRATIONS_FOLDER}}

clean:
cargo clean
Expand Down
15 changes: 10 additions & 5 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,17 @@ impl Db {

let mut conn = SqliteConnection::connect(db_path).await?;

let migration_path = Path::new(env!("MIGRATIONS_FOLDER"));
let migration_path = Path::new(constcat::concat!("/usr/share/", APP, "/migrations"));

sqlx::migrate::Migrator::new(migration_path)
.await?
.run(&mut conn)
.await?;
match sqlx::migrate::Migrator::new(migration_path).await {
Ok(migrator) => migrator,
Err(e) => {
warn!("migrator error {e}, fall back to relative path");
sqlx::migrate::Migrator::new(Path::new("./migrations")).await?
}
}
.run(&mut conn)
.await?;

if let Some(max_duration) = &config.maximum_entries_lifetime {
let now_millis = utils::now_millis();
Expand Down

0 comments on commit f97a29c

Please sign in to comment.