pgreset 0.1.1 → 0.2

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
- SHA1:
3
- metadata.gz: 59d339c9ccaf6e9ff9c8901629f53380bb30b4d1
4
- data.tar.gz: cac6274c05f6ef656bf31dfc7bb340c6705c4660
2
+ SHA256:
3
+ metadata.gz: 34faaca27defbd9899bcc44b48b501a1c10e2da614bac7a44549fcebd1434aea
4
+ data.tar.gz: 71f1207de1fd4e907dfab41811f3eb1cb82ffdec573ade06f1877f7450d3c3d0
5
5
  SHA512:
6
- metadata.gz: 8382b5e2ec778346a58bb87b71b316496dd762973bf6f146eec3d2a2700bb555311fdda033a5aacb64d51f4b51484d499f2138dbc48a5ac7f2ae4fe5fe9461f2
7
- data.tar.gz: d3c2247cdfbdc28d1dc0a1b544f079bf08c0bfc18e938b371bc6a4295219b6e8c8cce3a6d742799bfd70b0abb2867996f7463c9074974d6dec79057d453c2a62
6
+ metadata.gz: 9dedf9dbffd685fd05073f9ad7a2321b98b7b40b2a043301e1160a3656ad71a0ea72edf0f842edf40f8e9a2fdfa86d9392b669a8b4c576a51681cb60f026c048
7
+ data.tar.gz: 8148337cad52a15fe7a70a3cfb2a21e1003a59727db228220ef65940e6828516016bf3d137517a44917ddc1fcceb64289068df6ebd47dfddc60fb84c12e877bc
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- *gem
10
+ *gem
11
+ .idea/
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016 falconed
3
+ Copyright (c) 2020 Dan Falcone
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,6 +4,8 @@ The pgreset gem makes it possible to run rails db:reset against a postgres datab
4
4
 
5
5
  Credit for the [original solution](https://github.com/basecamp/pow/issues/212) goes to [Manuel Meurer](https://github.com/manuelmeurer).
6
6
 
7
+ Special thanks to [Emil Kampp](https://github.com/ekampp) and [Michael Yin](https://github.com/layerssss) for adding Rails 6.1 support.
8
+
7
9
  ## Installation and Usage
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -33,5 +35,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
35
 
34
36
  ## Contributing
35
37
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/falconed/pgreset.
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dafalcon/pgreset.
39
+
40
+ ## License
37
41
 
42
+ The gem is available as open source under the terms of the [MIT
43
+ License](https://opensource.org/licenses/MIT).
@@ -5,14 +5,21 @@ module ActiveRecord
5
5
  class PostgreSQLDatabaseTasks
6
6
  def drop
7
7
  establish_master_connection
8
-
8
+
9
+ database_name =
10
+ begin
11
+ self.configuration_hash[:database] || self.configuration_hash.fetch('database')
12
+ rescue NoMethodError
13
+ configuration['database']
14
+ end
15
+
9
16
  pid_column = 'pid' # Postgresql 9.2 and newer
10
17
  if 0 == connection.select_all("SELECT column_name FROM information_schema.columns WHERE table_name = 'pg_stat_activity' AND column_name = 'pid';").count
11
18
  pid_column = 'procpid' # Postgresql 9.1 and older
12
19
  end
13
20
 
14
- connection.select_all "SELECT pg_terminate_backend(pg_stat_activity.#{pid_column}) FROM pg_stat_activity WHERE datname='#{configuration['database']}' AND #{pid_column} <> pg_backend_pid();"
15
- connection.drop_database configuration['database']
21
+ connection.select_all "SELECT pg_terminate_backend(pg_stat_activity.#{pid_column}) FROM pg_stat_activity WHERE datname='#{database_name}' AND #{pid_column} <> pg_backend_pid();"
22
+ connection.drop_database database_name
16
23
  end
17
24
  end
18
25
  end
@@ -1,3 +1,3 @@
1
1
  module Pgreset
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -11,13 +11,14 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Automatically kill postgres connections during db:reset}
13
13
  spec.description = %q{Kills postgres connections during db:reset so you don't have to restart your server. Fixes "database in use" errors.}
14
- spec.homepage = "https://github.com/falconed/pgreset"
14
+ spec.homepage = "https://github.com/dafalcon/pgreset"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = "exe"
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
+ spec.licenses = ['MIT']
20
21
 
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler", "~> 2.2.4"
23
+ spec.add_development_dependency "rake", "~> 13.0.3"
23
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgreset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Falcone
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: 2.2.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: 2.2.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 13.0.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 13.0.3
41
41
  description: Kills postgres connections during db:reset so you don't have to restart
42
42
  your server. Fixes "database in use" errors.
43
43
  email:
@@ -48,7 +48,7 @@ extra_rdoc_files: []
48
48
  files:
49
49
  - ".gitignore"
50
50
  - Gemfile
51
- - LICENSE
51
+ - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
54
  - bin/console
@@ -56,10 +56,11 @@ files:
56
56
  - lib/pgreset.rb
57
57
  - lib/pgreset/version.rb
58
58
  - pgreset.gemspec
59
- homepage: https://github.com/falconed/pgreset
60
- licenses: []
59
+ homepage: https://github.com/dafalcon/pgreset
60
+ licenses:
61
+ - MIT
61
62
  metadata: {}
62
- post_install_message:
63
+ post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
65
66
  - lib
@@ -74,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.8
79
- signing_key:
78
+ rubygems_version: 3.0.6
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: Automatically kill postgres connections during db:reset
82
82
  test_files: []