Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a few more cast types using character varying #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ PATH
specs:
postgres_to_redshift (0.1.2)
aws-sdk-v1 (~> 1.54)
pg (~> 0.17.0)
pg (~> 0.18.0)

GEM
remote: https://rubygems.org/
specs:
aws-sdk-v1 (1.66.0)
aws-sdk-v1 (1.67.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
nokogiri (~> 1)
diff-lcs (1.2.5)
json (1.8.3)
mini_portile (0.6.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pg (0.17.1)
json (1.8.6)
mini_portile2 (2.3.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
pg (0.18.4)
rake (10.4.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
Expand All @@ -42,4 +42,4 @@ DEPENDENCIES
rspec

BUNDLED WITH
1.10.5
1.16.0
12 changes: 9 additions & 3 deletions lib/postgres_to_redshift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ def self.update_tables
update_tables = PostgresToRedshift.new

update_tables.tables.each do |table|
target_connection.exec("CREATE TABLE IF NOT EXISTS #{schema}.#{target_connection.quote_ident(table.target_table_name)} (#{table.columns_for_create})")
begin
retries ||= 3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this configurable, and default to 1?

target_connection.exec("CREATE TABLE IF NOT EXISTS #{schema}.#{target_connection.quote_ident(table.target_table_name)} (#{table.columns_for_create})")

update_tables.copy_table(table)
update_tables.copy_table(table)

update_tables.import_table(table)
update_tables.import_table(table)
rescue StandardError => e
retry unless retries += 1 < 3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be retry if retries += 1 < 3 ?

Can you also log the error?

next
end
end
end

Expand Down
3 changes: 3 additions & 0 deletions lib/postgres_to_redshift/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class PostgresToRedshift::Column
"bytea" => "CHARACTER VARYING(65535)",
"money" => "DECIMAL(19,2)",
"oid" => "CHARACTER VARYING(65535)",
"uuid" => "CHARACTER VARYING(65535)",
"inet" => "CHARACTER VARYING(65535)",
"time without time zone" => "CHARACTER VARYING(65535)",
"ARRAY" => "CHARACTER VARYING(65535)",
"USER-DEFINED" => "CHARACTER VARYING(65535)",
}
Expand Down