@@ -53,17 +53,21 @@ var (
5353 // so in the rest of the code we can know that we're running pg-delta logic.
5454 if viper .GetBool ("EXPERIMENTAL" ) && ! utils .IsPgDeltaEnabled () {
5555 utils .Config .Experimental .PgDelta = & config.PgDeltaConfig {Enabled : true }
56- return nil
5756 }
58- if utils .IsPgDeltaEnabled () {
59- return nil
57+ if ! utils .IsPgDeltaEnabled () {
58+ utils .CmdSuggestion = fmt .Sprintf ("Either pass %s or add %s with %s to %s" ,
59+ utils .Aqua ("--experimental" ),
60+ utils .Aqua ("[experimental.pgdelta]" ),
61+ utils .Aqua ("enabled = true" ),
62+ utils .Bold (utils .ConfigPath ))
63+ return errors .New ("declarative commands require --experimental flag or pg-delta enabled in config" )
6064 }
61- utils . CmdSuggestion = fmt . Sprintf ( "Either pass %s or add %s with %s to %s" ,
62- utils . Aqua ( "--experimental" ),
63- utils .Aqua ( "[experimental.pgdelta]" ),
64- utils . Aqua ( "enabled = true" ),
65- utils . Bold ( utils . ConfigPath ))
66- return errors . New ( "declarative commands require --experimental flag or pg-delta enabled in config" )
65+ // If the config.toml has [experimental.pgdelta] enabled = true, set the EXPERIMENTAL flag to true
66+ // so the follow-up PersistentPreRunE can run the pg-delta logic.
67+ if utils .Config . Experimental . PgDelta . Enabled {
68+ viper . Set ( "EXPERIMENTAL" , true )
69+ }
70+ return cmd . Root (). PersistentPreRunE ( cmd , args )
6771 },
6872 }
6973
0 commit comments