database_rewinder 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/database_rewinder.gemspec +1 -1
- data/lib/database_rewinder/cleaner.rb +2 -0
- data/test/config/database.yml +9 -2
- data/test/fake_app.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33fb09096b416644a0a992422fd4bd0b1f8b8957d447f96e6c825f61d0c1246a
|
4
|
+
data.tar.gz: 7f01e681757326b0ef190d046bc9620151b18736036b4529ccafbc57b261f2dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc22e635b796d03d57828b0bfae32ad0c611f1596cf2a945f91408285149b8ab151469ce696c4b359a592861611e7731e5bbad21f95b36b7ff0af074be4a4cee
|
7
|
+
data.tar.gz: b4f10e3069e8141bab9537a85ac48bfadf93b5cc029bfddfe35f9ce0c60c045a131c205a7587ca0e7fae19d1ccbc8912c4bdceeda1ab0bae6011d29572ada129
|
data/database_rewinder.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "database_rewinder"
|
9
|
-
spec.version = '0.9.
|
9
|
+
spec.version = '0.9.8'
|
10
10
|
spec.authors = ["Akira Matsuda"]
|
11
11
|
spec.email = ["ronnie@dio.jp"]
|
12
12
|
spec.description = "A minimalist's tiny and ultra-fast database cleaner for Active Record"
|
@@ -48,6 +48,8 @@ module DatabaseRewinder
|
|
48
48
|
def delete_all(ar_conn, tables, multiple: true)
|
49
49
|
tables = tables & @only if @only.any?
|
50
50
|
tables -= @except if @except.any?
|
51
|
+
# in order to avoid referential integrity error as much as possible
|
52
|
+
tables.reverse!
|
51
53
|
return if tables.empty?
|
52
54
|
|
53
55
|
if multiple && tables.many? && ar_conn.supports_multiple_statements?
|
data/test/config/database.yml
CHANGED
@@ -28,18 +28,25 @@ test2:
|
|
28
28
|
database: database_rewinder_test2
|
29
29
|
|
30
30
|
<% when 'postgresql' %>
|
31
|
-
|
31
|
+
superuser_connection:
|
32
32
|
adapter: postgresql
|
33
33
|
host: localhost
|
34
34
|
# this user has to be a superuser for the tests to pass
|
35
35
|
username: postgres
|
36
36
|
password: postgres
|
37
|
+
database: postgres
|
38
|
+
|
39
|
+
test:
|
40
|
+
adapter: postgresql
|
41
|
+
host: localhost
|
42
|
+
username: database_rewinder_user
|
43
|
+
password: postgres
|
37
44
|
database: database_rewinder_test
|
38
45
|
|
39
46
|
test2:
|
40
47
|
adapter: postgresql
|
41
48
|
host: localhost
|
42
|
-
username:
|
49
|
+
username: database_rewinder_user
|
43
50
|
password: postgres
|
44
51
|
database: database_rewinder_test2
|
45
52
|
<% end %>
|
data/test/fake_app.rb
CHANGED
@@ -18,6 +18,21 @@ module DatabaseRewinderTestApp
|
|
18
18
|
end
|
19
19
|
|
20
20
|
require 'active_record/base'
|
21
|
+
|
22
|
+
if ENV['DB'] == 'postgresql'
|
23
|
+
ActiveRecord::Base.establish_connection(:superuser_connection).connection.execute(<<-CREATE_ROLE_SQL)
|
24
|
+
DO
|
25
|
+
$do$
|
26
|
+
BEGIN
|
27
|
+
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'database_rewinder_user') THEN
|
28
|
+
CREATE ROLE database_rewinder_user LOGIN PASSWORD 'postgres' createdb;
|
29
|
+
END IF;
|
30
|
+
END
|
31
|
+
$do$
|
32
|
+
CREATE_ROLE_SQL
|
33
|
+
ActiveRecord::Base.remove_connection
|
34
|
+
end
|
35
|
+
|
21
36
|
ActiveRecord::Tasks::DatabaseTasks.root ||= Rails.root
|
22
37
|
ActiveRecord::Tasks::DatabaseTasks.drop_current 'test'
|
23
38
|
ActiveRecord::Tasks::DatabaseTasks.drop_current 'test2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_rewinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.4.0.dev
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: A minimalist's tiny and ultra-fast database cleaner
|