specjour 0.1.8 → 0.1.9
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.
- data/VERSION +1 -1
- data/lib/specjour/db_scrub.rb +21 -12
- data/lib/specjour.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/lib/specjour/db_scrub.rb
CHANGED
@@ -1,34 +1,43 @@
|
|
1
1
|
module Specjour
|
2
2
|
module DbScrub
|
3
|
+
load 'Rakefile'
|
3
4
|
extend self
|
4
5
|
|
5
6
|
def scrub
|
6
|
-
|
7
|
-
|
8
|
-
ActiveRecord::Base.connection
|
9
|
-
rescue # assume the database doesn't exist
|
10
|
-
Rake::Task['db:create'].invoke
|
7
|
+
connect_to_database
|
8
|
+
if pending_migrations?
|
11
9
|
Rake::Task['db:schema:load'].invoke
|
12
10
|
else
|
13
|
-
if pending_migrations?
|
14
|
-
Rake::Task['db:migrate'].invoke
|
15
|
-
end
|
16
|
-
|
17
11
|
purge_tables
|
18
12
|
end
|
19
13
|
end
|
20
14
|
|
21
15
|
protected
|
22
16
|
|
17
|
+
def connect_to_database
|
18
|
+
connection
|
19
|
+
rescue # assume the database doesn't exist
|
20
|
+
Rake::Task['db:create'].invoke
|
21
|
+
end
|
22
|
+
|
23
|
+
def connection
|
24
|
+
ActiveRecord::Base.connection
|
25
|
+
end
|
26
|
+
|
23
27
|
def purge_tables
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
connection.disable_referential_integrity do
|
29
|
+
tables_to_purge.each do |table|
|
30
|
+
connection.delete "delete from #{table}"
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
35
|
def pending_migrations?
|
31
36
|
ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations.any?
|
32
37
|
end
|
38
|
+
|
39
|
+
def tables_to_purge
|
40
|
+
connection.tables - ['schema_migrations']
|
41
|
+
end
|
33
42
|
end
|
34
43
|
end
|
data/lib/specjour.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 9
|
9
|
+
version: 0.1.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sandro Turriate
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-26 00:00:00 -04:00
|
18
18
|
default_executable: specjour
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|