activerecord-pg_enum 1.0.4 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/Appraisals +5 -1
- data/CHANGELOG.md +24 -0
- data/README.md +30 -0
- data/Rakefile +11 -6
- data/activerecord-pg_enum.gemspec +1 -1
- data/gemfiles/4.1.gemfile.lock +6 -6
- data/gemfiles/4.2.gemfile.lock +12 -12
- data/gemfiles/5.0.gemfile.lock +12 -12
- data/gemfiles/5.1.gemfile.lock +13 -13
- data/gemfiles/5.2.gemfile.lock +13 -13
- data/gemfiles/6.0.gemfile +1 -1
- data/gemfiles/6.0.gemfile.lock +16 -16
- data/gemfiles/6.1.gemfile +7 -0
- data/gemfiles/6.1.gemfile.lock +70 -0
- data/gemfiles/edge.gemfile.lock +114 -93
- data/lib/active_record/pg_enum.rb +6 -2
- data/lib/active_record/pg_enum/6.0/table_definition.rb +16 -0
- data/lib/active_record/pg_enum/6.1/prepare_column_options.rb +1 -0
- data/lib/active_record/pg_enum/6.1/schema_dumper.rb +1 -0
- data/lib/active_record/pg_enum/6.1/table_definition.rb +1 -0
- data/lib/active_record/pg_enum/command_recorder.rb +19 -0
- data/lib/active_record/pg_enum/postgresql_adapter.rb +5 -8
- data/lib/active_record/pg_enum/schema_statements.rb +30 -1
- data/lib/active_record/pg_enum/version.rb +1 -1
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d36c9e4ee304c95191b220c77fce35aefe35302947e35a37a5b7140d2464d1
|
4
|
+
data.tar.gz: f0e1a8b1a8824df5b29e294f9cd35eb395712bf795d5a8b78bea9076a5986420
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b2f8159361a471e78f894348d35e3cd4df4c5794afcbe10be6ceec198a9cc195a3898631699bbbcac630d480ba27bad7aa48481c02615dfd4787d52a985c38b
|
7
|
+
data.tar.gz: afa8c39a24d7ff70b50d7c22b5fc98cca1ac7b3ac05a4f87b61da8ba38c2a60a5bfd43c914d02e415b6813a4bc1640589fa7f0964a4d1000966bf652f46ba07b
|
data/.travis.yml
CHANGED
@@ -15,6 +15,8 @@ matrix:
|
|
15
15
|
gemfile: gemfiles/5.2.gemfile
|
16
16
|
- rvm: 2.6.0
|
17
17
|
gemfile: gemfiles/6.0.gemfile
|
18
|
+
- rvm: 2.7.0
|
19
|
+
gemfile: gemfiles/6.1.gemfile
|
18
20
|
- rvm: ruby-head
|
19
21
|
gemfile: gemfiles/edge.gemfile
|
20
22
|
allow_failures:
|
@@ -22,7 +24,7 @@ matrix:
|
|
22
24
|
services:
|
23
25
|
- postgresql
|
24
26
|
addons:
|
25
|
-
postgresql: "
|
27
|
+
postgresql: "10"
|
26
28
|
before_install: gem install bundler -v 1.17.3
|
27
29
|
script: "bundle exec rake spec"
|
28
30
|
env:
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.2.2] - 2021-01-07
|
10
|
+
### Fixed
|
11
|
+
- Don't mutate `Gem::Version#canonical_segments` (@agrobbin)
|
12
|
+
|
13
|
+
## [1.2.1] - 2021-01-05
|
14
|
+
### Fixed
|
15
|
+
- Argument bug that surfaced in Ruby 3.0
|
16
|
+
|
17
|
+
## [1.2.0] - 2020-12-09
|
18
|
+
### Added
|
19
|
+
- Support for 6.1
|
20
|
+
|
21
|
+
## [1.1.0] - 2020-01-18
|
22
|
+
### Added
|
23
|
+
- `rename_enum` command for changing the type name
|
24
|
+
- `rename_enum_value` command for changing an enum label (PostgreSQL 10+ only)
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- Refactored some code to eliminate deprecation warnings in 2.7 related to kwargs
|
28
|
+
|
29
|
+
## [1.0.5] - 2019-11-22
|
30
|
+
### Fixed
|
31
|
+
- Don't include schema name in dumped enum types to be consistent with the way tables are dumped (@TylerRick)
|
32
|
+
|
9
33
|
## [1.0.4] - 2019-11-16
|
10
34
|
### Fixed
|
11
35
|
- Dump enums declared in non-public schemas
|
data/README.md
CHANGED
@@ -117,6 +117,36 @@ class AddStatusToOrder < ActiveRecord::Migration[5.2]
|
|
117
117
|
end
|
118
118
|
```
|
119
119
|
|
120
|
+
Renaming an enum type
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
class RenameStatusType < ActiveRecord::Migration[6.0]
|
124
|
+
def change
|
125
|
+
rename_enum "status_type", to: "order_status_type"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
```SQL
|
131
|
+
ALTER TYPE status_type RENAME TO order_status_type;
|
132
|
+
```
|
133
|
+
|
134
|
+
**PostgreSQL 10+ required**:
|
135
|
+
|
136
|
+
Changing an enum label
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
class ChangeStatusHoldLabel < ActiveRecord::Migration[6.0]
|
140
|
+
def change
|
141
|
+
rename_enum_value "status_type", from: "on hold", to: "OnHold"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
```
|
145
|
+
|
146
|
+
```SQL
|
147
|
+
ALTER TYPE status_type RENAME VALUE 'on hold' TO 'OnHold';
|
148
|
+
```
|
149
|
+
|
120
150
|
### Module Builder
|
121
151
|
|
122
152
|
```ruby
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
require "appraisal"
|
4
|
+
require "pry"
|
4
5
|
|
5
6
|
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
6
7
|
task :default => :appraisal
|
@@ -10,13 +11,15 @@ end
|
|
10
11
|
|
11
12
|
task :connection do
|
12
13
|
require "active_record"
|
14
|
+
require_relative "spec/support/connection_config"
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
config = db_config_hash.except(:database)
|
17
|
+
|
18
|
+
if ActiveRecord.constants.include?(:DatabaseConfigurations)
|
19
|
+
config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "primary", config)
|
20
|
+
end
|
21
|
+
|
22
|
+
ActiveRecord::Base.establish_connection(config)
|
20
23
|
end
|
21
24
|
|
22
25
|
namespace :spec do
|
@@ -35,6 +38,8 @@ namespace :spec do
|
|
35
38
|
conn.drop_database ENV.fetch("TEST_DATABASE", "pg_enum_test")
|
36
39
|
end
|
37
40
|
end
|
41
|
+
|
42
|
+
task reset: [:teardown, :setup]
|
38
43
|
end
|
39
44
|
|
40
45
|
task spec: %w[spec:setup spec:run spec:teardown]
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "activesupport"
|
37
37
|
|
38
38
|
spec.add_development_dependency "appraisal"
|
39
|
-
spec.add_development_dependency "bundler", "~> 1.
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
42
42
|
spec.add_development_dependency "pry"
|
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
|
@@ -66,7 +66,7 @@ DEPENDENCIES
|
|
66
66
|
activerecord (>= 4.1.0, < 4.2.0)
|
67
67
|
activerecord-pg_enum!
|
68
68
|
appraisal
|
69
|
-
bundler (~> 1.
|
69
|
+
bundler (~> 1.17)
|
70
70
|
i18n (~> 0.7)
|
71
71
|
pg (~> 0.15)
|
72
72
|
pry
|
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
|
@@ -64,7 +64,7 @@ DEPENDENCIES
|
|
64
64
|
activerecord (>= 4.2.0, < 5.0.0)
|
65
65
|
activerecord-pg_enum!
|
66
66
|
appraisal
|
67
|
-
bundler (~> 1.
|
67
|
+
bundler (~> 1.17)
|
68
68
|
i18n (~> 0.7)
|
69
69
|
pg (~> 0.15)
|
70
70
|
pry
|
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.
|
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
|
@@ -62,7 +62,7 @@ DEPENDENCIES
|
|
62
62
|
activerecord (>= 5.0.0, < 5.1.0)
|
63
63
|
activerecord-pg_enum!
|
64
64
|
appraisal
|
65
|
-
bundler (~> 1.
|
65
|
+
bundler (~> 1.17)
|
66
66
|
i18n (= 1.5.1)
|
67
67
|
pry
|
68
68
|
rake (~> 10.0)
|
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.
|
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
|
@@ -62,7 +62,7 @@ DEPENDENCIES
|
|
62
62
|
activerecord (>= 5.1.0, < 5.2.0)
|
63
63
|
activerecord-pg_enum!
|
64
64
|
appraisal
|
65
|
-
bundler (~> 1.
|
65
|
+
bundler (~> 1.17)
|
66
66
|
pry
|
67
67
|
rake (~> 10.0)
|
68
68
|
rspec (~> 3.0)
|
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.
|
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
|
@@ -62,7 +62,7 @@ DEPENDENCIES
|
|
62
62
|
activerecord (~> 5.2)
|
63
63
|
activerecord-pg_enum!
|
64
64
|
appraisal
|
65
|
-
bundler (~> 1.
|
65
|
+
bundler (~> 1.17)
|
66
66
|
pry
|
67
67
|
rake (~> 10.0)
|
68
68
|
rspec (~> 3.0)
|
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
|
@@ -9,29 +9,29 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (6.0.
|
13
|
-
activesupport (= 6.0.
|
14
|
-
activerecord (6.0.
|
15
|
-
activemodel (= 6.0.
|
16
|
-
activesupport (= 6.0.
|
17
|
-
activesupport (6.0.
|
12
|
+
activemodel (6.0.3.4)
|
13
|
+
activesupport (= 6.0.3.4)
|
14
|
+
activerecord (6.0.3.4)
|
15
|
+
activemodel (= 6.0.3.4)
|
16
|
+
activesupport (= 6.0.3.4)
|
17
|
+
activesupport (6.0.3.4)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
21
21
|
tzinfo (~> 1.1)
|
22
|
-
zeitwerk (~> 2.
|
22
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
23
23
|
appraisal (2.2.0)
|
24
24
|
bundler
|
25
25
|
rake
|
26
26
|
thor (>= 0.14.0)
|
27
27
|
coderay (1.1.2)
|
28
|
-
concurrent-ruby (1.1.
|
28
|
+
concurrent-ruby (1.1.7)
|
29
29
|
diff-lcs (1.3)
|
30
|
-
i18n (1.
|
30
|
+
i18n (1.8.5)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
32
|
method_source (0.9.2)
|
33
|
-
minitest (5.
|
34
|
-
pg (1.
|
33
|
+
minitest (5.14.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)
|
@@ -51,18 +51,18 @@ GEM
|
|
51
51
|
rspec-support (3.8.2)
|
52
52
|
thor (0.20.3)
|
53
53
|
thread_safe (0.3.6)
|
54
|
-
tzinfo (1.2.
|
54
|
+
tzinfo (1.2.8)
|
55
55
|
thread_safe (~> 0.1)
|
56
|
-
zeitwerk (2.
|
56
|
+
zeitwerk (2.4.2)
|
57
57
|
|
58
58
|
PLATFORMS
|
59
59
|
ruby
|
60
60
|
|
61
61
|
DEPENDENCIES
|
62
|
-
activerecord (
|
62
|
+
activerecord (~> 6.0)
|
63
63
|
activerecord-pg_enum!
|
64
64
|
appraisal
|
65
|
-
bundler (~> 1.
|
65
|
+
bundler (~> 1.17)
|
66
66
|
pry
|
67
67
|
rake (~> 10.0)
|
68
68
|
rspec (~> 3.0)
|
@@ -0,0 +1,70 @@
|
|
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 (6.1.0)
|
13
|
+
activesupport (= 6.1.0)
|
14
|
+
activerecord (6.1.0)
|
15
|
+
activemodel (= 6.1.0)
|
16
|
+
activesupport (= 6.1.0)
|
17
|
+
activesupport (6.1.0)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
|
+
zeitwerk (~> 2.3)
|
23
|
+
appraisal (2.3.0)
|
24
|
+
bundler
|
25
|
+
rake
|
26
|
+
thor (>= 0.14.0)
|
27
|
+
coderay (1.1.3)
|
28
|
+
concurrent-ruby (1.1.7)
|
29
|
+
diff-lcs (1.4.4)
|
30
|
+
i18n (1.8.5)
|
31
|
+
concurrent-ruby (~> 1.0)
|
32
|
+
method_source (1.0.0)
|
33
|
+
minitest (5.14.2)
|
34
|
+
pg (1.2.3)
|
35
|
+
pry (0.13.1)
|
36
|
+
coderay (~> 1.1)
|
37
|
+
method_source (~> 1.0)
|
38
|
+
rake (10.5.0)
|
39
|
+
rspec (3.10.0)
|
40
|
+
rspec-core (~> 3.10.0)
|
41
|
+
rspec-expectations (~> 3.10.0)
|
42
|
+
rspec-mocks (~> 3.10.0)
|
43
|
+
rspec-core (3.10.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-expectations (3.10.0)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-mocks (3.10.0)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.10.0)
|
51
|
+
rspec-support (3.10.0)
|
52
|
+
thor (1.0.1)
|
53
|
+
tzinfo (2.0.3)
|
54
|
+
concurrent-ruby (~> 1.0)
|
55
|
+
zeitwerk (2.4.2)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
activerecord (~> 6.1)
|
62
|
+
activerecord-pg_enum!
|
63
|
+
appraisal
|
64
|
+
bundler (~> 1.17)
|
65
|
+
pry
|
66
|
+
rake (~> 10.0)
|
67
|
+
rspec (~> 3.0)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.17.3
|
data/gemfiles/edge.gemfile.lock
CHANGED
@@ -1,72 +1,93 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/rails/rails.git
|
3
|
-
revision:
|
3
|
+
revision: 46337faa795fa40dedb1b9b906bec1793358d7f3
|
4
4
|
branch: master
|
5
5
|
specs:
|
6
|
-
actioncable (6.
|
7
|
-
actionpack (= 6.
|
6
|
+
actioncable (6.2.0.alpha)
|
7
|
+
actionpack (= 6.2.0.alpha)
|
8
|
+
activesupport (= 6.2.0.alpha)
|
8
9
|
nio4r (~> 2.0)
|
9
10
|
websocket-driver (>= 0.6.1)
|
10
|
-
|
11
|
-
actionpack (= 6.
|
12
|
-
|
13
|
-
|
11
|
+
actionmailbox (6.2.0.alpha)
|
12
|
+
actionpack (= 6.2.0.alpha)
|
13
|
+
activejob (= 6.2.0.alpha)
|
14
|
+
activerecord (= 6.2.0.alpha)
|
15
|
+
activestorage (= 6.2.0.alpha)
|
16
|
+
activesupport (= 6.2.0.alpha)
|
17
|
+
mail (>= 2.7.1)
|
18
|
+
actionmailer (6.2.0.alpha)
|
19
|
+
actionpack (= 6.2.0.alpha)
|
20
|
+
actionview (= 6.2.0.alpha)
|
21
|
+
activejob (= 6.2.0.alpha)
|
22
|
+
activesupport (= 6.2.0.alpha)
|
14
23
|
mail (~> 2.5, >= 2.5.4)
|
15
24
|
rails-dom-testing (~> 2.0)
|
16
|
-
actionpack (6.
|
17
|
-
actionview (= 6.
|
18
|
-
activesupport (= 6.
|
19
|
-
rack (~> 2.0)
|
25
|
+
actionpack (6.2.0.alpha)
|
26
|
+
actionview (= 6.2.0.alpha)
|
27
|
+
activesupport (= 6.2.0.alpha)
|
28
|
+
rack (~> 2.0, >= 2.0.9)
|
20
29
|
rack-test (>= 0.6.3)
|
21
30
|
rails-dom-testing (~> 2.0)
|
22
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
23
|
-
|
24
|
-
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
32
|
+
actiontext (6.2.0.alpha)
|
33
|
+
actionpack (= 6.2.0.alpha)
|
34
|
+
activerecord (= 6.2.0.alpha)
|
35
|
+
activestorage (= 6.2.0.alpha)
|
36
|
+
activesupport (= 6.2.0.alpha)
|
37
|
+
nokogiri (>= 1.8.5)
|
38
|
+
actionview (6.2.0.alpha)
|
39
|
+
activesupport (= 6.2.0.alpha)
|
25
40
|
builder (~> 3.1)
|
26
41
|
erubi (~> 1.4)
|
27
42
|
rails-dom-testing (~> 2.0)
|
28
|
-
rails-html-sanitizer (~> 1.
|
29
|
-
activejob (6.
|
30
|
-
activesupport (= 6.
|
43
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
44
|
+
activejob (6.2.0.alpha)
|
45
|
+
activesupport (= 6.2.0.alpha)
|
31
46
|
globalid (>= 0.3.6)
|
32
|
-
activemodel (6.
|
33
|
-
activesupport (= 6.
|
34
|
-
activerecord (6.
|
35
|
-
activemodel (= 6.
|
36
|
-
activesupport (= 6.
|
37
|
-
activestorage (6.
|
38
|
-
actionpack (= 6.
|
39
|
-
|
47
|
+
activemodel (6.2.0.alpha)
|
48
|
+
activesupport (= 6.2.0.alpha)
|
49
|
+
activerecord (6.2.0.alpha)
|
50
|
+
activemodel (= 6.2.0.alpha)
|
51
|
+
activesupport (= 6.2.0.alpha)
|
52
|
+
activestorage (6.2.0.alpha)
|
53
|
+
actionpack (= 6.2.0.alpha)
|
54
|
+
activejob (= 6.2.0.alpha)
|
55
|
+
activerecord (= 6.2.0.alpha)
|
56
|
+
activesupport (= 6.2.0.alpha)
|
40
57
|
marcel (~> 0.3.1)
|
41
|
-
|
58
|
+
mimemagic (~> 0.3.2)
|
59
|
+
activesupport (6.2.0.alpha)
|
42
60
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
43
|
-
i18n (>=
|
44
|
-
minitest (
|
45
|
-
tzinfo (~>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
i18n (>= 1.6, < 2)
|
62
|
+
minitest (>= 5.1)
|
63
|
+
tzinfo (~> 2.0)
|
64
|
+
zeitwerk (~> 2.3)
|
65
|
+
rails (6.2.0.alpha)
|
66
|
+
actioncable (= 6.2.0.alpha)
|
67
|
+
actionmailbox (= 6.2.0.alpha)
|
68
|
+
actionmailer (= 6.2.0.alpha)
|
69
|
+
actionpack (= 6.2.0.alpha)
|
70
|
+
actiontext (= 6.2.0.alpha)
|
71
|
+
actionview (= 6.2.0.alpha)
|
72
|
+
activejob (= 6.2.0.alpha)
|
73
|
+
activemodel (= 6.2.0.alpha)
|
74
|
+
activerecord (= 6.2.0.alpha)
|
75
|
+
activestorage (= 6.2.0.alpha)
|
76
|
+
activesupport (= 6.2.0.alpha)
|
77
|
+
bundler (>= 1.15.0)
|
78
|
+
railties (= 6.2.0.alpha)
|
58
79
|
sprockets-rails (>= 2.0.0)
|
59
|
-
railties (6.
|
60
|
-
actionpack (= 6.
|
61
|
-
activesupport (= 6.
|
80
|
+
railties (6.2.0.alpha)
|
81
|
+
actionpack (= 6.2.0.alpha)
|
82
|
+
activesupport (= 6.2.0.alpha)
|
62
83
|
method_source
|
63
84
|
rake (>= 0.8.7)
|
64
|
-
thor (
|
85
|
+
thor (~> 1.0)
|
65
86
|
|
66
87
|
PATH
|
67
88
|
remote: ..
|
68
89
|
specs:
|
69
|
-
activerecord-pg_enum (1.
|
90
|
+
activerecord-pg_enum (1.2.2)
|
70
91
|
activerecord (>= 4.1.0)
|
71
92
|
activesupport
|
72
93
|
pg
|
@@ -74,75 +95,75 @@ PATH
|
|
74
95
|
GEM
|
75
96
|
remote: https://rubygems.org/
|
76
97
|
specs:
|
77
|
-
appraisal (2.
|
98
|
+
appraisal (2.3.0)
|
78
99
|
bundler
|
79
100
|
rake
|
80
101
|
thor (>= 0.14.0)
|
81
|
-
builder (3.2.
|
82
|
-
coderay (1.1.
|
83
|
-
concurrent-ruby (1.
|
84
|
-
crass (1.0.
|
85
|
-
diff-lcs (1.
|
86
|
-
erubi (1.
|
87
|
-
globalid (0.4.
|
102
|
+
builder (3.2.4)
|
103
|
+
coderay (1.1.3)
|
104
|
+
concurrent-ruby (1.1.7)
|
105
|
+
crass (1.0.6)
|
106
|
+
diff-lcs (1.4.4)
|
107
|
+
erubi (1.10.0)
|
108
|
+
globalid (0.4.2)
|
88
109
|
activesupport (>= 4.2.0)
|
89
|
-
i18n (1.
|
110
|
+
i18n (1.8.5)
|
90
111
|
concurrent-ruby (~> 1.0)
|
91
|
-
loofah (2.
|
112
|
+
loofah (2.8.0)
|
92
113
|
crass (~> 1.0.2)
|
93
114
|
nokogiri (>= 1.5.9)
|
94
|
-
mail (2.7.
|
115
|
+
mail (2.7.1)
|
95
116
|
mini_mime (>= 0.1.1)
|
96
|
-
marcel (0.3.
|
117
|
+
marcel (0.3.3)
|
97
118
|
mimemagic (~> 0.3.2)
|
98
|
-
method_source (0.
|
99
|
-
mimemagic (0.3.
|
100
|
-
mini_mime (1.0.
|
101
|
-
mini_portile2 (2.
|
102
|
-
minitest (5.
|
103
|
-
nio4r (2.
|
104
|
-
nokogiri (1.
|
105
|
-
mini_portile2 (~> 2.
|
106
|
-
pg (1.
|
107
|
-
pry (0.
|
108
|
-
coderay (~> 1.1
|
109
|
-
method_source (~>
|
110
|
-
rack (2.
|
119
|
+
method_source (1.0.0)
|
120
|
+
mimemagic (0.3.5)
|
121
|
+
mini_mime (1.0.2)
|
122
|
+
mini_portile2 (2.4.0)
|
123
|
+
minitest (5.14.2)
|
124
|
+
nio4r (2.5.4)
|
125
|
+
nokogiri (1.10.10)
|
126
|
+
mini_portile2 (~> 2.4.0)
|
127
|
+
pg (1.2.3)
|
128
|
+
pry (0.13.1)
|
129
|
+
coderay (~> 1.1)
|
130
|
+
method_source (~> 1.0)
|
131
|
+
rack (2.2.3)
|
111
132
|
rack-test (1.1.0)
|
112
133
|
rack (>= 1.0, < 3)
|
113
134
|
rails-dom-testing (2.0.3)
|
114
135
|
activesupport (>= 4.2.0)
|
115
136
|
nokogiri (>= 1.6)
|
116
|
-
rails-html-sanitizer (1.0
|
117
|
-
loofah (~> 2.
|
137
|
+
rails-html-sanitizer (1.3.0)
|
138
|
+
loofah (~> 2.3)
|
118
139
|
rake (10.5.0)
|
119
|
-
rspec (3.
|
120
|
-
rspec-core (~> 3.
|
121
|
-
rspec-expectations (~> 3.
|
122
|
-
rspec-mocks (~> 3.
|
123
|
-
rspec-core (3.
|
124
|
-
rspec-support (~> 3.
|
125
|
-
rspec-expectations (3.
|
140
|
+
rspec (3.10.0)
|
141
|
+
rspec-core (~> 3.10.0)
|
142
|
+
rspec-expectations (~> 3.10.0)
|
143
|
+
rspec-mocks (~> 3.10.0)
|
144
|
+
rspec-core (3.10.0)
|
145
|
+
rspec-support (~> 3.10.0)
|
146
|
+
rspec-expectations (3.10.0)
|
126
147
|
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
-
rspec-support (~> 3.
|
128
|
-
rspec-mocks (3.
|
148
|
+
rspec-support (~> 3.10.0)
|
149
|
+
rspec-mocks (3.10.0)
|
129
150
|
diff-lcs (>= 1.2.0, < 2.0)
|
130
|
-
rspec-support (~> 3.
|
131
|
-
rspec-support (3.
|
132
|
-
sprockets (
|
151
|
+
rspec-support (~> 3.10.0)
|
152
|
+
rspec-support (3.10.0)
|
153
|
+
sprockets (4.0.2)
|
133
154
|
concurrent-ruby (~> 1.0)
|
134
155
|
rack (> 1, < 3)
|
135
|
-
sprockets-rails (3.2.
|
156
|
+
sprockets-rails (3.2.2)
|
136
157
|
actionpack (>= 4.0)
|
137
158
|
activesupport (>= 4.0)
|
138
159
|
sprockets (>= 3.0.0)
|
139
|
-
thor (0.
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
websocket-driver (0.7.0)
|
160
|
+
thor (1.0.1)
|
161
|
+
tzinfo (2.0.3)
|
162
|
+
concurrent-ruby (~> 1.0)
|
163
|
+
websocket-driver (0.7.3)
|
144
164
|
websocket-extensions (>= 0.1.0)
|
145
|
-
websocket-extensions (0.1.
|
165
|
+
websocket-extensions (0.1.5)
|
166
|
+
zeitwerk (2.4.2)
|
146
167
|
|
147
168
|
PLATFORMS
|
148
169
|
ruby
|
@@ -150,7 +171,7 @@ PLATFORMS
|
|
150
171
|
DEPENDENCIES
|
151
172
|
activerecord-pg_enum!
|
152
173
|
appraisal
|
153
|
-
bundler (~> 1.
|
174
|
+
bundler (~> 1.17)
|
154
175
|
pry
|
155
176
|
rails!
|
156
177
|
rake (~> 10.0)
|
@@ -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].map { |v| Gem::Version.new(v) }
|
6
|
+
KNOWN_VERSIONS = %w[4.1 4.2 5.0 5.1 5.2 6.0 6.1].map { |v| Gem::Version.new(v) }
|
7
7
|
|
8
8
|
class << self
|
9
9
|
attr_reader :enabled_version
|
@@ -25,6 +25,10 @@ module ActiveRecord
|
|
25
25
|
monkeypatches[patch] = block
|
26
26
|
end
|
27
27
|
|
28
|
+
def detected_version
|
29
|
+
approximate_version Gem.loaded_specs["activerecord"].version
|
30
|
+
end
|
31
|
+
|
28
32
|
private
|
29
33
|
|
30
34
|
def monkeypatches
|
@@ -41,7 +45,7 @@ module ActiveRecord
|
|
41
45
|
end
|
42
46
|
|
43
47
|
def approximate_version(version)
|
44
|
-
segments = version.respond_to?(:canonical_segments) ? version.canonical_segments : version.segments
|
48
|
+
segments = version.respond_to?(:canonical_segments) ? version.canonical_segments.dup : version.segments
|
45
49
|
|
46
50
|
segments.pop while segments.any? { |s| String === s }
|
47
51
|
segments.pop while segments.size > 2
|
@@ -1,2 +1,18 @@
|
|
1
1
|
require "active_record/pg_enum/4.2/table_definition"
|
2
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 @@
|
|
1
|
+
require "active_record/pg_enum/5.2/prepare_column_options"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/5.2/schema_dumper"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_enum/6.0/table_definition"
|
@@ -34,12 +34,31 @@ module ActiveRecord
|
|
34
34
|
record(:add_enum_value, args, &block)
|
35
35
|
end
|
36
36
|
|
37
|
+
def rename_enum(name, options = {})
|
38
|
+
record(:rename_enum, [name, options])
|
39
|
+
end
|
40
|
+
|
41
|
+
def rename_enum_value(type, options = {})
|
42
|
+
record(:rename_enum_value, [type, options])
|
43
|
+
end
|
44
|
+
|
37
45
|
private
|
38
46
|
|
39
47
|
def invert_create_enum(args)
|
40
48
|
[:drop_enum, args]
|
41
49
|
end
|
42
50
|
|
51
|
+
def invert_rename_enum_value(args)
|
52
|
+
type, args = args
|
53
|
+
reversed = %i[from to].zip(args.values_at(:to, :from))
|
54
|
+
|
55
|
+
[:rename_enum_value, [type, Hash[reversed]]]
|
56
|
+
end
|
57
|
+
|
58
|
+
def invert_rename_enum(args)
|
59
|
+
[:rename_enum, [args.last[:to], to: args.first]]
|
60
|
+
end
|
61
|
+
|
43
62
|
def invert_drop_enum(args)
|
44
63
|
raise ActiveRecord::IrreversibleMigration, "drop_enum is only reversible if given a list of values" unless args.length > 1
|
45
64
|
[:create_enum, args]
|
@@ -14,11 +14,12 @@ module ActiveRecord
|
|
14
14
|
# { "foo_type" => ["foo", "bar", "baz"] }
|
15
15
|
def enum_types
|
16
16
|
res = exec_query(<<-SQL.strip_heredoc, "SCHEMA")
|
17
|
-
SELECT
|
17
|
+
SELECT t.typname AS enum_name, array_agg(e.enumlabel ORDER BY e.enumsortorder) AS enum_value
|
18
18
|
FROM pg_type t
|
19
19
|
JOIN pg_enum e ON t.oid = e.enumtypid
|
20
20
|
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
21
|
-
|
21
|
+
WHERE n.nspname = ANY (current_schemas(false))
|
22
|
+
GROUP BY enum_name;
|
22
23
|
SQL
|
23
24
|
|
24
25
|
coltype = res.column_types["enum_value"]
|
@@ -30,12 +31,8 @@ module ActiveRecord
|
|
30
31
|
proc { |values| coltype.type_cast(values) }
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
public_enums
|
37
|
-
.map { |_, name, values| [name, values] }
|
38
|
-
.concat(custom)
|
34
|
+
res.rows
|
35
|
+
.map { |name, values| [name, values] }
|
39
36
|
.sort { |a, b| a.first <=> b.first }
|
40
37
|
.each_with_object({}) { |(name, values), memo| memo[name] = deserialize.call(values) }
|
41
38
|
end
|
@@ -24,6 +24,14 @@ module ActiveRecord
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
+
# Rename an existing ENUM type
|
28
|
+
def rename_enum(name, options = {})
|
29
|
+
to = options.fetch(:to) { raise ArgumentError, ":to is required" }
|
30
|
+
execute("ALTER TYPE #{name} RENAME TO #{to}").tap {
|
31
|
+
reload_type_map
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
27
35
|
# Add a new value to an existing ENUM type.
|
28
36
|
# Only one value at a time is supported by PostgreSQL.
|
29
37
|
#
|
@@ -34,7 +42,8 @@ module ActiveRecord
|
|
34
42
|
# Example:
|
35
43
|
#
|
36
44
|
# add_enum_value("foo_type", "quux", before: "bar")
|
37
|
-
def add_enum_value(type, value,
|
45
|
+
def add_enum_value(type, value, options = {})
|
46
|
+
before, after = options.values_at(:before, :after)
|
38
47
|
cmd = "ALTER TYPE #{type} ADD VALUE '#{value}'"
|
39
48
|
|
40
49
|
if before && after
|
@@ -47,6 +56,26 @@ module ActiveRecord
|
|
47
56
|
|
48
57
|
execute(cmd).tap { reload_type_map }
|
49
58
|
end
|
59
|
+
|
60
|
+
# Change the label of an existing ENUM value
|
61
|
+
#
|
62
|
+
# Options:
|
63
|
+
# from: The original label string
|
64
|
+
# to: The desired label string
|
65
|
+
#
|
66
|
+
# Example:
|
67
|
+
#
|
68
|
+
# rename_enum_value "foo_type", from: "quux", to: "Quux"
|
69
|
+
#
|
70
|
+
# Note: This feature requires PostgreSQL 10 or later
|
71
|
+
def rename_enum_value(type, options = {})
|
72
|
+
from = options.fetch(:from) { raise ArgumentError, ":from is required" }
|
73
|
+
to = options.fetch(:to) { raise ArgumentError, ":to is required" }
|
74
|
+
|
75
|
+
execute("ALTER TYPE #{type} RENAME VALUE '#{from}' TO '#{to}'").tap {
|
76
|
+
reload_type_map
|
77
|
+
}
|
78
|
+
end
|
50
79
|
end
|
51
80
|
end
|
52
81
|
end
|
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: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Lassek
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.17'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.17'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- adam@doubleprime.net
|
128
128
|
executables: []
|
@@ -155,6 +155,8 @@ files:
|
|
155
155
|
- gemfiles/5.2.gemfile.lock
|
156
156
|
- gemfiles/6.0.gemfile
|
157
157
|
- gemfiles/6.0.gemfile.lock
|
158
|
+
- gemfiles/6.1.gemfile
|
159
|
+
- gemfiles/6.1.gemfile.lock
|
158
160
|
- gemfiles/edge.gemfile
|
159
161
|
- gemfiles/edge.gemfile.lock
|
160
162
|
- lib/active_record/pg_enum.rb
|
@@ -181,6 +183,9 @@ files:
|
|
181
183
|
- lib/active_record/pg_enum/6.0/prepare_column_options.rb
|
182
184
|
- lib/active_record/pg_enum/6.0/schema_dumper.rb
|
183
185
|
- lib/active_record/pg_enum/6.0/table_definition.rb
|
186
|
+
- lib/active_record/pg_enum/6.1/prepare_column_options.rb
|
187
|
+
- lib/active_record/pg_enum/6.1/schema_dumper.rb
|
188
|
+
- lib/active_record/pg_enum/6.1/table_definition.rb
|
184
189
|
- lib/active_record/pg_enum/command_recorder.rb
|
185
190
|
- lib/active_record/pg_enum/postgresql_adapter.rb
|
186
191
|
- lib/active_record/pg_enum/schema_statements.rb
|
@@ -194,7 +199,7 @@ metadata:
|
|
194
199
|
changelog_uri: https://github.com/alassek/activerecord-pg_enum/blob/master/CHANGELOG.md
|
195
200
|
pgp_keys_uri: https://keybase.io/alassek/pgp_keys.asc
|
196
201
|
signatures_uri: https://keybase.pub/alassek/gems/
|
197
|
-
post_install_message:
|
202
|
+
post_install_message:
|
198
203
|
rdoc_options: []
|
199
204
|
require_paths:
|
200
205
|
- lib
|
@@ -210,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
215
|
version: '0'
|
211
216
|
requirements: []
|
212
217
|
rubygems_version: 3.0.3
|
213
|
-
signing_key:
|
218
|
+
signing_key:
|
214
219
|
specification_version: 4
|
215
220
|
summary: Integrate PostgreSQL's enumerated types with the Rails enum feature
|
216
221
|
test_files: []
|