activerecord_snapshot_view 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/activerecord_snapshot_view/snapshot_view.rb +9 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.1
|
@@ -237,14 +237,16 @@ module ActiveRecord
|
|
237
237
|
end
|
238
238
|
|
239
239
|
# like new_version, but instead of an empty table you start with
|
240
|
-
# a copy of the previous version
|
241
|
-
def updated_version(&block)
|
240
|
+
# a copy of the previous version (if update=true)
|
241
|
+
def updated_version(update=true, &block)
|
242
242
|
new_version do
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
243
|
+
if update
|
244
|
+
sql = <<-EOF
|
245
|
+
insert into #{working_table_name}
|
246
|
+
select * from #{active_table_name}
|
247
|
+
EOF
|
248
|
+
connection.execute(sql)
|
249
|
+
end
|
248
250
|
block.call
|
249
251
|
end
|
250
252
|
end
|