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 +4 -4
- data/lib/blueshift/version.rb +1 -1
- data/lib/sequel/adapters/redshift.rb +19 -24
- data/lib/sequel/extensions/schema_dumper_ext.rb +5 -0
- data/lib/tasks/schema.rake +1 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9ff2aa70afe9aae6299cd15f51a8afb60862184
|
4
|
+
data.tar.gz: a275f2007b457f80140668ca19917739c6e4270c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f4473e6459b7b5fbfd8a6f1a9a7d12b4de70671cf6cc92e3d75a3301d4fa8361d48cb89d6a7115d3fc949d3e80f51dbab97488fc2b23f10bc74f1f358854be9
|
7
|
+
data.tar.gz: 41d9dccc4493a44f10bbf4625c5dd83491834f045b45951d4e63593fd8db269600ade1ac869b4c8a2b154ac0ab8a97e26fabb0d7a95e594ac8429b251bb65007
|
data/lib/blueshift/version.rb
CHANGED
@@ -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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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'
|
data/lib/tasks/schema.rake
CHANGED
@@ -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['
|
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.
|
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:
|
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.
|
148
|
+
rubygems_version: 2.5.1
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Amazon Redshift adapter for Sequel
|