Migrations work
This code actually enables migrations by running migrations on initialization before any other code runs.
This commit is contained in:
parent
f7f81e0bda
commit
61439d65b3
2 changed files with 12 additions and 1 deletions
|
@ -1,4 +1,13 @@
|
|||
use diesel::prelude::*;
|
||||
use diesel::sqlite::SqliteConnection;
|
||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("src/rust/migrations");
|
||||
|
||||
pub fn run_migrations(conn: &mut SqliteConnection) -> bool {
|
||||
conn.run_pending_migrations(MIGRATIONS).unwrap();
|
||||
true
|
||||
}
|
||||
|
||||
#[derive(Queryable)]
|
||||
pub struct Image {
|
||||
|
|
|
@ -95,9 +95,11 @@ mod song_model {
|
|||
#[qinvokable]
|
||||
pub fn setup(mut self: Pin<&mut Self>) {
|
||||
let db = &mut self.as_mut().get_db();
|
||||
run_migrations(db);
|
||||
|
||||
let results = songs
|
||||
.load::<crate::models::Song>(db)
|
||||
.expect("Error loading songs");
|
||||
.expect("NO TABLE?????????????");
|
||||
self.as_mut().set_highest_id(0);
|
||||
|
||||
println!("SHOWING SONGS");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue