Class: Pu::Lite::TuneGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Pu::Lite::TuneGenerator
- Includes:
- PlutoniumGenerators::Generator
- Defined in:
- lib/generators/pu/lite/tune/tune_generator.rb
Constant Summary collapse
- RAILS_8_1 =
::Gem::Version.new("8.1.0")
- DATABASE_YML =
"config/database.yml"
Instance Method Summary collapse
Methods included from PlutoniumGenerators::Generator
derive_association_name, find_shared_namespace, included
Methods included from PlutoniumGenerators::Concerns::Logger
#debug, #error, #exception, #info, #success, #warn
Methods included from PlutoniumGenerators::Concerns::Config
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/pu/lite/tune/tune_generator.rb', line 15 def start path = File.(DATABASE_YML, destination_root) unless File.exist?(path) log :skip, "#{DATABASE_YML} not found" return end content = File.read(path) if content.include?("wal_autocheckpoint") log :skip, "pragmas already tuned in #{DATABASE_YML}" return end new_content = apply_pragmas(content, rails_version) if new_content == content log :skip, "no `default: &default` block in #{DATABASE_YML}" return end create_file DATABASE_YML, new_content, force: true say_status :tune, "added SQLite pragmas to #{DATABASE_YML}" rescue => e exception "#{self.class} failed:", e end |