diff --git a/sqlx-core/src/migrate/source.rs b/sqlx-core/src/migrate/source.rs index 609f4fdeaa..10a18b365b 100644 --- a/sqlx-core/src/migrate/source.rs +++ b/sqlx-core/src/migrate/source.rs @@ -24,7 +24,8 @@ impl<'s> MigrationSource<'s> for &'s Path { let mut migrations = Vec::new(); while let Some(entry) = s.next().await? { - if !entry.metadata.is_file() { + // std::fs::metadata traverses symlinks + if !std::fs::metadata(&entry.path)?.is_file() { // not a file; ignore continue; } diff --git a/tests/migrate/macro.rs b/tests/migrate/macro.rs index da7f901996..03cb578f7f 100644 --- a/tests/migrate/macro.rs +++ b/tests/migrate/macro.rs @@ -3,15 +3,18 @@ use std::path::Path; static EMBEDDED_SIMPLE: Migrator = sqlx::migrate!("tests/migrate/migrations_simple"); static EMBEDDED_REVERSIBLE: Migrator = sqlx::migrate!("tests/migrate/migrations_reversible"); +static EMBEDDED_SYMLINK: Migrator = sqlx::migrate!("tests/migrate/migrations_symlink"); #[sqlx_macros::test] async fn same_output() -> anyhow::Result<()> { let runtime_simple = Migrator::new(Path::new("tests/migrate/migrations_simple")).await?; let runtime_reversible = Migrator::new(Path::new("tests/migrate/migrations_reversible")).await?; + let runtime_symlink = Migrator::new(Path::new("tests/migrate/migrations_symlink")).await?; assert_same(&EMBEDDED_SIMPLE, &runtime_simple); assert_same(&EMBEDDED_REVERSIBLE, &runtime_reversible); + assert_same(&EMBEDDED_SYMLINK, &runtime_symlink); Ok(()) } diff --git a/tests/migrate/migrations_symlink b/tests/migrate/migrations_symlink new file mode 120000 index 0000000000..433d94398c --- /dev/null +++ b/tests/migrate/migrations_symlink @@ -0,0 +1 @@ +migrations_simple \ No newline at end of file