Skip to content

Commit

Permalink
fix model and migration generators
Browse files Browse the repository at this point in the history
  • Loading branch information
Yacine Petitprez committed Jul 5, 2018
1 parent 020d151 commit 2d49f65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/clear/cli/generators/migration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/clear/cli/generators/model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2d49f65

Please sign in to comment.