#Correct way of running migrations

9 messages · Page 1 of 1 (latest)

dark raven
#

Hi, I'm building my migrations like this:

tauri_plugin_sql::Builder::default()
  .add_migrations(
    "sqlite:app.db",
     vec![
       migration![1674364901_agent],
       migration![1674365066_client],
       migration![1674365089_real_estate],
      ],
  )
.build(),

// this being the macro definition
#[macro_export]
macro_rules! migration {
    ($name: tt) => {
        Migration {
            version: 1,
            description: stringify!($name.sql),
            sql: include_str![concat!("../migrations/", stringify!($name.sql))],
            kind: tauri_plugin_sql::MigrationKind::Up,
        }
    };
}

However, for some reason, only the first migration is ever executed and the rest are ignored. Should I be using a different version of the plugin? I am using the dev branch at the moment.

dark raven
#

Now it isn't running any of my migrations

#

I'm thinking of switching to manual sqlx

runic compass
#

I couldn't find any problem with latest dev version,
it should run migrations when load the db with exactly same dbUrl as the added migrations

dark raven
#

would it be useful to you if I created a minimal reproducible example?

runic compass
#

maybe;
the plugin just save the migrations provide by add_migrations into state, and then run them when load that db, then will remove the migrations from state

the migration is running by sqlx, the plugin just a interface.

dark raven
#

should I try to debug it or just use something else

#

I'm looking for whatever allowes me to continue working in the app the fastest, and I currently don't depend too heavily in the plugin yet

runic compass
#

maybe you could try connect and run migrations manually by using sqlx, the code need write pretty much the same as use the plugin