activerecord-pg_enum 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +95 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +20 -0
- data/README.md +10 -2
- data/Rakefile +0 -3
- data/gemfiles/4.1.gemfile.lock +5 -5
- data/gemfiles/4.2.gemfile.lock +11 -11
- data/gemfiles/5.0.gemfile.lock +11 -11
- data/gemfiles/5.1.gemfile.lock +12 -12
- data/gemfiles/5.2.gemfile.lock +12 -12
- data/gemfiles/6.0.gemfile +1 -1
- data/gemfiles/6.0.gemfile.lock +3 -3
- data/gemfiles/6.1.gemfile.lock +1 -1
- data/gemfiles/7.0.gemfile +7 -0
- data/gemfiles/7.0.gemfile.lock +68 -0
- data/gemfiles/edge.gemfile.lock +1 -1
- data/lib/active_record/pg_enum/4.1/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/4.1/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/4.2/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/4.2/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/5.0/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/5.0/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/5.1/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/5.1/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/5.2/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/5.2/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/6.0/create_enum.rb +1 -0
- data/lib/active_record/pg_enum/6.0/postgresql_adapter.rb +1 -0
- data/lib/active_record/pg_enum/6.0/table_definition.rb +17 -0
- data/lib/active_record/pg_enum/6.1/create_enum.rb +21 -0
- data/lib/active_record/pg_enum/{postgresql_adapter.rb → 6.1/postgresql_adapter.rb} +1 -1
- data/lib/active_record/pg_enum/6.1/table_definition.rb +1 -1
- data/lib/active_record/pg_enum/schema_statements.rb +1 -12
- data/lib/active_record/pg_enum/version.rb +1 -1
- data/lib/active_record/pg_enum.rb +2 -3
- metadata +20 -5
- data/.travis.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e90a1c4526f10cabb98bec7d1800ac564c00ade2847cca560ee9ecbb3b471ffb
|
4
|
+
data.tar.gz: a4741cc472ad80350fc69f13ab846b1e5cecaa4484ae353b0d9cbc6af8da041b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83969dc1fdba6d8f1e0ca382ee34564797ae20d2c941ab98900d0a9574977994fae4b6f465a1e8966ebaf3058680df3c3f66f37a8bae0f86053a2423f7b29524
|
7
|
+
data.tar.gz: 5c21046467a8adcbcba29b90090e8b5472a3c8e337250782ea2b68b0c76e5600ea5bf33bb89a4f4f44b220ea538051ed116228422e33968c1ff60951e2a997bf
|
@@ -0,0 +1,95 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
parameters:
|
6
|
+
image:
|
7
|
+
type: string
|
8
|
+
gemfile:
|
9
|
+
type: string
|
10
|
+
docker:
|
11
|
+
- image: '<< parameters.image >>'
|
12
|
+
auth:
|
13
|
+
username: alassek
|
14
|
+
password: $DOCKERHUB_TOKEN
|
15
|
+
- image: circleci/postgres:10
|
16
|
+
auth:
|
17
|
+
username: alassek
|
18
|
+
password: $DOCKERHUB_TOKEN
|
19
|
+
environment:
|
20
|
+
POSTGRES_USER: postgres
|
21
|
+
POSTGRES_PASSWORD: ""
|
22
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
23
|
+
environment:
|
24
|
+
BUNDLER_VERSION: "1.17.3"
|
25
|
+
BUNDLE_GEMFILE: '<< parameters.gemfile >>'
|
26
|
+
BUNDLE_JOBS: "3"
|
27
|
+
BUNDLE_RETRY: "3"
|
28
|
+
PGHOST: 127.0.0.1
|
29
|
+
PGUSER: postgres
|
30
|
+
PGPASSWORD: ""
|
31
|
+
TEST_USER: postgres
|
32
|
+
steps:
|
33
|
+
- checkout
|
34
|
+
- run:
|
35
|
+
name: Generate checksums
|
36
|
+
command: |
|
37
|
+
mkdir -p tmp
|
38
|
+
shasum gemfiles/*.lock > tmp/checksum.txt
|
39
|
+
- restore_cache:
|
40
|
+
key: v1-gem-cache-{{ checksum "tmp/checksum.txt" }}
|
41
|
+
- run:
|
42
|
+
name: Install Dependencies
|
43
|
+
command: |
|
44
|
+
gem install bundler:$BUNDLER_VERSION
|
45
|
+
bundle check --path ./vendor/bundle || bundle install --deployment
|
46
|
+
- run:
|
47
|
+
name: Wait for DB
|
48
|
+
command: dockerize -wait tcp://localhost:5432 -timeout 1m
|
49
|
+
- run:
|
50
|
+
name: Run RSpec Tests
|
51
|
+
command: bundle exec rake spec
|
52
|
+
|
53
|
+
workflows:
|
54
|
+
rails_4_1:
|
55
|
+
jobs:
|
56
|
+
- test:
|
57
|
+
name: Rails 4.1
|
58
|
+
image: 'circleci/ruby:2.2.6'
|
59
|
+
gemfile: 'gemfiles/4.1.gemfile'
|
60
|
+
rails_4_2:
|
61
|
+
jobs:
|
62
|
+
- test:
|
63
|
+
name: Rails 4.2
|
64
|
+
image: 'circleci/ruby:2.2.10'
|
65
|
+
gemfile: 'gemfiles/4.2.gemfile'
|
66
|
+
rails_5_0:
|
67
|
+
jobs:
|
68
|
+
- test:
|
69
|
+
name: Rails 5.0
|
70
|
+
image: 'circleci/ruby:2.3.8'
|
71
|
+
gemfile: 'gemfiles/5.0.gemfile'
|
72
|
+
rails_5_1:
|
73
|
+
jobs:
|
74
|
+
- test:
|
75
|
+
name: Rails 5.1
|
76
|
+
image: 'circleci/ruby:2.4.4'
|
77
|
+
gemfile: 'gemfiles/5.1.gemfile'
|
78
|
+
rails_6_0:
|
79
|
+
jobs:
|
80
|
+
- test:
|
81
|
+
name: Rails 6.0
|
82
|
+
image: 'circleci/ruby:2.6.0'
|
83
|
+
gemfile: 'gemfiles/6.0.gemfile'
|
84
|
+
rails_6_1:
|
85
|
+
jobs:
|
86
|
+
- test:
|
87
|
+
name: Rails 6.1
|
88
|
+
image: 'circleci/ruby:3.0.1'
|
89
|
+
gemfile: 'gemfiles/6.1.gemfile'
|
90
|
+
rails_7_0:
|
91
|
+
jobs:
|
92
|
+
- test:
|
93
|
+
name: Rails 7.0
|
94
|
+
image: 'cimg/ruby:2.7.6'
|
95
|
+
gemfile: 'gemfiles/7.0.gemfile'
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.0.0] - 2022-07-17
|
10
|
+
### Added
|
11
|
+
- Support for 7.0
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- ActiveRecord added `enum_types` interface so monkeypatch has been removed. **Note:** output format has changed.
|
15
|
+
- `create_enum` uses framework interface, replacing `:as` kwarg with `:enum_type`
|
16
|
+
|
17
|
+
## [1.2.2] - 2021-01-07
|
18
|
+
### Fixed
|
19
|
+
- Don't mutate `Gem::Version#canonical_segments` (@agrobbin)
|
20
|
+
|
21
|
+
## [1.2.1] - 2021-01-05
|
22
|
+
### Fixed
|
23
|
+
- Argument bug that surfaced in Ruby 3.0
|
24
|
+
|
25
|
+
## [1.2.0] - 2020-12-09
|
26
|
+
### Added
|
27
|
+
- Support for 6.1
|
28
|
+
|
9
29
|
## [1.1.0] - 2020-01-18
|
10
30
|
### Added
|
11
31
|
- `rename_enum` command for changing the type name
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# ActiveRecord::PGEnum [](https://app.circleci.com/pipelines/github/alassek/activerecord-pg_enum)
|
2
|
+
|
3
|
+
**Note**: This was originally written before Rails added support for native enums. See the comments in [version
|
4
|
+
support](#version-support).
|
2
5
|
|
3
6
|
The `enum` feature in Rails has bad developer ergonomics. It uses integer types at the DB layer, which means trying to understand SQL output is a pain.
|
4
7
|
|
@@ -61,6 +64,9 @@ The monkeypatches in this library are extremely narrow and contained; the dirty
|
|
61
64
|
|
62
65
|
Monkeypatching Rails internals is **scary**. So this library has a comprehensive test suite that runs against every known minor version.
|
63
66
|
|
67
|
+
Rails 7 added support for native enums, but they have so far neglected to support altering or dropping enums in the API,
|
68
|
+
so this gem remains to fill in the gaps. I expect to slowly deprecate this over time.
|
69
|
+
|
64
70
|
## Installation
|
65
71
|
|
66
72
|
Add this line to your application's Gemfile:
|
@@ -91,10 +97,12 @@ class AddContactMethodType < ActiveRecord::Migration[5.2]
|
|
91
97
|
end
|
92
98
|
```
|
93
99
|
|
94
|
-
Adding a value to an existing ENUM
|
100
|
+
Adding a value to an existing ENUM (you must disable the wrapping transaction on PostgreSQL versions older than 12)
|
95
101
|
|
96
102
|
```ruby
|
97
103
|
class AddSMSToContactMethodType < ActiveRecord::Migration[5.2]
|
104
|
+
disable_ddl_transaction!
|
105
|
+
|
98
106
|
def up
|
99
107
|
add_enum_value "contact_method_type", "SMS", before: "Phone"
|
100
108
|
end
|
data/Rakefile
CHANGED
data/gemfiles/4.1.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -27,15 +27,15 @@ GEM
|
|
27
27
|
rake
|
28
28
|
thor (>= 0.14.0)
|
29
29
|
arel (5.0.1.20140414130214)
|
30
|
-
builder (3.2.
|
30
|
+
builder (3.2.4)
|
31
31
|
coderay (1.1.2)
|
32
|
-
concurrent-ruby (1.1.
|
32
|
+
concurrent-ruby (1.1.7)
|
33
33
|
diff-lcs (1.3)
|
34
34
|
i18n (0.9.5)
|
35
35
|
concurrent-ruby (~> 1.0)
|
36
36
|
json (1.8.6)
|
37
37
|
method_source (0.9.2)
|
38
|
-
minitest (5.
|
38
|
+
minitest (5.14.2)
|
39
39
|
pg (0.21.0)
|
40
40
|
pry (0.12.2)
|
41
41
|
coderay (~> 1.1.0)
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
rspec-support (3.8.2)
|
57
57
|
thor (0.20.3)
|
58
58
|
thread_safe (0.3.6)
|
59
|
-
tzinfo (1.2.
|
59
|
+
tzinfo (1.2.8)
|
60
60
|
thread_safe (~> 0.1)
|
61
61
|
|
62
62
|
PLATFORMS
|
data/gemfiles/4.2.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -9,14 +9,14 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (4.2.11.
|
13
|
-
activesupport (= 4.2.11.
|
12
|
+
activemodel (4.2.11.3)
|
13
|
+
activesupport (= 4.2.11.3)
|
14
14
|
builder (~> 3.1)
|
15
|
-
activerecord (4.2.11.
|
16
|
-
activemodel (= 4.2.11.
|
17
|
-
activesupport (= 4.2.11.
|
15
|
+
activerecord (4.2.11.3)
|
16
|
+
activemodel (= 4.2.11.3)
|
17
|
+
activesupport (= 4.2.11.3)
|
18
18
|
arel (~> 6.0)
|
19
|
-
activesupport (4.2.11.
|
19
|
+
activesupport (4.2.11.3)
|
20
20
|
i18n (~> 0.7)
|
21
21
|
minitest (~> 5.1)
|
22
22
|
thread_safe (~> 0.3, >= 0.3.4)
|
@@ -26,14 +26,14 @@ GEM
|
|
26
26
|
rake
|
27
27
|
thor (>= 0.14.0)
|
28
28
|
arel (6.0.4)
|
29
|
-
builder (3.2.
|
29
|
+
builder (3.2.4)
|
30
30
|
coderay (1.1.2)
|
31
|
-
concurrent-ruby (1.1.
|
31
|
+
concurrent-ruby (1.1.7)
|
32
32
|
diff-lcs (1.3)
|
33
33
|
i18n (0.9.5)
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
35
|
method_source (0.9.2)
|
36
|
-
minitest (5.
|
36
|
+
minitest (5.14.2)
|
37
37
|
pg (0.21.0)
|
38
38
|
pry (0.12.2)
|
39
39
|
coderay (~> 1.1.0)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
rspec-support (3.8.2)
|
55
55
|
thor (0.20.3)
|
56
56
|
thread_safe (0.3.6)
|
57
|
-
tzinfo (1.2.
|
57
|
+
tzinfo (1.2.8)
|
58
58
|
thread_safe (~> 0.1)
|
59
59
|
|
60
60
|
PLATFORMS
|
data/gemfiles/5.0.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -9,13 +9,13 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (5.0.7.
|
13
|
-
activesupport (= 5.0.7.
|
14
|
-
activerecord (5.0.7.
|
15
|
-
activemodel (= 5.0.7.
|
16
|
-
activesupport (= 5.0.7.
|
12
|
+
activemodel (5.0.7.2)
|
13
|
+
activesupport (= 5.0.7.2)
|
14
|
+
activerecord (5.0.7.2)
|
15
|
+
activemodel (= 5.0.7.2)
|
16
|
+
activesupport (= 5.0.7.2)
|
17
17
|
arel (~> 7.0)
|
18
|
-
activesupport (5.0.7.
|
18
|
+
activesupport (5.0.7.2)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 0.7, < 2)
|
21
21
|
minitest (~> 5.1)
|
@@ -26,13 +26,13 @@ GEM
|
|
26
26
|
thor (>= 0.14.0)
|
27
27
|
arel (7.1.4)
|
28
28
|
coderay (1.1.2)
|
29
|
-
concurrent-ruby (1.1.
|
29
|
+
concurrent-ruby (1.1.7)
|
30
30
|
diff-lcs (1.3)
|
31
31
|
i18n (1.5.1)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
method_source (0.9.2)
|
34
|
-
minitest (5.
|
35
|
-
pg (1.2.
|
34
|
+
minitest (5.14.2)
|
35
|
+
pg (1.2.3)
|
36
36
|
pry (0.12.2)
|
37
37
|
coderay (~> 1.1.0)
|
38
38
|
method_source (~> 0.9.0)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
rspec-support (3.8.0)
|
53
53
|
thor (0.20.3)
|
54
54
|
thread_safe (0.3.6)
|
55
|
-
tzinfo (1.2.
|
55
|
+
tzinfo (1.2.8)
|
56
56
|
thread_safe (~> 0.1)
|
57
57
|
|
58
58
|
PLATFORMS
|
data/gemfiles/5.1.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -9,13 +9,13 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (5.1.
|
13
|
-
activesupport (= 5.1.
|
14
|
-
activerecord (5.1.
|
15
|
-
activemodel (= 5.1.
|
16
|
-
activesupport (= 5.1.
|
12
|
+
activemodel (5.1.7)
|
13
|
+
activesupport (= 5.1.7)
|
14
|
+
activerecord (5.1.7)
|
15
|
+
activemodel (= 5.1.7)
|
16
|
+
activesupport (= 5.1.7)
|
17
17
|
arel (~> 8.0)
|
18
|
-
activesupport (5.1.
|
18
|
+
activesupport (5.1.7)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 0.7, < 2)
|
21
21
|
minitest (~> 5.1)
|
@@ -26,13 +26,13 @@ GEM
|
|
26
26
|
thor (>= 0.14.0)
|
27
27
|
arel (8.0.0)
|
28
28
|
coderay (1.1.2)
|
29
|
-
concurrent-ruby (1.
|
29
|
+
concurrent-ruby (1.1.7)
|
30
30
|
diff-lcs (1.3)
|
31
|
-
i18n (1.
|
31
|
+
i18n (1.8.5)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
method_source (0.9.0)
|
34
|
-
minitest (5.
|
35
|
-
pg (1.2.
|
34
|
+
minitest (5.14.2)
|
35
|
+
pg (1.2.3)
|
36
36
|
pry (0.11.3)
|
37
37
|
coderay (~> 1.1.0)
|
38
38
|
method_source (~> 0.9.0)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
rspec-support (3.8.0)
|
53
53
|
thor (0.20.0)
|
54
54
|
thread_safe (0.3.6)
|
55
|
-
tzinfo (1.2.
|
55
|
+
tzinfo (1.2.8)
|
56
56
|
thread_safe (~> 0.1)
|
57
57
|
|
58
58
|
PLATFORMS
|
data/gemfiles/5.2.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -9,13 +9,13 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (5.2.
|
13
|
-
activesupport (= 5.2.
|
14
|
-
activerecord (5.2.
|
15
|
-
activemodel (= 5.2.
|
16
|
-
activesupport (= 5.2.
|
12
|
+
activemodel (5.2.4.4)
|
13
|
+
activesupport (= 5.2.4.4)
|
14
|
+
activerecord (5.2.4.4)
|
15
|
+
activemodel (= 5.2.4.4)
|
16
|
+
activesupport (= 5.2.4.4)
|
17
17
|
arel (>= 9.0)
|
18
|
-
activesupport (5.2.
|
18
|
+
activesupport (5.2.4.4)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 0.7, < 2)
|
21
21
|
minitest (~> 5.1)
|
@@ -26,13 +26,13 @@ GEM
|
|
26
26
|
thor (>= 0.14.0)
|
27
27
|
arel (9.0.0)
|
28
28
|
coderay (1.1.2)
|
29
|
-
concurrent-ruby (1.
|
29
|
+
concurrent-ruby (1.1.7)
|
30
30
|
diff-lcs (1.3)
|
31
|
-
i18n (1.
|
31
|
+
i18n (1.8.5)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
method_source (0.9.0)
|
34
|
-
minitest (5.
|
35
|
-
pg (1.2.
|
34
|
+
minitest (5.14.2)
|
35
|
+
pg (1.2.3)
|
36
36
|
pry (0.11.3)
|
37
37
|
coderay (~> 1.1.0)
|
38
38
|
method_source (~> 0.9.0)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
rspec-support (3.8.0)
|
53
53
|
thor (0.20.0)
|
54
54
|
thread_safe (0.3.6)
|
55
|
-
tzinfo (1.2.
|
55
|
+
tzinfo (1.2.8)
|
56
56
|
thread_safe (~> 0.1)
|
57
57
|
|
58
58
|
PLATFORMS
|
data/gemfiles/6.0.gemfile
CHANGED
data/gemfiles/6.0.gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
activerecord-pg_enum (1.
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
activesupport
|
7
7
|
pg
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
32
|
method_source (0.9.2)
|
33
33
|
minitest (5.14.2)
|
34
|
-
pg (1.2.
|
34
|
+
pg (1.2.3)
|
35
35
|
pry (0.12.2)
|
36
36
|
coderay (~> 1.1.0)
|
37
37
|
method_source (~> 0.9.0)
|
@@ -59,7 +59,7 @@ PLATFORMS
|
|
59
59
|
ruby
|
60
60
|
|
61
61
|
DEPENDENCIES
|
62
|
-
activerecord (
|
62
|
+
activerecord (~> 6.0)
|
63
63
|
activerecord-pg_enum!
|
64
64
|
appraisal
|
65
65
|
bundler (~> 1.17)
|
data/gemfiles/6.1.gemfile.lock
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
activerecord-pg_enum (1.2.2)
|
5
|
+
activerecord (>= 4.1.0)
|
6
|
+
activesupport
|
7
|
+
pg
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (7.0.3.1)
|
13
|
+
activesupport (= 7.0.3.1)
|
14
|
+
activerecord (7.0.3.1)
|
15
|
+
activemodel (= 7.0.3.1)
|
16
|
+
activesupport (= 7.0.3.1)
|
17
|
+
activesupport (7.0.3.1)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
|
+
appraisal (2.4.1)
|
23
|
+
bundler
|
24
|
+
rake
|
25
|
+
thor (>= 0.14.0)
|
26
|
+
coderay (1.1.3)
|
27
|
+
concurrent-ruby (1.1.10)
|
28
|
+
diff-lcs (1.5.0)
|
29
|
+
i18n (1.12.0)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
method_source (1.0.0)
|
32
|
+
minitest (5.16.2)
|
33
|
+
pg (1.4.1)
|
34
|
+
pry (0.14.1)
|
35
|
+
coderay (~> 1.1)
|
36
|
+
method_source (~> 1.0)
|
37
|
+
rake (10.5.0)
|
38
|
+
rspec (3.11.0)
|
39
|
+
rspec-core (~> 3.11.0)
|
40
|
+
rspec-expectations (~> 3.11.0)
|
41
|
+
rspec-mocks (~> 3.11.0)
|
42
|
+
rspec-core (3.11.0)
|
43
|
+
rspec-support (~> 3.11.0)
|
44
|
+
rspec-expectations (3.11.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-mocks (3.11.1)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.11.0)
|
50
|
+
rspec-support (3.11.0)
|
51
|
+
thor (1.2.1)
|
52
|
+
tzinfo (2.0.4)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
activerecord (~> 7.0)
|
60
|
+
activerecord-pg_enum!
|
61
|
+
appraisal
|
62
|
+
bundler (~> 1.17)
|
63
|
+
pry
|
64
|
+
rake (~> 10.0)
|
65
|
+
rspec (~> 3.0)
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
1.17.3
|
data/gemfiles/edge.gemfile.lock
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/create_enum"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.1/postgresql_adapter"
|
@@ -1 +1,18 @@
|
|
1
1
|
require "active_record/pg_enum/4.2/table_definition"
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module PGEnum
|
5
|
+
module TableDefinition
|
6
|
+
# Create an enum column inside a TableDefinition
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# create_table :orders do |t|
|
11
|
+
# t.enum :status, as: "status_type"
|
12
|
+
# end
|
13
|
+
def enum(name, as:, **options)
|
14
|
+
column(name, as, **options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module PGEnum
|
3
|
+
register :create_enum do
|
4
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
5
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include CreateEnum
|
6
|
+
end
|
7
|
+
|
8
|
+
module CreateEnum
|
9
|
+
# Create a new ENUM type, with an arbitrary number of values.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# create_enum("foo_type", "foo", "bar", "baz", "foo bar")
|
14
|
+
def create_enum(name, values)
|
15
|
+
execute("CREATE TYPE #{name} AS ENUM (#{Array(values).map { |v| "'#{v}'" }.join(", ")})").tap {
|
16
|
+
reload_type_map
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -2,7 +2,7 @@ module ActiveRecord
|
|
2
2
|
module PGEnum
|
3
3
|
register :postgresql_adapter do
|
4
4
|
require "active_record/connection_adapters/postgresql_adapter"
|
5
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include PostgreSQLAdapter
|
5
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include ::ActiveRecord::PGEnum::PostgreSQLAdapter
|
6
6
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.merge!(enum: { name: "enum" })
|
7
7
|
end
|
8
8
|
|
@@ -1 +1 @@
|
|
1
|
-
require "active_record/pg_enum/
|
1
|
+
require "active_record/pg_enum/6.0/table_definition"
|
@@ -1,22 +1,11 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module PGEnum
|
3
3
|
register :schema_statements do
|
4
|
-
require "active_record/connection_adapters/
|
4
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
5
5
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include SchemaStatements
|
6
6
|
end
|
7
7
|
|
8
8
|
module SchemaStatements
|
9
|
-
# Create a new ENUM type, with an arbitrary number of values.
|
10
|
-
#
|
11
|
-
# Example:
|
12
|
-
#
|
13
|
-
# create_enum("foo_type", "foo", "bar", "baz", "foo bar")
|
14
|
-
def create_enum(name, values)
|
15
|
-
execute("CREATE TYPE #{name} AS ENUM (#{Array(values).map { |v| "'#{v}'" }.join(", ")})").tap {
|
16
|
-
reload_type_map
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
9
|
# Drop an ENUM type from the database.
|
21
10
|
def drop_enum(name, values_for_revert = nil)
|
22
11
|
execute("DROP TYPE #{name}").tap {
|
@@ -3,7 +3,7 @@ require "active_support/lazy_load_hooks"
|
|
3
3
|
|
4
4
|
module ActiveRecord
|
5
5
|
module PGEnum
|
6
|
-
KNOWN_VERSIONS = %w[4.1 4.2 5.0 5.1 5.2 6.0 6.1].map { |v| Gem::Version.new(v) }
|
6
|
+
KNOWN_VERSIONS = %w[4.1 4.2 5.0 5.1 5.2 6.0 6.1 7.0].map { |v| Gem::Version.new(v) }
|
7
7
|
|
8
8
|
class << self
|
9
9
|
attr_reader :enabled_version
|
@@ -37,7 +37,6 @@ module ActiveRecord
|
|
37
37
|
|
38
38
|
def initialize!
|
39
39
|
require "active_record/pg_enum/command_recorder"
|
40
|
-
require "active_record/pg_enum/postgresql_adapter"
|
41
40
|
require "active_record/pg_enum/schema_statements"
|
42
41
|
|
43
42
|
Dir[File.join(__dir__, "pg_enum", enabled_version.to_s, "*.rb")].each { |file| require file }
|
@@ -45,7 +44,7 @@ module ActiveRecord
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def approximate_version(version)
|
48
|
-
segments = version.respond_to?(:canonical_segments) ? version.canonical_segments : version.segments
|
47
|
+
segments = version.respond_to?(:canonical_segments) ? version.canonical_segments.dup : version.segments
|
49
48
|
|
50
49
|
segments.pop while segments.any? { |s| String === s }
|
51
50
|
segments.pop while segments.size > 2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-pg_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Lassek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -129,10 +129,10 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".circleci/config.yml"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".rspec"
|
134
135
|
- ".rubocop.yml"
|
135
|
-
- ".travis.yml"
|
136
136
|
- Appraisals
|
137
137
|
- CHANGELOG.md
|
138
138
|
- Gemfile
|
@@ -157,37 +157,52 @@ files:
|
|
157
157
|
- gemfiles/6.0.gemfile.lock
|
158
158
|
- gemfiles/6.1.gemfile
|
159
159
|
- gemfiles/6.1.gemfile.lock
|
160
|
+
- gemfiles/7.0.gemfile
|
161
|
+
- gemfiles/7.0.gemfile.lock
|
160
162
|
- gemfiles/edge.gemfile
|
161
163
|
- gemfiles/edge.gemfile.lock
|
162
164
|
- lib/active_record/pg_enum.rb
|
165
|
+
- lib/active_record/pg_enum/4.1/create_enum.rb
|
163
166
|
- lib/active_record/pg_enum/4.1/initialize_type_map.rb
|
164
167
|
- lib/active_record/pg_enum/4.1/migration_keys.rb
|
168
|
+
- lib/active_record/pg_enum/4.1/postgresql_adapter.rb
|
165
169
|
- lib/active_record/pg_enum/4.1/prepare_column_options.rb
|
166
170
|
- lib/active_record/pg_enum/4.1/schema_dumper.rb
|
167
171
|
- lib/active_record/pg_enum/4.1/simplified_type.rb
|
168
172
|
- lib/active_record/pg_enum/4.1/table_definition.rb
|
173
|
+
- lib/active_record/pg_enum/4.2/create_enum.rb
|
169
174
|
- lib/active_record/pg_enum/4.2/migration_keys.rb
|
175
|
+
- lib/active_record/pg_enum/4.2/postgresql_adapter.rb
|
170
176
|
- lib/active_record/pg_enum/4.2/prepare_column_options.rb
|
171
177
|
- lib/active_record/pg_enum/4.2/schema_dumper.rb
|
172
178
|
- lib/active_record/pg_enum/4.2/table_definition.rb
|
179
|
+
- lib/active_record/pg_enum/5.0/create_enum.rb
|
173
180
|
- lib/active_record/pg_enum/5.0/migration_keys.rb
|
181
|
+
- lib/active_record/pg_enum/5.0/postgresql_adapter.rb
|
174
182
|
- lib/active_record/pg_enum/5.0/prepare_column_options.rb
|
175
183
|
- lib/active_record/pg_enum/5.0/schema_dumper.rb
|
176
184
|
- lib/active_record/pg_enum/5.0/table_definition.rb
|
185
|
+
- lib/active_record/pg_enum/5.1/create_enum.rb
|
186
|
+
- lib/active_record/pg_enum/5.1/postgresql_adapter.rb
|
177
187
|
- lib/active_record/pg_enum/5.1/prepare_column_options.rb
|
178
188
|
- lib/active_record/pg_enum/5.1/schema_dumper.rb
|
179
189
|
- lib/active_record/pg_enum/5.1/table_definition.rb
|
190
|
+
- lib/active_record/pg_enum/5.2/create_enum.rb
|
191
|
+
- lib/active_record/pg_enum/5.2/postgresql_adapter.rb
|
180
192
|
- lib/active_record/pg_enum/5.2/prepare_column_options.rb
|
181
193
|
- lib/active_record/pg_enum/5.2/schema_dumper.rb
|
182
194
|
- lib/active_record/pg_enum/5.2/table_definition.rb
|
195
|
+
- lib/active_record/pg_enum/6.0/create_enum.rb
|
196
|
+
- lib/active_record/pg_enum/6.0/postgresql_adapter.rb
|
183
197
|
- lib/active_record/pg_enum/6.0/prepare_column_options.rb
|
184
198
|
- lib/active_record/pg_enum/6.0/schema_dumper.rb
|
185
199
|
- lib/active_record/pg_enum/6.0/table_definition.rb
|
200
|
+
- lib/active_record/pg_enum/6.1/create_enum.rb
|
201
|
+
- lib/active_record/pg_enum/6.1/postgresql_adapter.rb
|
186
202
|
- lib/active_record/pg_enum/6.1/prepare_column_options.rb
|
187
203
|
- lib/active_record/pg_enum/6.1/schema_dumper.rb
|
188
204
|
- lib/active_record/pg_enum/6.1/table_definition.rb
|
189
205
|
- lib/active_record/pg_enum/command_recorder.rb
|
190
|
-
- lib/active_record/pg_enum/postgresql_adapter.rb
|
191
206
|
- lib/active_record/pg_enum/schema_statements.rb
|
192
207
|
- lib/active_record/pg_enum/version.rb
|
193
208
|
- lib/activerecord/pg_enum.rb
|
@@ -214,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
229
|
- !ruby/object:Gem::Version
|
215
230
|
version: '0'
|
216
231
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
232
|
+
rubygems_version: 3.1.6
|
218
233
|
signing_key:
|
219
234
|
specification_version: 4
|
220
235
|
summary: Integrate PostgreSQL's enumerated types with the Rails enum feature
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
dist: xenial
|
3
|
-
language: ruby
|
4
|
-
matrix:
|
5
|
-
include:
|
6
|
-
- rvm: 2.2.4
|
7
|
-
gemfile: gemfiles/4.1.gemfile
|
8
|
-
- rvm: 2.2.10
|
9
|
-
gemfile: gemfiles/4.2.gemfile
|
10
|
-
- rvm: 2.3.8
|
11
|
-
gemfile: gemfiles/5.0.gemfile
|
12
|
-
- rvm: 2.4.4
|
13
|
-
gemfile: gemfiles/5.1.gemfile
|
14
|
-
- rvm: 2.5.1
|
15
|
-
gemfile: gemfiles/5.2.gemfile
|
16
|
-
- rvm: 2.6.0
|
17
|
-
gemfile: gemfiles/6.0.gemfile
|
18
|
-
- rvm: 2.7.0
|
19
|
-
gemfile: gemfiles/6.1.gemfile
|
20
|
-
- rvm: ruby-head
|
21
|
-
gemfile: gemfiles/edge.gemfile
|
22
|
-
allow_failures:
|
23
|
-
- gemfile: gemfiles/edge.gemfile
|
24
|
-
services:
|
25
|
-
- postgresql
|
26
|
-
addons:
|
27
|
-
postgresql: "10"
|
28
|
-
before_install: gem install bundler -v 1.17.3
|
29
|
-
script: "bundle exec rake spec"
|
30
|
-
env:
|
31
|
-
global:
|
32
|
-
- TEST_USER=postgres
|
33
|
-
- PGPORT=5432
|