diff --git a/src/clear/cli/generators/migration.cr b/src/clear/cli/generators/migration.cr index 6f38672dc..dcd18b199 100644 --- a/src/clear/cli/generators/migration.cr +++ b/src/clear/cli/generators/migration.cr @@ -33,7 +33,7 @@ class Clear::CLI::Generator migration_file = "#{migration_uid}_#{name_underscore}.cr" if Dir[File.join(g.target_directory, "src/db/migrations/*_#{name_underscore}.cr")].any? - puts "Migration file `*_#{name_underscore}.cr` already exists" + puts "A migration file `xxxx_#{name_underscore}.cr` already exists" exit 1 end diff --git a/src/clear/cli/generators/model.cr b/src/clear/cli/generators/model.cr index b2c56788a..dbc1b1bc0 100644 --- a/src/clear/cli/generators/model.cr +++ b/src/clear/cli/generators/model.cr @@ -36,7 +36,12 @@ class Clear::CLI::Generator g["model_fields"] = fields model_file = "#{name_underscore}.cr" - migration_file = "#{migration_uid}_create_#{name_underscore}.cr" + migration_file = "#{migration_uid}_create_#{name_underscore.pluralize}.cr" + + if Dir[File.join(g.target_directory, "src/db/migrations/*_create_#{name_underscore.pluralize}.cr")].any? + puts "A migration file `xxxx__create_#{name_underscore.pluralize}.cr` already exists" + exit 1 + end g.in_directory "src/models" do g.file(model_file, Clear::CLI::Generator.ecr_to_s("#{__DIR__}/../../../../templates/model/model.cr.ecr", g))