copydb 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/copydb.rb +6 -1
- metadata +3 -3
data/lib/copydb.rb
CHANGED
@@ -93,17 +93,22 @@ module CopyDb
|
|
93
93
|
next
|
94
94
|
end
|
95
95
|
unless entry[1].nil?
|
96
|
+
ActiveRecord::Base.connection.begin_db_transaction
|
96
97
|
columns = entry[1].each_key.to_a
|
97
98
|
quoted_column_names = columns.map { |column| ActiveRecord::Base.connection.quote_column_name(column) }.join(',')
|
98
99
|
|
99
100
|
for i in 1..(entry.length-1)
|
100
101
|
entries = entry[i].each_value.to_a
|
101
102
|
quoted_column_values = entries.map { |record| ActiveRecord::Base.connection.quote(record) }.join(',')
|
103
|
+
|
104
|
+
ActiveRecord::Base.connection.execute("ALTER TABLE #{entry[0]} DISABLE TRIGGER ALL;")
|
102
105
|
|
103
106
|
sql_string = "INSERT INTO #{entry[0]} (#{quoted_column_names}) VALUES (#{quoted_column_values});"
|
104
|
-
|
105
107
|
ActiveRecord::Base.connection.execute(sql_string)
|
108
|
+
|
109
|
+
ActiveRecord::Base.connection.execute("ALTER TABLE #{entry[0]} ENABLE TRIGGER ALL;")
|
106
110
|
end
|
111
|
+
ActiveRecord::Base.connection.commit_db_transaction
|
107
112
|
end
|
108
113
|
end
|
109
114
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copydb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-08-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faker
|
16
|
-
requirement: &
|
16
|
+
requirement: &17340460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.9.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17340460
|
25
25
|
description: Copydb is a gem that helps you to copy databases e.g. from a production
|
26
26
|
database to your development database. During the process it is possible to define
|
27
27
|
columns in tables in which the data should be exchanged for fake data. This can
|