dbmigrator 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dbmigrator"
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrey Vasenin"]
12
- s.date = "2013-03-20"
12
+ s.date = "2013-03-21"
13
13
  s.email = "vasenin@aboutecho.com"
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -4,6 +4,7 @@ require "task_manager"
4
4
  require "migration_generator"
5
5
  require "postgres"
6
6
  require "migration"
7
+ require "tempfile"
7
8
 
8
9
  load "active_record/railties/databases.rake"
9
10
 
@@ -63,19 +64,25 @@ db_namespace = namespace :db do
63
64
 
64
65
  namespace :structure do
65
66
  override_task :dump => [:environment, :load_config] do
66
- config = current_config
67
- unless config['adapter'] =~ /postgres/
68
- Rake::Task['db:structure:dump:original'].invoke
69
- next
70
- end
71
- filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql")
72
- set_psql_env(config)
73
- `pg_dump -i -s -O -f #{Shellwords.escape(filename)} #{Shellwords.escape(config['database'])}`
74
- raise 'Error dumping database' if $?.exitstatus == 1
75
- if ActiveRecord::Base.connection.supports_migrations?
76
- File.open(filename, "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
67
+ tempfile = Tempfile.new('migrator-structure').tap(&:close)
68
+ begin
69
+ config = current_config
70
+ unless config['adapter'] =~ /postgres/
71
+ Rake::Task['db:structure:dump:original'].invoke
72
+ next
73
+ end
74
+ set_psql_env(config)
75
+ `pg_dump -i -s -O -f #{Shellwords.escape(tempfile.path)} #{Shellwords.escape(config['database'])}`
76
+ raise 'Error dumping database' if $?.exitstatus == 1
77
+ if ActiveRecord::Base.connection.supports_migrations?
78
+ File.open(tempfile.path, "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
79
+ end
80
+ filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql")
81
+ FileUtils.cp tempfile.path, filename
82
+ db_namespace['structure:dump'].reenable
83
+ ensure
84
+ tempfile.unlink # deletes the temp file
77
85
  end
78
- db_namespace['structure:dump'].reenable
79
86
  end
80
87
  end
81
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbmigrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -96,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  segments:
98
98
  - 0
99
- hash: 1522855695555397277
99
+ hash: -2354698246710805387
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements: