sequel-from_csv 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/extensions/from_csv.rb +2 -2
- data/lib/sequel/plugins/from_csv.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8486d07dffd74cc99acc09f50b2d328a400d7184a4bb01cf3f9e65137f123c1a
|
4
|
+
data.tar.gz: 7864b520d687801d1632ae51c9f30088a32630b9b3cff3a8adeeda8c2f815ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d063f09423177c125a09313c98817ec238f49efacdcfd6880f10fdd0cd09f4e64755c641445c791532868df1e420bb14f79faea27c92d87bfb24a550866359
|
7
|
+
data.tar.gz: '099c7c16f203f9c5c63e2dfd22622929416fe582f39d66e6377af02544b0ad5b20a86570a2b65b1f3b60f2274206cf7fb80d345ffd9d2dc29f39c197e89db1e3'
|
@@ -14,9 +14,9 @@ module Sequel
|
|
14
14
|
#
|
15
15
|
# *Options:*
|
16
16
|
# :delete_missing :: whether to remove rows from the table that were not found in the CSV file
|
17
|
-
# :
|
17
|
+
# :resequence :: whether to update the primary key's sequence to reflect the max primary key value
|
18
18
|
#
|
19
|
-
# :
|
19
|
+
# :resequence only works on PostgreSQL tables that auto-increment their primary keys using sequences
|
20
20
|
def seed_from_csv directory, **opts
|
21
21
|
|
22
22
|
Dir.glob("#{directory}/**/*.csv").each do |filename|
|
@@ -17,16 +17,16 @@ module Sequel
|
|
17
17
|
#
|
18
18
|
# *Options:*
|
19
19
|
# :delete_missing :: whether to remove rows from the table that were not found in the CSV file
|
20
|
-
# :
|
20
|
+
# :resequence :: whether to update the primary key's sequence to reflect the max primary key value
|
21
21
|
#
|
22
|
-
# :
|
22
|
+
# :resequence only works on PostgreSQL tables that auto-increment their primary keys using sequences
|
23
23
|
#
|
24
24
|
# *Usage:*
|
25
25
|
# class Artist < Sequel::Model
|
26
26
|
# plugin :from_csv
|
27
27
|
# end
|
28
|
-
# Artist.seed_from_csv "seeds/artists.csv",
|
29
|
-
def seed_from_csv csv_path, delete_missing: false,
|
28
|
+
# Artist.seed_from_csv "seeds/artists.csv", resequence: true
|
29
|
+
def seed_from_csv csv_path, delete_missing: false, resequence: false
|
30
30
|
|
31
31
|
# Read the source CSV file
|
32
32
|
data = CSV.table csv_path, converters: :date_time
|
@@ -61,7 +61,7 @@ module Sequel
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# Update the table's sequence
|
64
|
-
if
|
64
|
+
if resequence
|
65
65
|
case self.db.database_type
|
66
66
|
when :postgres
|
67
67
|
self.db.run <<~SQL
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-from_csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenaniah Cerny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|