Sha256: e178ff76363fa58ec963e79c3129f6d91735d1d6ca509926cef3587c5a191eed
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
class Recipes::Database < Rails::AppBuilder def ask databases = { postgresql: "PostgreSQL", mysql: "MySQL", none: "None, thanks" } database = answer(:db) do databases.keys[Ask.list("Which database are you using?", databases.values)] end set :database, database.to_sym end def create if db = databases(get(:database)) if db[:relational] activate_for_active_record(db) end end end def install ask create end private def databases(database) databases = { postgresql: { name: 'postgresql', gem_name: 'pg', version: '~> 0.21', relational: true }, mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true } } databases[database] end def activate_for_active_record(db) remove_file 'config/database.yml' template "../assets/config/database_#{db[:name]}.yml.erb", 'config/database.yml' discard_gem 'sqlite3' gather_gem 'strong_migrations' if db[:version] gather_gem db[:gem_name], db[:version] else gather_gem db[:gem_name] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
potassium-5.2.0 | lib/potassium/recipes/database.rb |