blue-shift 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 854cfe4464d33859954cd59b31e0aab3416ff3c3
4
- data.tar.gz: 36e046e96ca8f013b9a1dcfed1017334f2a2c4a1
3
+ metadata.gz: f9ff2aa70afe9aae6299cd15f51a8afb60862184
4
+ data.tar.gz: a275f2007b457f80140668ca19917739c6e4270c
5
5
  SHA512:
6
- metadata.gz: 5a3dacb4ab8e472434905142c1f1ffe344a269cc80e1e8194524bc10b80c1dddeab08677be3ff2961f463b8da3de0a36170a12a6614b771759d5c1b0da959e32
7
- data.tar.gz: f3969bf286f9e125c1d621e8bcab8e4ada926757d688844ee6888b1b7ac6b601c8436fb442a20e5887d9a6a5fef6216b5dee71af5f5b2518659f15eaebb9c72a
6
+ metadata.gz: 7f4473e6459b7b5fbfd8a6f1a9a7d12b4de70671cf6cc92e3d75a3301d4fa8361d48cb89d6a7115d3fc949d3e80f51dbab97488fc2b23f10bc74f1f358854be9
7
+ data.tar.gz: 41d9dccc4493a44f10bbf4625c5dd83491834f045b45951d4e63593fd8db269600ade1ac869b4c8a2b154ac0ab8a97e26fabb0d7a95e594ac8429b251bb65007
@@ -1,3 +1,3 @@
1
1
  module Blueshift
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -88,26 +88,25 @@ module Sequel
88
88
  def schema_parse_table(table_name, opts)
89
89
  m = output_identifier_meth(opts[:dataset])
90
90
  ds = metadata_dataset.select(:pg_attribute__attname___name,
91
- SQL::Cast.new(:pg_attribute__atttypid, :integer).as(:oid),
92
- SQL::Cast.new(:basetype__oid, :integer).as(:base_oid),
93
- SQL::Function.new(:format_type, :basetype__oid, :pg_type__typtypmod).as(:db_base_type),
94
- SQL::Function.new(:format_type, :pg_type__oid, :pg_attribute__atttypmod).as(:db_type),
95
- SQL::Function.new(:pg_get_expr, :pg_attrdef__adbin, :pg_class__oid).as(:default),
96
- SQL::BooleanExpression.new(:NOT, :pg_attribute__attnotnull).as(:allow_null),
97
- SQL::Function.new(:COALESCE,
98
- SQL::BooleanExpression.from_value_pairs(:name => 'id'),
99
- schema_migrations_column_name(table_name),
100
- false).as(:primary_key)).
101
- from(:pg_class).
102
- join(:pg_attribute, :attrelid=>:oid).
103
- join(:pg_type, :oid=>:atttypid).
104
- left_outer_join(:pg_type___basetype, :oid=>:typbasetype).
105
- left_outer_join(:pg_attrdef, :adrelid=>:pg_class__oid, :adnum=>:pg_attribute__attnum).
106
- left_outer_join(:pg_index, :indrelid=>:pg_class__oid, :indisprimary=>true).
107
- filter(:pg_attribute__attisdropped=>false).
108
- filter{|o| o.pg_attribute__attnum > 0}.
109
- filter(:pg_class__oid=>regclass_oid(table_name, opts)).
110
- order(:pg_attribute__attnum)
91
+ SQL::Cast.new(:pg_attribute__atttypid, :integer).as(:oid),
92
+ SQL::Cast.new(:basetype__oid, :integer).as(:base_oid),
93
+ SQL::Function.new(:format_type, :basetype__oid, :pg_type__typtypmod).as(:db_base_type),
94
+ SQL::Function.new(:format_type, :pg_type__oid, :pg_attribute__atttypmod).as(:db_type),
95
+ SQL::Function.new(:pg_get_expr, :pg_attrdef__adbin, :pg_class__oid).as(:default),
96
+ SQL::BooleanExpression.new(:NOT, :pg_attribute__attnotnull).as(:allow_null),
97
+ SQL::Function.new(:COALESCE, SQL::BooleanExpression.from_value_pairs(:pg_attribute__attnum => SQL::Function.new(:ANY,
98
+ SQL::Function.new(:string_to_array, SQL::Function.new(:textin, SQL::Function.new(:int2vectorout, :pg_index__indkey)), ' ')
99
+ )), false).as(:primary_key)).
100
+ from(:pg_class).
101
+ join(:pg_attribute, :attrelid=>:oid).
102
+ join(:pg_type, :oid=>:atttypid).
103
+ left_outer_join(:pg_type___basetype, :oid=>:typbasetype).
104
+ left_outer_join(:pg_attrdef, :adrelid=>:pg_class__oid, :adnum=>:pg_attribute__attnum).
105
+ left_outer_join(:pg_index, :indrelid=>:pg_class__oid, :indisprimary=>true).
106
+ filter(:pg_attribute__attisdropped=>false).
107
+ filter{|o| o.pg_attribute__attnum > 0}.
108
+ filter(:pg_class__oid=>regclass_oid(table_name, opts)).
109
+ order(:pg_attribute__attnum)
111
110
  ds.map do |row|
112
111
  row[:default] = nil if blank_object?(row[:default])
113
112
  if row[:base_oid]
@@ -126,10 +125,6 @@ module Sequel
126
125
  [m.call(row.delete(:name)), row]
127
126
  end
128
127
  end
129
-
130
- def schema_migrations_column_name(table_name)
131
- #SQL::BooleanExpression.from_value_pairs(:name => 'filename') if table_name == :schema_migrations
132
- end
133
128
  end
134
129
 
135
130
  class Dataset < Postgres::Dataset
@@ -2,12 +2,17 @@ require 'sequel/extensions/schema_dumper'
2
2
  module Sequel
3
3
  module SchemaDumper
4
4
  alias_method :dump_table_schema_without_force, :dump_table_schema
5
+ alias_method :dump_schema_migration_original, :dump_schema_migration
5
6
  alias_method :column_schema_to_ruby_type_without_uuid, :column_schema_to_ruby_type
6
7
 
7
8
  def dump_table_schema(table, opts=OPTS)
8
9
  dump_table_schema_without_force(table, opts).gsub('create_table(', 'create_table!(')
9
10
  end
10
11
 
12
+ def dump_schema_migration(options=OPTS)
13
+ dump_schema_migration_original(options).to_s.gsub(/^\s+$/, '')
14
+ end
15
+
11
16
  def column_schema_to_ruby_type(schema)
12
17
  case schema[:db_type].downcase
13
18
  when 'uuid'
@@ -71,7 +71,7 @@ namespace :redshift do
71
71
  desc 'Rollback the latest applied migration for Redshift'
72
72
  task :rollback do
73
73
  Blueshift::Migration.rollback!(:redshift)
74
- Rake::Task['pg:schema:dump'].invoke
74
+ Rake::Task['redshift:schema:dump'].invoke
75
75
  end
76
76
  end
77
77
 
@@ -81,4 +81,3 @@ namespace :blueshift do
81
81
  puts 'Running migrations for Postgres and Redshift...', ''
82
82
  end
83
83
  end
84
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue-shift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Mansour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.6
148
+ rubygems_version: 2.5.1
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Amazon Redshift adapter for Sequel