Sha256: 101fb9c3922091c21710e80fc3a8a282c54fbed495adab12ddcff469742a6ced
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
require "rails/generators" module Multiverse module Generators class DbGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) argument :name def create_initializer lower_name = name.underscore template "record.rb", "app/models/#{lower_name}_record.rb" case ActiveRecord::Base.connection_config[:adapter] when "sqlite3" development_conf = "database: db/#{lower_name}_development.sqlite3" test_conf = "database: db/#{lower_name}_test.sqlite3" production_conf = "database: db/#{lower_name}_production.sqlite3" else development_conf = "database: #{lower_name}_development" test_conf = "database: #{lower_name}_test" production_conf = "url: <%= ENV['#{lower_name.upcase}_DATABASE_URL'] %>" end append_to_file "config/database.yml" do " #{name}_development: <<: *default #{development_conf} #{name}_test: <<: *default #{test_conf} #{name}_production: <<: *default #{production_conf} " end empty_directory "db/#{lower_name}/migrate" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems