Class: Sail::Generators::UpdateGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sail::Generators::UpdateGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sail/update/update_generator.rb
Overview
UpdateGenerator
The UpdateGenerator analyzes the current state of the database and helps users upgrade to the latest Sail version.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(_path) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/sail/update/update_generator.rb', line 18 def self.next_migration_number(_path) if @prev_migration_nr @prev_migration_nr += 1 else @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end @prev_migration_nr.to_s end |
Instance Method Details
#copy_migrations ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/sail/update/update_generator.rb', line 28 def copy_migrations # Add migration to add group to settings # if upgrading from Sail <= 1.x.x if Sail::Setting.column_names.exclude?("group") migration_template "add_group_to_sail_settings.rb", "db/migrate/add_group_to_sail_settings.rb", migration_version: migration_version end # Add migration to create profiles # if upgrading from Sail <= 2.x.x unless ActiveRecord::Base.connection.table_exists?("sail_profiles") migration_template "#{__dir__}/../install/templates/create_sail_profiles.rb", "db/migrate/create_sail_profiles.rb", migration_version: migration_version end end |
#migration_version ⇒ Object
48 49 50 |
# File 'lib/generators/sail/update/update_generator.rb', line 48 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails.version.start_with?("5") end |