@@ -143,13 +143,7 @@ defmodule AshPostgres.MigrationGenerator do
143143 end
144144
145145 defp opts ( opts ) do
146- case struct ( __MODULE__ , opts ) do
147- % { check: true } = opts ->
148- % { opts | dry_run: true }
149-
150- opts ->
151- opts
152- end
146+ struct ( __MODULE__ , opts )
153147 end
154148
155149 defp snapshot_path ( % { snapshot_path: snapshot_path } , _ ) when not is_nil ( snapshot_path ) ,
@@ -163,10 +157,17 @@ defmodule AshPostgres.MigrationGenerator do
163157 snapshot_path
164158 else
165159 priv =
166- config [ :priv ] || "priv/#{ repo |> Module . split ( ) |> List . last ( ) |> Macro . underscore ( ) } "
160+ config [ :priv ] || "priv/"
167161
168162 app = Keyword . fetch! ( config , :otp_app )
169- Application . app_dir ( app , Path . join ( priv , "resource_snapshots" ) )
163+
164+ Application . app_dir (
165+ app ,
166+ Path . join ( [
167+ priv ,
168+ "resource_snapshots"
169+ ] )
170+ )
170171 end
171172 end
172173
@@ -182,7 +183,7 @@ defmodule AshPostgres.MigrationGenerator do
182183 |> Path . join ( repo_name )
183184 |> Path . join ( "extensions.json" )
184185
185- unless opts . dry_run do
186+ unless opts . dry_run || opts . check do
186187 File . rename ( legacy_snapshot_file , snapshot_file )
187188 end
188189
@@ -383,7 +384,29 @@ defmodule AshPostgres.MigrationGenerator do
383384 if opts . dry_run do
384385 Mix . shell ( ) . info ( snapshot_contents )
385386 Mix . shell ( ) . info ( contents )
387+
388+ if opts . check do
389+ Mix . shell ( ) . error ( """
390+ Migrations would have been generated, but the --check flag was provided.
391+
392+ To see what migration would have been generated, run with the `--dry-run`
393+ option instead. To generate those migrations, run without either flag.
394+ """ )
395+
396+ exit ( { :shutdown , 1 } )
397+ end
386398 else
399+ if opts . check do
400+ Mix . shell ( ) . error ( """
401+ Migrations would have been generated, but the --check flag was provided.
402+
403+ To see what migration would have been generated, run with the `--dry-run`
404+ option instead. To generate those migrations, run without either flag.
405+ """ )
406+
407+ exit ( { :shutdown , 1 } )
408+ end
409+
387410 create_file ( snapshot_file , snapshot_contents , force: true )
388411 create_file ( migration_file , contents )
389412 end
0 commit comments