copy shared migrations and add comments to ignore file to explain

This commit is contained in:
Mark Sinclair
2025-11-04 14:30:44 +00:00
parent 5526c5bffd
commit c3a6ce8150
3 changed files with 32 additions and 1 deletions
+2
View File
@@ -1,2 +1,4 @@
# ignore files that are copied in from `../common/nyxd-scraper-psql/sql_migrations/* migrations`
# and remember to name the migrations to avoid collisions and so they process in the correct string sort order
0001_metadata.sql
0002_cosmos.sql
+2 -1
View File
@@ -45,5 +45,6 @@ utoipauto = { workspace = true }
[build-dependencies]
anyhow = { workspace = true }
glob = "0.3.3"
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
sqlx = { workspace = true, features = ["runtime-tokio-rustls", "postgres"] }
sqlx = { workspace = true, features = ["runtime-tokio-rustls", "postgres"] }
+28
View File
@@ -1,7 +1,35 @@
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use glob::glob;
use std::env;
use std::path::Path;
fn main() {
// copy common manifest files from "../common/nyxd-scraper-psql/sql_migrations/* migrations"
println!("Copying common migrations...");
let manifest_dir_string = env::var("CARGO_MANIFEST_DIR").unwrap();
let common_migrations_path =
Path::new(&manifest_dir_string).join("../common/nyxd-scraper-psql/sql_migrations/");
let output_path = Path::new(&manifest_dir_string).join("migrations");
println!(
"output_path: {:?} (exists = {})",
output_path,
output_path.exists()
);
let common_migrations_path = common_migrations_path.as_path();
println!(
"common_migrations_path: {:?} (exists = {})",
common_migrations_path,
common_migrations_path.exists()
);
for file in glob(&format!("{common_migrations_path:?}/*"))
.unwrap()
.flatten()
{
println!("- {file:?}");
std::fs::copy(file, &output_path).unwrap();
}
if let Ok(database_url) = std::env::var("DATABASE_URL") {
println!("cargo:rustc-env=DATABASE_URL={database_url}");
}