Skip to content

Commit 0942a35

Browse files
committed
pr review
1 parent 661efe9 commit 0942a35

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

crates/pg_workspace/src/workspace/server/migration.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ pub(crate) fn get_migration(path: &Path, migrations_dir: &Path) -> Option<Migrat
2424
return None;
2525
}
2626

27-
// Try Root pattern
27+
// we are trying to match patterns used by popular migration tools
28+
29+
// in the "root" pattern, all files are directly within the migrations directory
30+
// and their names follow <timestamp>_<name>.sql.
31+
// this is used by supabase
2832
let root_migration = path
2933
.file_name()
3034
.and_then(|os_str| os_str.to_str())
@@ -39,7 +43,8 @@ pub(crate) fn get_migration(path: &Path, migrations_dir: &Path) -> Option<Migrat
3943
return root_migration;
4044
}
4145

42-
// Try Subdirectory pattern
46+
// in the "subdirectory" pattern, each migration is in a subdirectory named <timestamp>_<name>
47+
// this is used by prisma and drizzle
4348
path.parent()
4449
.and_then(|parent| parent.file_name())
4550
.and_then(|os_str| os_str.to_str())
@@ -95,7 +100,7 @@ mod tests {
95100
}
96101

97102
#[test]
98-
fn test_get_migration_non_migration_file() {
103+
fn test_get_migration_not_timestamp_in_filename() {
99104
let migrations_dir = PathBuf::from("/tmp/migrations");
100105
let path = migrations_dir.join("not_a_migration.sql");
101106

pglsp.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ username = "postgres"
1313
password = "postgres"
1414
database = "postgres"
1515

16-
[migrations]
17-
migrations_dir = "migrations"
18-
after = 20230912094327
16+
# [migrations]
17+
# migrations_dir = "migrations"
18+
# after = 20230912094327
1919

2020
[linter]
2121
enabled = true

0 commit comments

Comments
 (0)