blue-shift 0.0.2 → 0.0.3
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 +4 -3
- data/lib/tasks/schema.rake +11 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbdb82fbebfd1c8a3535c8b23e454236334fc174
|
4
|
+
data.tar.gz: d7f4925e8a96b773d4cf47a6adedd452d86fddf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ff31243b99c2af428ce80d54a6e5dfdcc9528b68b1b22ebad70f5f6b24a1605ffed4342041ddbf1717c71d0d6834cfde7559d03272e381ba1bd9486594d7200
|
7
|
+
data.tar.gz: 7d476d66ab8af83aa0e5961d17c2a5e6fb525d5a38bec5ff4760aee41dcc996b5b354914ce6b608781ca4e0a24d9e3f5c71a1087c9a95cd34e8d195642e5433c
|
data/lib/blueshift/version.rb
CHANGED
@@ -18,6 +18,10 @@ module Sequel
|
|
18
18
|
[]
|
19
19
|
end
|
20
20
|
|
21
|
+
def supports_index_parsing?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
21
25
|
private
|
22
26
|
|
23
27
|
def create_table_sql(name, generator, options)
|
@@ -98,9 +102,6 @@ module Sequel
|
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
|
-
# OVERRIDE since indexes are not enforced by Redshift
|
102
|
-
def indexes(table, opts=OPTS)
|
103
|
-
end
|
104
105
|
end
|
105
106
|
|
106
107
|
class Dataset < Postgres::Dataset
|
data/lib/tasks/schema.rake
CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'blueshift'
|
5
5
|
|
6
6
|
path = File.join(Dir.pwd, 'db')
|
7
|
+
logger = Logger.new(STDOUT)
|
7
8
|
|
8
9
|
task :ensure_db_dir do
|
9
10
|
FileUtils.mkdir_p(path)
|
@@ -13,13 +14,16 @@ namespace :pg do
|
|
13
14
|
namespace :schema do
|
14
15
|
desc 'Dumps the Postgres schema to a file'
|
15
16
|
task :dump => :ensure_db_dir do
|
17
|
+
Blueshift::POSTGRES_DB.logger = logger
|
16
18
|
Blueshift::POSTGRES_DB.extension :redshift_schema_dumper
|
17
19
|
File.open(File.join(path, 'schema.rb'), 'w') { |f| f << Blueshift::POSTGRES_DB.dump_schema_migration(same_db: true) }
|
18
20
|
end
|
19
21
|
|
20
22
|
desc 'Loads the Postgres schema from the file to the database'
|
21
23
|
task :load => :ensure_db_dir do
|
22
|
-
|
24
|
+
Blueshift::POSTGRES_DB.logger = logger
|
25
|
+
eval(File.read(File.join(path, 'schema.rb'))).apply(Blueshift::POSTGRES_DB, :up)
|
26
|
+
puts 'loaded schema into Postgres'
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -29,13 +33,16 @@ namespace :redshift do
|
|
29
33
|
namespace :schema do
|
30
34
|
desc 'Dumps the Postgres schema to a file'
|
31
35
|
task :dump => :ensure_db_dir do
|
36
|
+
Blueshift::REDSHIFT_DB.logger = logger
|
32
37
|
Blueshift::REDSHIFT_DB.extension :redshift_schema_dumper
|
33
38
|
File.open(File.join(path, 'schema_redshift.rb'), 'w') { |f| f << Blueshift::REDSHIFT_DB.dump_schema_migration(same_db: true) }
|
34
39
|
end
|
35
40
|
|
36
41
|
desc 'Loads the Postgres schema from the file to the database'
|
37
42
|
task :load => :ensure_db_dir do
|
38
|
-
|
43
|
+
Blueshift::REDSHIFT_DB.logger = logger
|
44
|
+
eval(File.read(File.join(path, 'schema_redshift.rb'))).apply(Blueshift::REDSHIFT_DB, :up)
|
45
|
+
puts 'loaded schema into Redshift'
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -44,6 +51,8 @@ namespace :blueshift do
|
|
44
51
|
desc 'Runs migrations for both Postgres and Redshift'
|
45
52
|
task :migrate do
|
46
53
|
puts 'Running migrations for Postgres and Redshift...', ''
|
54
|
+
Blueshift::POSTGRES_DB.logger = logger
|
55
|
+
Blueshift::REDSHIFT_DB.logger = logger
|
47
56
|
Blueshift::Migration.run!
|
48
57
|
end
|
49
58
|
end
|