switchy_schema_test_utils 0.3.0

Switchy Schema Test Utils package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
#![cfg_attr(feature = "fail-on-warnings", deny(warnings))]
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
#![allow(clippy::multiple_crate_versions)]

//! Test utilities for `switchy_schema` migration testing
//!
//! This crate provides comprehensive testing infrastructure for verifying migration
//! correctness and behavior. It supports testing migrations with fresh databases,
//! pre-seeded state, and interleaved mutations between migrations.
//!
//! ## Migration Test Builder
//!
//! The [`MigrationTestBuilder`] provides an ergonomic way to test complex migration
//! scenarios where you need to insert data at specific points in the migration sequence.
//! This is particularly useful for testing data migration scenarios.
//!
//! ### Basic Usage
//!
//! ```rust,no_run
//! # #[cfg(feature = "sqlite")]
//! # {
//! use switchy_schema_test_utils::{MigrationTestBuilder, create_empty_in_memory};
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let db = create_empty_in_memory().await?;
//! let migrations = vec![/* your migrations */];
//!
//! MigrationTestBuilder::new(migrations)
//!     .with_table_name("__test_migrations")
//!     .run(&*db)
//!     .await?;
//! # Ok(())
//! # }
//! # }
//! ```
//!
//! ### Testing Data Migrations
//!
//! ```rust,no_run
//! # #[cfg(feature = "sqlite")]
//! # {
//! use switchy_schema_test_utils::MigrationTestBuilder;
//!
//! # async fn example(db: &dyn switchy_database::Database, migrations: Vec<std::sync::Arc<dyn switchy_schema::migration::Migration<'static> + 'static>>) -> Result<(), Box<dyn std::error::Error>> {
//! // Test a data migration scenario
//! MigrationTestBuilder::new(migrations)
//!     .with_data_before(
//!         "002_migrate_user_data",
//!         |db| Box::pin(async move {
//!             // Insert old format data that migration will transform
//!             db.exec_raw("INSERT INTO old_users (name) VALUES ('test')").await
//!         })
//!     )
//!     .run(db)
//!     .await?;
//!
//! // Verify migration transformed data correctly
//! // Note: In real usage, you would use the query builder
//! // let users = query::select("new_users").columns(&["*"]).execute(db).await?;
//! // assert!(!users.is_empty());
//! # Ok(())
//! # }
//! # }
//! ```
//!
//! ### Multiple Breakpoints
//!
//! ```rust,no_run
//! # #[cfg(feature = "sqlite")]
//! # {
//! use switchy_schema_test_utils::MigrationTestBuilder;
//!
//! # async fn example(db: &dyn switchy_database::Database, migrations: Vec<std::sync::Arc<dyn switchy_schema::migration::Migration<'static> + 'static>>) -> Result<(), Box<dyn std::error::Error>> {
//! MigrationTestBuilder::new(migrations)
//!     .with_data_after(
//!         "001_create_users",
//!         |db| Box::pin(async move {
//!             db.exec_raw("INSERT INTO users (name) VALUES ('test_user')").await
//!         })
//!     )
//!     .with_data_before(
//!         "003_migrate_posts",
//!         |db| Box::pin(async move {
//!             db.exec_raw("INSERT INTO old_posts (title, user_name) VALUES ('Test', 'test_user')").await
//!         })
//!     )
//!     .run(db)
//!     .await?;
//! # Ok(())
//! # }
//! # }
//! ```

use std::{future::Future, pin::Pin, sync::Arc};

use async_trait::async_trait;
use switchy_database::{Database, DatabaseError};
use switchy_schema::{
    MigrationError,
    migration::{Migration, MigrationSource},
    runner::{MigrationRunner, RollbackStrategy},
};

/// Re-export core types for convenience
pub use switchy_database;
pub use switchy_schema;

/// Re-export the migration test builder for convenience
#[cfg(feature = "sqlite")]
pub use builder::MigrationTestBuilder;

/// Mutation handling for advanced migration testing
pub mod mutations;

/// Test assertion helpers for database schema and migration verification
#[cfg(feature = "sqlite")]
pub mod assertions;

/// Migration test builder for complex testing scenarios
#[cfg(feature = "sqlite")]
pub mod builder;

/// Integration tests demonstrating new migration capabilities
pub mod integration_tests;

/// Snapshot testing utilities for migration verification
#[cfg(feature = "snapshots")]
pub mod snapshots;

/// Test error type that wraps existing errors from `switchy_schema` and `switchy_database`
#[derive(Debug, thiserror::Error)]
pub enum TestError {
    /// Migration error
    #[error(transparent)]
    Migration(#[from] MigrationError),
    /// Database error
    #[error(transparent)]
    Database(#[from] DatabaseError),
    /// Database connection initialization error
    #[cfg(feature = "sqlite")]
    #[error(transparent)]
    DatabaseInit(#[from] switchy_database_connection::InitSqliteSqlxDatabaseError),
}

// Re-export snapshot types when feature is enabled
#[cfg(feature = "snapshots")]
pub use snapshots::{
    MigrationSnapshotTest, Result as SnapshotResult, SnapshotError, SnapshotTester,
};

/// Feature-gated helper to create an empty in-memory `SQLite` database
///
/// # Errors
///
/// * If the `SQLite` database initialization fails
#[cfg(feature = "sqlite")]
pub async fn create_empty_in_memory()
-> Result<Box<dyn Database>, switchy_database_connection::InitSqliteSqlxDatabaseError> {
    // Create in-memory SQLite database using sqlx
    switchy_database_connection::init_sqlite_sqlx(None).await
}

/// Internal helper struct that wraps a Vec of migrations into a `MigrationSource`
struct VecMigrationSource<'a> {
    migrations: Vec<Arc<dyn Migration<'a> + 'a>>,
}

impl<'a> VecMigrationSource<'a> {
    #[must_use]
    fn new(migrations: Vec<Arc<dyn Migration<'a> + 'a>>) -> Self {
        Self { migrations }
    }
}

#[async_trait]
impl<'a> MigrationSource<'a> for VecMigrationSource<'a> {
    async fn migrations(&self) -> switchy_schema::Result<Vec<Arc<dyn Migration<'a> + 'a>>> {
        Ok(self.migrations.clone()) // Cheap Arc cloning!
    }
}

/// Test migrations from fresh state - runs migrations forward then backward
///
/// This function creates a `MigrationRunner` internally and tests the full migration
/// cycle: applying all migrations forward, then rolling them all back.
///
/// # Arguments
///
/// * `db` - Database connection to test against
/// * `migrations` - Vector of migrations to test
///
/// # Errors
///
/// * If any migration fails during forward execution
/// * If any migration fails during rollback
/// * If database operations fail
///
/// # Examples
///
/// ```rust,no_run
/// use std::sync::Arc;
/// use switchy_schema_test_utils::{verify_migrations_full_cycle, TestError};
/// use switchy_schema::migration::Migration;
/// use switchy_database::Database;
///
/// # async fn example(db: &dyn Database, migrations: Vec<Arc<dyn Migration<'static> + 'static>>) -> Result<(), TestError> {
/// // Test a set of migrations
/// verify_migrations_full_cycle(db, migrations).await?;
/// # Ok(())
/// # }
/// ```
pub async fn verify_migrations_full_cycle<'a>(
    db: &dyn Database,
    migrations: Vec<Arc<dyn Migration<'a> + 'a>>,
) -> Result<(), TestError> {
    // Create VecMigrationSource from provided migrations
    let source = VecMigrationSource::new(migrations);

    // Create MigrationRunner internally
    let runner = MigrationRunner::new(Box::new(source));

    // Run all migrations forward (up)
    runner.run(db).await?;

    // Run all migrations backward (down) using rollback functionality
    runner.rollback(db, RollbackStrategy::All).await?;

    Ok(())
}

/// Test migrations with pre-seeded state - runs setup, then migrations forward and backward
///
/// This function allows testing migrations against a database that already contains data.
/// It executes a setup closure first, then runs the full migration cycle.
///
/// # Arguments
///
/// * `db` - Database connection to test against
/// * `migrations` - Vector of migrations to test
/// * `setup` - Closure to populate initial database state
///
/// # Errors
///
/// * If the setup closure fails
/// * If any migration fails during forward execution
/// * If any migration fails during rollback
/// * If database operations fail
///
/// # Examples
///
/// ```rust,no_run
/// use std::sync::Arc;
/// use switchy_schema_test_utils::{verify_migrations_with_state, TestError};
/// use switchy_schema::migration::Migration;
/// use switchy_database::{Database, DatabaseError};
///
/// # async fn example(db: &dyn Database, migrations: Vec<Arc<dyn Migration<'static> + 'static>>) -> Result<(), TestError> {
/// // Test migrations with pre-existing data
/// verify_migrations_with_state(
///     db,
///     migrations,
///     |db| Box::pin(async move {
///         // Setup initial state
///         db.exec_raw("CREATE TABLE existing_table (id INTEGER)").await?;
///         db.exec_raw("INSERT INTO existing_table (id) VALUES (1)").await?;
///         Ok(())
///     })
/// ).await?;
/// # Ok(())
/// # }
/// ```
pub async fn verify_migrations_with_state<'a, F>(
    db: &dyn Database,
    migrations: Vec<Arc<dyn Migration<'a> + 'a>>,
    setup: F,
) -> Result<(), TestError>
where
    F: for<'db> FnOnce(
        &'db dyn Database,
    )
        -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'db>>,
{
    // Execute setup closure to populate initial state
    setup(db).await?;

    // Create VecMigrationSource from provided migrations
    let source = VecMigrationSource::new(migrations);

    // Create MigrationRunner internally
    let runner = MigrationRunner::new(Box::new(source));

    // Run all migrations forward
    runner.run(db).await?;

    // Run all migrations backward using rollback functionality
    runner.rollback(db, RollbackStrategy::All).await?;

    Ok(())
}

/// Test migrations with data changes between migration steps
///
/// This function allows testing migrations with mutations (data changes) that occur
/// between specific migration steps. This verifies that migrations handle intermediate
/// state changes correctly and that rollback works with mutated data.
///
/// # Arguments
///
/// * `db` - Database connection to test against
/// * `migrations` - Vector of migrations to test
/// * `mutations` - Provider for mutations to execute between migrations
///
/// # Errors
///
/// * If any migration fails during forward execution
/// * If any mutation fails during execution
/// * If any migration fails during rollback
/// * If database operations fail
///
/// # Examples
///
/// ```rust,no_run
/// use std::{collections::BTreeMap, sync::Arc};
/// use switchy_schema_test_utils::{verify_migrations_with_mutations, TestError, mutations::MutationProvider};
/// use switchy_schema::migration::Migration;
/// use switchy_database::{Database, Executable};
///
/// # async fn example(db: &dyn Database, migrations: Vec<Arc<dyn Migration<'static> + 'static>>) -> Result<(), TestError> {
/// // Create mutations to execute between migrations
/// let mut mutation_map = BTreeMap::new();
/// mutation_map.insert(
///     "001_create_users".to_string(),
///     Arc::new("INSERT INTO users (name) VALUES ('test_user')".to_string()) as Arc<dyn Executable>
/// );
///
/// // Test migrations with mutations
/// verify_migrations_with_mutations(db, migrations, mutation_map).await?;
/// # Ok(())
/// # }
/// ```
pub async fn verify_migrations_with_mutations<'a, M>(
    db: &dyn Database,
    migrations: Vec<Arc<dyn Migration<'a> + 'a>>,
    mutations: M,
) -> Result<(), TestError>
where
    M: mutations::MutationProvider,
{
    // Create VecMigrationSource from provided migrations
    let source = VecMigrationSource::new(migrations.clone());

    // Create MigrationRunner internally
    let runner = MigrationRunner::new(Box::new(source));

    // We need to run migrations one by one to execute mutations between them
    // First, get all migrations in order
    let mut migration_map = std::collections::BTreeMap::new();
    for migration in &migrations {
        migration_map.insert(migration.id().to_string(), Arc::clone(migration));
    }

    // Execute migrations one by one with mutations
    for (migration_id, migration) in &migration_map {
        // Run this single migration
        let single_migration_source = VecMigrationSource::new(vec![Arc::clone(migration)]);
        let single_runner = MigrationRunner::new(Box::new(single_migration_source));
        single_runner.run(db).await?;

        // Execute any mutation for this migration
        if let Some(mutation) = mutations.get_mutation(migration_id).await {
            mutation.execute(db).await?;
        }
    }

    // Now rollback all migrations
    runner.rollback(db, RollbackStrategy::All).await?;

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::sync::Arc;
    use switchy_schema::migration::Migration;

    // Mock migration for testing
    struct TestMigration {
        id: String,
        up_sql: String,
        down_sql: Option<String>,
    }

    impl TestMigration {
        fn new(id: &str, up_sql: &str, down_sql: Option<&str>) -> Self {
            Self {
                id: id.to_string(),
                up_sql: up_sql.to_string(),
                down_sql: down_sql.map(String::from),
            }
        }
    }

    #[async_trait]
    impl Migration<'static> for TestMigration {
        fn id(&self) -> &str {
            &self.id
        }

        async fn up(&self, db: &dyn Database) -> switchy_schema::Result<()> {
            db.exec_raw(&self.up_sql).await?;
            Ok(())
        }

        async fn down(&self, db: &dyn Database) -> switchy_schema::Result<()> {
            if let Some(down_sql) = &self.down_sql {
                db.exec_raw(down_sql).await?;
            }
            Ok(())
        }
    }

    #[switchy_async::test]
    async fn test_vec_migration_source() {
        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let migration2 = Arc::new(TestMigration::new(
            "002_create_posts",
            "CREATE TABLE posts (id INTEGER PRIMARY KEY, user_id INTEGER)",
            Some("DROP TABLE posts"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1, migration2];
        let source = VecMigrationSource::new(test_migrations.clone());

        // Test that migrations() returns the same migrations
        let result = source.migrations().await.unwrap();
        assert_eq!(result.len(), 2);
        assert_eq!(result[0].id(), "001_create_users");
        assert_eq!(result[1].id(), "002_create_posts");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_full_cycle() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let migration2 = Arc::new(TestMigration::new(
            "002_create_posts",
            "CREATE TABLE posts (id INTEGER PRIMARY KEY, user_id INTEGER, title TEXT)",
            Some("DROP TABLE posts"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1, migration2];

        // This should run migrations forward then backward without errors
        let result = verify_migrations_full_cycle(db.as_ref(), test_migrations).await;
        assert!(result.is_ok(), "Full cycle verification failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_with_state() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let migration2 = Arc::new(TestMigration::new(
            "002_add_email_column",
            "ALTER TABLE existing_data ADD COLUMN email TEXT",
            Some("ALTER TABLE existing_data DROP COLUMN email"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1, migration2];

        // Test with pre-seeded state
        let result = verify_migrations_with_state(db.as_ref(), test_migrations, |db| {
            Box::pin(async move {
                // Setup initial state
                db.exec_raw("CREATE TABLE existing_data (id INTEGER PRIMARY KEY, name TEXT)")
                    .await?;
                db.exec_raw("INSERT INTO existing_data (name) VALUES ('test')")
                    .await?;
                Ok(())
            })
        })
        .await;

        assert!(result.is_ok(), "With state verification failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_empty_list() {
        let db = create_empty_in_memory().await.unwrap();
        let migrations: Vec<Arc<dyn Migration<'static> + 'static>> = vec![];

        // Empty migration list should work fine
        let result = verify_migrations_full_cycle(db.as_ref(), migrations).await;
        assert!(result.is_ok(), "Empty migration list failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_single_migration() {
        let db = create_empty_in_memory().await.unwrap();

        let migration = Arc::new(TestMigration::new(
            "001_single_table",
            "CREATE TABLE single_table (id INTEGER PRIMARY KEY)",
            Some("DROP TABLE single_table"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let single_migration = vec![migration];

        // Single migration should work
        let result = verify_migrations_full_cycle(db.as_ref(), single_migration).await;
        assert!(result.is_ok(), "Single migration failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_with_mutations_btreemap() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let migration2 = Arc::new(TestMigration::new(
            "002_create_posts",
            "CREATE TABLE posts (id INTEGER PRIMARY KEY, user_id INTEGER, title TEXT)",
            Some("DROP TABLE posts"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1, migration2];

        // Create mutations using BTreeMap
        let mut mutation_map = std::collections::BTreeMap::new();
        mutation_map.insert(
            "001_create_users".to_string(),
            Arc::new("INSERT INTO users (name) VALUES ('test_user')".to_string())
                as Arc<dyn switchy_database::Executable>,
        );

        // Test migrations with mutations
        let result =
            verify_migrations_with_mutations(db.as_ref(), test_migrations, mutation_map).await;
        assert!(result.is_ok(), "Mutations with BTreeMap failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_with_mutations_vec() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1];

        // Create mutations using Vec
        let mutations = vec![(
            "001_create_users".to_string(),
            Arc::new("INSERT INTO users (name) VALUES ('test_user')".to_string())
                as Arc<dyn switchy_database::Executable>,
        )];

        // Test migrations with mutations
        let result =
            verify_migrations_with_mutations(db.as_ref(), test_migrations, mutations).await;
        assert!(result.is_ok(), "Mutations with Vec failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_with_mutations_builder() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1];

        // Create mutations using builder pattern
        let mutations = crate::mutations::MutationBuilder::new()
            .add_mutation(
                "001_create_users",
                "INSERT INTO users (name) VALUES ('builder_user')",
            )
            .build();

        // Test migrations with mutations
        let result =
            verify_migrations_with_mutations(db.as_ref(), test_migrations, mutations).await;
        assert!(result.is_ok(), "Mutations with builder failed: {result:?}");
    }

    #[cfg(feature = "sqlite")]
    #[switchy_async::test]
    async fn test_verify_migrations_with_no_mutations() {
        let db = create_empty_in_memory().await.unwrap();

        let migration1 = Arc::new(TestMigration::new(
            "001_create_users",
            "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
            Some("DROP TABLE users"),
        )) as Arc<dyn Migration<'static> + 'static>;

        let test_migrations = vec![migration1];

        // Create empty mutations
        let mutations =
            std::collections::BTreeMap::<String, Arc<dyn switchy_database::Executable>>::new();

        // Test migrations with no mutations (should work like normal)
        let result =
            verify_migrations_with_mutations(db.as_ref(), test_migrations, mutations).await;
        assert!(
            result.is_ok(),
            "Migrations with no mutations failed: {result:?}"
        );
    }
}