Skip to content

Commit c96999b

Browse files
committed
Set migrations optinnal
1 parent e5e9113 commit c96999b

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "postgate"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2024"
55
default-run = "postgate"
66
description = "Secure HTTP proxy for PostgreSQL with SQL validation and multi-tenant support"
@@ -10,8 +10,9 @@ keywords = ["postgresql", "proxy", "http", "sql", "serverless"]
1010
categories = ["database", "web-programming"]
1111

1212
[features]
13-
default = ["server"]
13+
default = ["server", "migrations"]
1414
server = ["dep:actix-web", "dep:actix-rt", "dep:clap", "dep:dotenvy", "dep:env_logger"]
15+
migrations = []
1516

1617
[dependencies]
1718
# Web server (optional - only for server feature)
@@ -51,7 +52,7 @@ env_logger = { version = "0.11.8", optional = true }
5152
dotenvy = { version = "0.15", optional = true }
5253

5354
# CLI (optional - only for server feature)
54-
clap = { version = "4", features = ["derive"], optional = true }
55+
clap = { version = "4", features = ["derive", "env"], optional = true }
5556

5657
[[bin]]
5758
name = "postgate"

src/main.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ use postgate::token::generate_token;
1515
#[command(name = "postgate")]
1616
#[command(version, about, long_about = None)]
1717
struct Cli {
18+
/// Skip database migrations (useful when using OpenWorkers schema)
19+
#[cfg(feature = "migrations")]
20+
#[arg(long, env = "POSTGATE_SKIP_MIGRATIONS")]
21+
skip_migrations: bool,
22+
1823
#[command(subcommand)]
1924
command: Option<Commands>,
2025
}
@@ -229,13 +234,21 @@ async fn main() -> std::io::Result<()> {
229234
.await
230235
.expect("Failed to create executor pool");
231236

232-
// Run migrations
233-
info!("Running database migrations...");
234-
sqlx::migrate!("./migrations")
235-
.run(executor_pool.shared_pool())
236-
.await
237-
.expect("Failed to run migrations");
238-
info!("Migrations completed");
237+
// Run migrations (unless skipped or feature disabled)
238+
#[cfg(feature = "migrations")]
239+
if cli.skip_migrations {
240+
info!("Skipping database migrations (--skip-migrations or POSTGATE_SKIP_MIGRATIONS=true)");
241+
} else {
242+
info!("Running database migrations...");
243+
sqlx::migrate!("./migrations")
244+
.run(executor_pool.shared_pool())
245+
.await
246+
.expect("Failed to run migrations");
247+
info!("Migrations completed");
248+
}
249+
250+
#[cfg(not(feature = "migrations"))]
251+
info!("Migrations disabled (compiled without 'migrations' feature)");
239252

240253
// Create store (uses the shared pool)
241254
let store = Store::new(executor_pool.shared_pool().clone());

0 commit comments

Comments
 (0)