Skip to content

Commit

Permalink
Allow for custom generation path
Browse files Browse the repository at this point in the history
  • Loading branch information
zachahn committed Nov 27, 2024
1 parent 4310b72 commit 409afdf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
representing the current job being executed
* Added `Disqualified::Job#current_sequence`, which returns the ActiveRecord
object representing the current sequence
* Handle ActiveRecord's multi-database feature in the installation generator

### Changed

Expand Down
2 changes: 2 additions & 0 deletions lib/generators/disqualified/install/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Description:

Example:
bin/rails generate disqualified:install
bin/rails generate disqualified:install --database primary
bin/rails g disqualified:install --db=animals

This will create:
db/migrate/20220703062536_create_disqualified_jobs.rb
13 changes: 11 additions & 2 deletions lib/generators/disqualified/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
require "rails/generators/active_record"

class Disqualified::InstallGenerator < Rails::Generators::Base
include ActiveRecord::Generators::Migration

source_root File.expand_path("templates", __dir__)

class_option :database,
type: :string,
aliases: %i[--db],
desc: "The database for your migration. By default, the current environment's primary database is used."

def copy_migration_file
basename = "20220703062536_create_disqualified_jobs.rb"
copy_file(basename, "db/migrate/#{basename}")
copy_file(basename, File.join(db_migrate_path, basename))

basename = "20241119023328_create_disqualified_sequences.rb"
copy_file(basename, "db/migrate/#{basename}")
copy_file(basename, File.join(db_migrate_path, basename))
end
end
1 change: 1 addition & 0 deletions sorbet/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--dir
.
--ignore=lib/generators/disqualified/
--ignore=vendor/
--enable-experimental-requires-ancestor

0 comments on commit 409afdf

Please sign in to comment.