prodder 1.7.5 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26e389eb90419a1ac54845075f953e58fd3b1035214854773ead1528c338707a
4
- data.tar.gz: b57a008eca5e26de21fbbc47f25e7ffd582b6f5a0d5228e913154dbb502cfe5b
3
+ metadata.gz: bffad577e74259c3700295becff4baeafd8fa42038529e104e46edf6cbd59ca2
4
+ data.tar.gz: 0283df1e58d3b49ea8c51bf7b715230bffbf9b51e031ae5450c5c9d83dcb6c36
5
5
  SHA512:
6
- metadata.gz: e856705e7bcdd77de90de067aa20093ada1e6da740bdb3643134de9b9c6a5e164776d7aa7c5f3f02b3bcf0f93bac526a56cda7ce0662d2beadb6410a896025ce
7
- data.tar.gz: b36befbd98f1e3df3c7674f30fbc82f9ddd2766805c597e2f6340a3e0068dc6b72c54be7fc795f168bc3b3b67b9e4ae5742ed13c6f11a25d9a307084f21e9808
6
+ metadata.gz: 0cd59679ebdf492e96a0f1858217660dca26f68b910d38df60cd9877de773a4998e90280900cc539ad4eb286ae4ce995e33aebfb3f8f8a76ee4925dc95da9203
7
+ data.tar.gz: 6e144e41880ed23e55f11ab6688b5bfdcba6fdf46faa451cb096c42c38a1e8778f98e558adbfee27f40981f0b56f1b3a095b325c29af0da4656f09c39d773d0e
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
  prodder [![Build Status](https://travis-ci.org/enova/prodder.svg?branch=master)](https://travis-ci.org/enova/prodder)
3
3
  =======
4
4
 
5
- A tool to maintain and load your Rails application's database structure and seed
6
- table contents, based on its migration history and the current in production
7
- databases.
5
+ A tool to maintain and load your Rails application's database structure, seed
6
+ table contents, permissions and database settings based on its migration history
7
+ and the current state in production databases.
8
8
 
9
9
  In short: `db:reset db:migrate`
10
10
 
@@ -203,24 +203,26 @@ namespace :db do
203
203
  namespace :structure do
204
204
  desc "Load db/structure.sql into the current environment's database"
205
205
  task :load => dependencies do
206
- config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
207
- config["username"] = config["superuser"] if config["superuser"] && File.exist?('db/permissions.sql')
208
- set_psql_env config
209
- puts "Loading db/structure.sql into database '#{config['database']}'"
210
- `psql --no-psqlrc -f db/structure.sql #{Shellwords.escape(config['database'])}`
211
- raise 'Error loading db/structure.sql' if $?.exitstatus != 0
206
+ as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
207
+ config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
208
+ set_psql_env config
209
+ puts "Loading db/structure.sql into database '#{config['database']}'"
210
+ `psql --no-psqlrc -f db/structure.sql #{Shellwords.escape(config['database'])}`
211
+ raise 'Error loading db/structure.sql' if $?.exitstatus != 0
212
+ end
212
213
  end
213
214
  end
214
215
 
215
216
  desc "Load initial seeds from db/seeds.sql"
216
217
  task :seed => dependencies do
217
218
  if File.exist?('db/seeds.sql')
218
- config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
219
- config["username"] = config["superuser"] if config["superuser"] && File.exist?('db/permissions.sql')
220
- set_psql_env config
221
- puts "Loading db/seeds.sql into database '#{config['database']}'"
222
- `psql --no-psqlrc -f db/seeds.sql #{Shellwords.escape(config['database'])}`
223
- raise 'Error loading db/seeds.sql' if $?.exitstatus != 0
219
+ as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
220
+ config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
221
+ set_psql_env config
222
+ puts "Loading db/seeds.sql into database '#{config['database']}'"
223
+ `psql --no-psqlrc -f db/seeds.sql #{Shellwords.escape(config['database'])}`
224
+ raise 'Error loading db/seeds.sql' if $?.exitstatus != 0
225
+ end
224
226
  else
225
227
  puts 'db/seeds.sql not found: no seeds to load.'
226
228
  end
@@ -229,12 +231,13 @@ namespace :db do
229
231
  desc "Load quality_checks (indexes, triggers, foreign keys) from db/quality_checks.sql"
230
232
  task :quality_check => dependencies do
231
233
  if File.exist?('db/quality_checks.sql')
232
- config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
233
- config["username"] = config["superuser"] if config["superuser"] && File.exist?('db/permissions.sql')
234
- set_psql_env config
235
- puts "Loading db/quality_checks.sql into database '#{config['database']}'"
236
- `psql --no-psqlrc -f db/quality_checks.sql #{Shellwords.escape(config['database'])}`
237
- raise 'Error loading db/quality_checks.sql' if $?.exitstatus != 0
234
+ as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
235
+ config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
236
+ set_psql_env config
237
+ puts "Loading db/quality_checks.sql into database '#{config['database']}'"
238
+ `psql --no-psqlrc -f db/quality_checks.sql #{Shellwords.escape(config['database'])}`
239
+ raise 'Error loading db/quality_checks.sql' if $?.exitstatus != 0
240
+ end
238
241
  else
239
242
  puts 'db/quality_checks.sql not found: no quality_checks to load.'
240
243
  end
@@ -243,20 +246,19 @@ namespace :db do
243
246
  desc "Load permissions (DB object level access control, group role memberships) from db/permissions.sql"
244
247
  task :permission => dependencies do
245
248
  if File.exist?('db/permissions.sql')
246
- config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
247
- config["username"] = config["superuser"] if config["superuser"]
248
- set_psql_env config
249
- puts "Loading db/permissions.sql into database '#{config['database']}'"
250
- disconnect
251
- ActiveRecord::Base.establish_connection((ENV['RAILS_ENV'] || Rails.env).intern)
252
- result = ActiveRecord::Base.connection.execute(<<-SQL).first
253
- select 1 as is_super from pg_roles where rolname = '#{config['username']}' and rolsuper
254
- SQL
255
- unless result && result['is_super']
256
- puts "warning: Restoring permissions as config/database.yml non-superuser: '#{config['username']}', expect errors, or rerun after granting superuser"
249
+ as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
250
+ config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
251
+ set_psql_env config
252
+ puts "Loading db/permissions.sql into database '#{config['database']}'"
253
+ result = ActiveRecord::Base.connection.execute(<<-SQL).first
254
+ select 1 as is_super from pg_roles where rolname = '#{config['username']}' and rolsuper
255
+ SQL
256
+ unless result && result['is_super']
257
+ puts "warning: Restoring permissions as config/database.yml non-superuser: '#{config['username']}', expect errors, or rerun after granting superuser"
258
+ end
259
+ `psql --no-psqlrc -f db/permissions.sql #{Shellwords.escape(config['database'])}`
260
+ raise 'Error loading db/permissions.sql' if $?.exitstatus != 0
257
261
  end
258
- `psql --no-psqlrc -f db/permissions.sql #{Shellwords.escape(config['database'])}`
259
- raise 'Error loading db/permissions.sql' if $?.exitstatus != 0
260
262
  else
261
263
  puts 'db/permissions.sql not found: no permissions to load.'
262
264
  end
@@ -265,20 +267,19 @@ namespace :db do
265
267
  desc "Load database settings"
266
268
  task :settings => dependencies do
267
269
  if File.exist?('db/settings.sql')
268
- config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
269
- config["username"] = config["superuser"] if config["superuser"] && File.exist?('db/permissions.sql')
270
- set_psql_env config
271
- puts "Loading db/settings.sql into database '#{config['database']}'"
272
- disconnect
273
- ActiveRecord::Base.establish_connection((ENV['RAILS_ENV'] || Rails.env).intern)
274
- result = ActiveRecord::Base.connection.execute(<<-SQL).first
275
- select 1 as is_super from pg_roles where rolname = '#{config['username']}' and rolsuper
276
- SQL
277
- unless result && result['is_super']
278
- puts "warning: Restoring settings as config/database.yml non-superuser: '#{config['username']}', expect errors, or rerun after granting superuser"
270
+ as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
271
+ config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
272
+ set_psql_env config
273
+ puts "Loading db/settings.sql into database '#{config['database']}'"
274
+ result = ActiveRecord::Base.connection.execute(<<-SQL).first
275
+ select 1 as is_super from pg_roles where rolname = '#{config['username']}' and rolsuper
276
+ SQL
277
+ unless result && result['is_super']
278
+ puts "warning: Restoring settings as config/database.yml non-superuser: '#{config['username']}', expect errors, or rerun after granting superuser"
279
+ end
280
+ `psql --no-psqlrc -f db/settings.sql #{Shellwords.escape(config['database'])}`
281
+ raise 'Error loading db/settings.sql' if $?.exitstatus != 0
279
282
  end
280
- `psql --no-psqlrc -f db/settings.sql #{Shellwords.escape(config['database'])}`
281
- raise 'Error loading db/settings.sql' if $?.exitstatus != 0
282
283
  else
283
284
  puts 'db/settings.sql not found: no settings to load.'
284
285
  end
@@ -1,3 +1,3 @@
1
1
  module Prodder
2
- VERSION = "1.7.5"
2
+ VERSION = "1.7.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prodder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Hargraves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deject
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.7.6
85
+ rubygems_version: 2.7.7
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Maintain your Rails apps' structure, seed and quality_checks files using