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 +5 -5
- data/.gitignore +2 -1
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +7 -1
- data/lib/pgreset.rb +10 -3
- data/lib/pgreset/version.rb +1 -1
- data/pgreset.gemspec +4 -3
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34faaca27defbd9899bcc44b48b501a1c10e2da614bac7a44549fcebd1434aea
|
4
|
+
data.tar.gz: 71f1207de1fd4e907dfab41811f3eb1cb82ffdec573ade06f1877f7450d3c3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dedf9dbffd685fd05073f9ad7a2321b98b7b40b2a043301e1160a3656ad71a0ea72edf0f842edf40f8e9a2fdfa86d9392b669a8b4c576a51681cb60f026c048
|
7
|
+
data.tar.gz: 8148337cad52a15fe7a70a3cfb2a21e1003a59727db228220ef65940e6828516016bf3d137517a44917ddc1fcceb64289068df6ebd47dfddc60fb84c12e877bc
|
data/.gitignore
CHANGED
data/{LICENSE → LICENSE.txt}
RENAMED
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/
|
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).
|
data/lib/pgreset.rb
CHANGED
@@ -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='#{
|
15
|
-
connection.drop_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
|
data/lib/pgreset/version.rb
CHANGED
data/pgreset.gemspec
CHANGED
@@ -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/
|
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", "~>
|
22
|
-
spec.add_development_dependency "rake", "~>
|
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.
|
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:
|
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:
|
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:
|
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:
|
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:
|
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/
|
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
|
-
|
78
|
-
|
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: []
|