Class: Kowl::DatabaseGenerator

Inherits:
Generators::Base show all
Defined in:
lib/kowl/generators/database_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

default_source_root, source_paths

Methods included from Docker

#alpine_docker_dependencies, #app_js_volumes, #app_volumes, #db_volumes, #debian_database_dependencies, #debian_docker_dependencies, #docker_app_command, #docker_compose_database_string, #docker_databases, #docker_depends_on, #docker_port_watcher, #docker_redis_service, #docker_sidekiq_service, #docker_variables, #docker_volumes, #docker_webpacker_service, #dockerfile_database_args, #dockerfile_migration_snip, #js_volumes, #mysql_volumes, #postgresql_volumes, #redis_volumes

Methods included from Actions

#add_extension_routes, #add_package, #append_to_file, #database_route, #dev_config, #dup_file, #file_exists?, #mailer_gems, #mailer_route, #mk_dir, #move_file, #pry_gems, #rails_cmd, #remove_dir, #remove_file, #remove_gem, #replace_string_in_file, #robocop_test_engine, #sidekiq_route, #template_linter_gems

Instance Method Details

#copy_seed_fileObject

Copy a base seef file to the application with sample users



33
34
35
# File 'lib/kowl/generators/database_generator.rb', line 33

def copy_seed_file
  template('db/seeds.rb.tt', 'db/seeds.rb', force: true)
end

#make_ar_immutableObject

Add frozen_string_literal to application_record.rb



38
39
40
# File 'lib/kowl/generators/database_generator.rb', line 38

def make_ar_immutable
  inject_into_file('app/models/application_record.rb', "# frozen_string_literal: true\n\n", before: "class ApplicationRecord < ActiveRecord::Base\n")
end

#setup_annotateObject

Used to generate the config for automatically generating annotated models



18
19
20
# File 'lib/kowl/generators/database_generator.rb', line 18

def setup_annotate
  generate('annotate:install')
end

#setup_pgheroObject

If the application is using postgresql this will add pghero to the application



23
24
25
26
27
28
29
30
# File 'lib/kowl/generators/database_generator.rb', line 23

def setup_pghero
  return unless options[:database] == 'postgresql'

  generate('pghero:config') # generate PGhero config
  generate('pghero:query_stats') # generate pghero stats migrations
  generate('pghero:space_stats')
  add_to_assets('pghero/application.js pghero/application.css')
end