Class: Bard::Utf8mb4MigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



9
10
11
12
# File 'lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb', line 9

def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1
  ActiveRecord::Migration.next_migration_number(next_migration_number)
end

Instance Method Details

#install_migrationObject



14
15
16
# File 'lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb', line 14

def install_migration
  migration_template "migration.rb", "db/migrate/convert_to_utf8mb4.rb"
end

#specify_charset_and_collation_in_database_ymlObject



18
19
20
21
22
# File 'lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb', line 18

def specify_charset_and_collation_in_database_yml
  ["config/database.yml", "config/database.sample.yml"].each do |file|
    inject_into_file file, "  charset: utf8mb4\n", after: "  socket: /var/run/mysqld/mysqld.sock\n"
  end
end