Module: Debci::DB
- Defined in:
- lib/debci/db.rb
Constant Summary collapse
- LEGACY_MIGRATION =
if version_isnewer ActiveRecord::Migration else ActiveRecord::Migration[4.2] end
Class Method Summary collapse
Class Method Details
.config ⇒ Object
8 9 10 |
# File 'lib/debci/db.rb', line 8 def self.config @config ||= ENV['DATABASE_URL'] || Debci.config.database_url end |
.establish_connection ⇒ Object
12 13 14 |
# File 'lib/debci/db.rb', line 12 def self.establish_connection ActiveRecord::Base.establish_connection(config) end |
.migrate(target_version = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/debci/db.rb', line 16 def self.migrate(target_version = nil) migrations_path = File.join(File.dirname(__FILE__), 'db', 'migrations') ActiveRecord::Migration.verbose = !Debci.config.quiet if ActiveRecord.version.release >= Gem::Version.new('6.0') # ActiveRecord 6+ ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate(target_version) else # ActiveRecord 5.2 ActiveRecord::MigrationContext.new(migrations_path).migrate(target_version) end end |