@@ -15,6 +15,11 @@ use postgate::token::generate_token;
1515#[ command( name = "postgate" ) ]
1616#[ command( version, about, long_about = None ) ]
1717struct 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