-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
30 lines (22 loc) · 890 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true
require('bundler/gem_tasks')
task(default: :spec)
require('active_record')
require('active_record/database_configurations/database_config')
require('active_record/database_configurations/url_config')
database_url = ENV.fetch('DATABASE_URL')
namespace :db do
task :create do
database = ActiveRecord::DatabaseConfigurations::UrlConfig.new(nil, nil, database_url)
ActiveRecord::Tasks::DatabaseTasks.create(database.config)
end
task :migrate do
base_path = Gem.loaded_specs['benchmarker-data'].full_gem_path
full_path = File.join(base_path, 'db', 'migrations')
ActiveRecord::MigrationContext.new(full_path, ActiveRecord::SchemaMigration).migrate
end
task :drop do
database = ActiveRecord::DatabaseConfigurations::UrlConfig.new(nil, nil, database_url)
ActiveRecord::Tasks::DatabaseTasks.drop(database.config)
end
end