mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
fce0932afd
4 changed files with 64 additions and 18 deletions
5
Gemfile
5
Gemfile
|
@ -8,7 +8,10 @@ gem 'hashie_rails', '~> 0.0.1'
|
|||
# model related
|
||||
gem 'pg', '~> 0.18.0'
|
||||
gem 'ransack', '~> 1.5.1' # for searching
|
||||
gem 'paper_trail', '~> 4.0.0.beta2' # archiving
|
||||
# with polymorphic fix
|
||||
gem 'paper_trail',
|
||||
github: 'airblade/paper_trail',
|
||||
ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' # '~> 4.0.0.beta2' # archiving
|
||||
gem 'rails-settings-cached', '~> 0.4.1' # for settings
|
||||
gem 'delayed_job_active_record', '~> 4.0.3' # delayed job
|
||||
|
||||
|
|
16
Gemfile.lock
16
Gemfile.lock
|
@ -1,3 +1,13 @@
|
|||
GIT
|
||||
remote: git://github.com/airblade/paper_trail.git
|
||||
revision: a453811226ec4ea59753ba6b827e390ced2fc140
|
||||
ref: a453811226ec4ea59753ba6b827e390ced2fc140
|
||||
specs:
|
||||
paper_trail (4.0.0.beta3)
|
||||
activerecord (>= 3.0, < 6.0)
|
||||
activesupport (>= 3.0, < 6.0)
|
||||
request_store (~> 1.1.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/haml/html2haml.git
|
||||
revision: 6984f50bdbbd6291535027726a5697f28778ee8d
|
||||
|
@ -235,9 +245,6 @@ GEM
|
|||
nprogress-rails (0.1.6.5)
|
||||
open4 (1.3.4)
|
||||
orm_adapter (0.5.0)
|
||||
paper_trail (4.0.0.beta2)
|
||||
activerecord (>= 3.0, < 6.0)
|
||||
activesupport (>= 3.0, < 6.0)
|
||||
parser (2.2.0.2)
|
||||
ast (>= 1.1, < 3.0)
|
||||
pg (0.18.1)
|
||||
|
@ -309,6 +316,7 @@ GEM
|
|||
ruby_parser (~> 3.3)
|
||||
sexp_processor
|
||||
ref (1.0.5)
|
||||
request_store (1.1.0)
|
||||
responders (2.0.2)
|
||||
railties (>= 4.2.0.alpha, < 5)
|
||||
rspec (3.0.0)
|
||||
|
@ -469,7 +477,7 @@ DEPENDENCIES
|
|||
newrelic_rpm (~> 3.9.9.275)
|
||||
nokogiri (~> 1.6.2.1)
|
||||
nprogress-rails (~> 0.1.6.5)
|
||||
paper_trail (~> 4.0.0.beta2)
|
||||
paper_trail!
|
||||
pg (~> 0.18.0)
|
||||
phantomjs (~> 1.9.7.1)
|
||||
phantomjs-binaries (~> 1.9.2.4)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if ActiveRecord::Base.connection.table_exists? 'settings' # otherwise rake not working 100%
|
||||
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?('settings') # otherwise rake not working 100%
|
||||
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
||||
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
||||
Setting.disclosure_org_name = true if Setting.disclosure_org_name.nil?
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
namespace :db do
|
||||
def databases
|
||||
@db ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}", "#{Rails.env}"]
|
||||
def other_databases
|
||||
@db ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||
end
|
||||
|
||||
def schema_file(db)
|
||||
case db
|
||||
when databases.first
|
||||
when "api_log_#{Rails.env}"
|
||||
'api_log_schema.rb'
|
||||
when databases.second
|
||||
when "whois_#{Rails.env}"
|
||||
'whois_schema.rb'
|
||||
when databases.third
|
||||
'schema.rb'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,11 +22,41 @@ namespace :db do
|
|||
|
||||
desc 'Create all databases: registry, api_log and whois'
|
||||
task create: [:environment] do
|
||||
databases.each do |name|
|
||||
puts "\n---------------------------- Create main database ----------------------------------------\n"
|
||||
Rake::Task['db:create'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
conf = ActiveRecord::Base.configurations
|
||||
puts "\n---------------------------- Create #{name} ----------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.connection.create_database(conf[name]['database'], conf[name])
|
||||
conf = ActiveRecord::Base.configurations
|
||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Drop all databaseses: registry, api_log and whois'
|
||||
task drop: [:environment] do
|
||||
# just in case we allow only drop test, comment it out please for temp
|
||||
return unless Rails.env.test?
|
||||
|
||||
puts "\n---------------------------- Drop main database ----------------------------------------\n"
|
||||
Rake::Task['db:drop'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} dropped ----------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||
|
||||
conf = ActiveRecord::Base.configurations
|
||||
if ActiveRecord::Tasks::DatabaseTasks.drop(conf[name])
|
||||
puts "#{conf[name]['database']} dropped"
|
||||
else
|
||||
puts "Didn't find database #{name}, no drop"
|
||||
end
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
|
@ -38,9 +66,13 @@ namespace :db do
|
|||
namespace :schema do
|
||||
desc 'Schema load for all databases: registry, api_log and whois'
|
||||
task load: [:environment] do
|
||||
databases.each do |name|
|
||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
||||
Rake::Task['db:schema:load'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||
puts "\n---------------------------- #{name} schema loaded ----------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||
if ActiveRecord::Base.connection.table_exists?('schema_migrations')
|
||||
puts 'Found tables, skip schema load!'
|
||||
|
@ -55,7 +87,10 @@ namespace :db do
|
|||
|
||||
desc 'Schema load for all databases: registry, api_log and whois'
|
||||
task dump: [:environment] do
|
||||
databases.each do |name|
|
||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
||||
Rake::Task['db:schema:dump'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue