activerecord_snapshot_view 0.11.3 → 0.11.4
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/activerecord_snapshot_view/snapshot_view.rb +13 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.4
|
@@ -46,6 +46,18 @@ module ActiveRecord
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
# remove all SnapshotView related tables for a model, making it a normal model again
|
50
|
+
# does not require that the SnapshotView module is included on the model class
|
51
|
+
def self.normalize(base_table)
|
52
|
+
view_tables = ActiveRecord::Base::connection.tables.select{|n| n=~ /^#{base_table}_([[:alpha:]]|switch)$/}
|
53
|
+
|
54
|
+
$stderr << "#{base_table} matches no view_tables\n" if view_tables.empty?
|
55
|
+
view_tables.each do |table|
|
56
|
+
ActiveRecord::Base::connection.execute( "drop table #{table}" )
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
49
61
|
# if a block given to the +new_version+ method throws this exception,
|
50
62
|
# then the working table will still be made current
|
51
63
|
class SaveWork < Exception
|
@@ -122,11 +134,11 @@ module ActiveRecord
|
|
122
134
|
if active_table_name != base_table_name
|
123
135
|
connection.execute( "truncate table #{base_table_name}" )
|
124
136
|
connection.execute( "insert into #{base_table_name} select * from #{active_table_name}" )
|
125
|
-
switch_to(base_table_name)
|
126
137
|
end
|
127
138
|
suffixed_table_names.each do |stn|
|
128
139
|
connection.execute( "drop table if exists #{stn}" )
|
129
140
|
end
|
141
|
+
connection.execute( "drop table #{switch_table_name}" )
|
130
142
|
end
|
131
143
|
|
132
144
|
def ensure_version_table(name)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 11
|
8
|
-
-
|
9
|
-
version: 0.11.
|
8
|
+
- 4
|
9
|
+
version: 0.11.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- mccraig mccraig of the clan mccraig
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-15 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|