postshift 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +28 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1156 -0
- data/Appraisals +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +54 -0
- data/README.md +111 -0
- data/Rakefile +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +9 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/ar_5.0.gemfile +8 -0
- data/gemfiles/ar_5.0.gemfile.lock +70 -0
- data/gemfiles/ar_5.1.gemfile +8 -0
- data/gemfiles/ar_5.1.gemfile.lock +70 -0
- data/lib/active_record/connection_adapters/redshift/column.rb +7 -0
- data/lib/active_record/connection_adapters/redshift/referential_integrity.rb +11 -0
- data/lib/active_record/connection_adapters/redshift/schema_definitions.rb +43 -0
- data/lib/active_record/connection_adapters/redshift/schema_dumper.rb +25 -0
- data/lib/active_record/connection_adapters/redshift/schema_statements.rb +154 -0
- data/lib/active_record/connection_adapters/redshift/type_metadata.rb +18 -0
- data/lib/active_record/connection_adapters/redshift_adapter.rb +220 -0
- data/lib/postshift.rb +5 -0
- data/lib/postshift/version.rb +3 -0
- data/postshift.gemspec +37 -0
- metadata +199 -0
data/Appraisals
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at david.krupinski@valimail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
-----------------------------------------------------------------------------------
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2004-2013 David Heinemeier Hansson (original code author)
|
5
|
+
Copyright (c) 2013 Minero Aoki
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
8
|
+
this software and associated documentation files (the "Software"), to deal in
|
9
|
+
the Software without restriction, including without limitation the rights to
|
10
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
11
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
12
|
+
subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
19
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
20
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
21
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
22
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
-----------------------------------------------------------------------------------
|
25
|
+
Copyright (c) 2010-2013, Fiksu, Inc.
|
26
|
+
All rights reserved.
|
27
|
+
|
28
|
+
Redistribution and use in source and binary forms, with or without
|
29
|
+
modification, are permitted provided that the following conditions are
|
30
|
+
met:
|
31
|
+
|
32
|
+
o Redistributions of source code must retain the above copyright
|
33
|
+
notice, this list of conditions and the following disclaimer.
|
34
|
+
|
35
|
+
o Redistributions in binary form must reproduce the above copyright
|
36
|
+
notice, this list of conditions and the following disclaimer in the
|
37
|
+
documentation and/or other materials provided with the
|
38
|
+
distribution.
|
39
|
+
|
40
|
+
o Fiksu, Inc. nor the names of its contributors may be used to
|
41
|
+
endorse or promote products derived from this software without
|
42
|
+
specific prior written permission.
|
43
|
+
|
44
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
45
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
46
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
47
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
48
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
50
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
51
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
52
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
53
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
54
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# Postshift
|
2
|
+
|
3
|
+
Amazon Redshift extension for ActiveRecord 5 (Rails 5) PostgreSQL adapter based off of the existing activerecord5-redshift-adapter. This version has 3 primary goals:
|
4
|
+
|
5
|
+
1. Function as an extension of the PostgreSQL ActiveRecord adapter. Overriding or extending as needed to properly account for the differences between PostgreSQL and Redshift.
|
6
|
+
2. Create a functioning test suite.
|
7
|
+
3. Operate within both ActiveRecord 5 and 5.1.
|
8
|
+
|
9
|
+
<https://github.com/ConsultingMD/activerecord5-redshift-adapter>
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'postshift'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install postshift
|
26
|
+
|
27
|
+
In your Rails 5+ database.yml
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
development:
|
31
|
+
adapter: redshift
|
32
|
+
host: your_cluster_name.at.redshift.amazonaws.com
|
33
|
+
port: 5439
|
34
|
+
database: your_db
|
35
|
+
username: your_user
|
36
|
+
password: your_password
|
37
|
+
encoding: utf8
|
38
|
+
pool: 3
|
39
|
+
timeout: 5000
|
40
|
+
```
|
41
|
+
|
42
|
+
## Migrations
|
43
|
+
|
44
|
+
Postshift exposes Redshift table and column options within ActiveRecord migrations.
|
45
|
+
|
46
|
+
**DISTKEY & SORTKEY Table Configuration**
|
47
|
+
|
48
|
+
The DISTKEY and SORTKEY can be passed through the create_table syntax:
|
49
|
+
|
50
|
+
```
|
51
|
+
create_table 'example_table', distkey: 'name', sortkey: 'number' do |t|
|
52
|
+
t.string :name
|
53
|
+
t.integer :number
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
**Column Compression Encoding**
|
58
|
+
|
59
|
+
Redshift column compression encoding can be specified inline as an option within migrations:
|
60
|
+
|
61
|
+
```
|
62
|
+
create_table 'encoding_examples' do |t|
|
63
|
+
t.integer :number, encoding: 'delta'
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
For more information on compression types:
|
68
|
+
<http://docs.aws.amazon.com/redshift/latest/dg/c_Compression_encodings.html>
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
|
+
|
76
|
+
## Testing
|
77
|
+
|
78
|
+
To run the full test suite, a functioning Redshift database instance is required. Once provisioned, copy the example configuration and update with your connection information & run the spec migrations:
|
79
|
+
|
80
|
+
cp spec/config.example.yml spec/config.yml
|
81
|
+
|
82
|
+
rake spec:db:migrate
|
83
|
+
|
84
|
+
And finally, you can now run the entire test suite:
|
85
|
+
|
86
|
+
rake spec
|
87
|
+
|
88
|
+
The spec structure is based on reliance of an available running Redshift instance. These specs can be run separately:
|
89
|
+
|
90
|
+
```
|
91
|
+
rake spec:isolated # Run isolated non-Redshift reliant code examples
|
92
|
+
rake spec:redshift # Run Redshift reliant code examples
|
93
|
+
```
|
94
|
+
|
95
|
+
Additionally, there is multi-version test support through [Appraisal](https://github.com/thoughtbot/appraisal).
|
96
|
+
|
97
|
+
```
|
98
|
+
appraisal install
|
99
|
+
appraisal ar-5.0 rake spec
|
100
|
+
appraisal ar-5.1 rake spec
|
101
|
+
```
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ValiMail/postshift. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
106
|
+
|
107
|
+
|
108
|
+
## License
|
109
|
+
|
110
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
111
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'active_record'
|
4
|
+
require_relative 'spec/support/config'
|
5
|
+
require_relative 'spec/support/connection'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
task default: :spec
|
10
|
+
|
11
|
+
namespace :spec do
|
12
|
+
include ActiveRecord::Tasks
|
13
|
+
|
14
|
+
desc 'Run isolated non-Redshift reliant code examples'
|
15
|
+
RSpec::Core::RakeTask.new(:isolated) do |t|
|
16
|
+
t.pattern = 'spec/lib/**/*_spec.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run Redshift reliant code examples'
|
20
|
+
RSpec::Core::RakeTask.new(:redshift) do |t|
|
21
|
+
t.pattern = 'spec/redshift/**/*_spec.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
task :environment do
|
25
|
+
ARTest.connect
|
26
|
+
# DatabaseTasks.current_config = ARTest.config
|
27
|
+
DatabaseTasks.database_configuration = ARTest.config
|
28
|
+
DatabaseTasks.db_dir = File.expand_path('../spec/db', __FILE__)
|
29
|
+
DatabaseTasks.env = 'test'
|
30
|
+
DatabaseTasks.migrations_paths = File.join(DatabaseTasks.db_dir, 'migrate')
|
31
|
+
end
|
32
|
+
|
33
|
+
load 'active_record/railties/databases.rake'
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "postshift"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
postshift (0.1.0)
|
5
|
+
activerecord (>= 5.0)
|
6
|
+
activesupport (>= 5.0)
|
7
|
+
pg (~> 0.20.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (5.0.2)
|
13
|
+
activesupport (= 5.0.2)
|
14
|
+
activerecord (5.0.2)
|
15
|
+
activemodel (= 5.0.2)
|
16
|
+
activesupport (= 5.0.2)
|
17
|
+
arel (~> 7.0)
|
18
|
+
activesupport (5.0.2)
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
i18n (~> 0.7)
|
21
|
+
minitest (~> 5.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
appraisal (2.2.0)
|
24
|
+
bundler
|
25
|
+
rake
|
26
|
+
thor (>= 0.14.0)
|
27
|
+
arel (7.1.4)
|
28
|
+
concurrent-ruby (1.0.5)
|
29
|
+
database_cleaner (1.6.1)
|
30
|
+
diff-lcs (1.3)
|
31
|
+
factory_girl (4.8.0)
|
32
|
+
activesupport (>= 3.0.0)
|
33
|
+
i18n (0.8.1)
|
34
|
+
minitest (5.10.2)
|
35
|
+
pg (0.20.0)
|
36
|
+
rake (10.5.0)
|
37
|
+
rspec (3.6.0)
|
38
|
+
rspec-core (~> 3.6.0)
|
39
|
+
rspec-expectations (~> 3.6.0)
|
40
|
+
rspec-mocks (~> 3.6.0)
|
41
|
+
rspec-core (3.6.0)
|
42
|
+
rspec-support (~> 3.6.0)
|
43
|
+
rspec-expectations (3.6.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.6.0)
|
46
|
+
rspec-mocks (3.6.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.6.0)
|
49
|
+
rspec-support (3.6.0)
|
50
|
+
thor (0.19.4)
|
51
|
+
thread_safe (0.3.6)
|
52
|
+
tzinfo (1.2.3)
|
53
|
+
thread_safe (~> 0.1)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
activerecord (= 5.0.2)
|
60
|
+
activesupport (= 5.0.2)
|
61
|
+
appraisal (~> 2.2.0)
|
62
|
+
bundler (~> 1.14)
|
63
|
+
database_cleaner (~> 1.6.0)
|
64
|
+
factory_girl (~> 4.8.0)
|
65
|
+
postshift!
|
66
|
+
rake (~> 10.0)
|
67
|
+
rspec (~> 3.0)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.14.6
|
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
postshift (0.1.0)
|
5
|
+
activerecord (>= 5.0)
|
6
|
+
activesupport (>= 5.0)
|
7
|
+
pg (~> 0.20.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (5.1.0)
|
13
|
+
activesupport (= 5.1.0)
|
14
|
+
activerecord (5.1.0)
|
15
|
+
activemodel (= 5.1.0)
|
16
|
+
activesupport (= 5.1.0)
|
17
|
+
arel (~> 8.0)
|
18
|
+
activesupport (5.1.0)
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
i18n (~> 0.7)
|
21
|
+
minitest (~> 5.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
appraisal (2.2.0)
|
24
|
+
bundler
|
25
|
+
rake
|
26
|
+
thor (>= 0.14.0)
|
27
|
+
arel (8.0.0)
|
28
|
+
concurrent-ruby (1.0.5)
|
29
|
+
database_cleaner (1.6.1)
|
30
|
+
diff-lcs (1.3)
|
31
|
+
factory_girl (4.8.0)
|
32
|
+
activesupport (>= 3.0.0)
|
33
|
+
i18n (0.8.1)
|
34
|
+
minitest (5.10.2)
|
35
|
+
pg (0.20.0)
|
36
|
+
rake (10.5.0)
|
37
|
+
rspec (3.6.0)
|
38
|
+
rspec-core (~> 3.6.0)
|
39
|
+
rspec-expectations (~> 3.6.0)
|
40
|
+
rspec-mocks (~> 3.6.0)
|
41
|
+
rspec-core (3.6.0)
|
42
|
+
rspec-support (~> 3.6.0)
|
43
|
+
rspec-expectations (3.6.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.6.0)
|
46
|
+
rspec-mocks (3.6.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.6.0)
|
49
|
+
rspec-support (3.6.0)
|
50
|
+
thor (0.19.4)
|
51
|
+
thread_safe (0.3.6)
|
52
|
+
tzinfo (1.2.3)
|
53
|
+
thread_safe (~> 0.1)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
activerecord (= 5.1.0)
|
60
|
+
activesupport (= 5.1.0)
|
61
|
+
appraisal (~> 2.2.0)
|
62
|
+
bundler (~> 1.14)
|
63
|
+
database_cleaner (~> 1.6.0)
|
64
|
+
factory_girl (~> 4.8.0)
|
65
|
+
postshift!
|
66
|
+
rake (~> 10.0)
|
67
|
+
rspec (~> 3.0)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.14.6
|