activerecord-postgres_enum 2.0.1 → 2.1.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/README.md +2 -2
- data/lib/active_record/postgres_enum/column.rb +0 -2
- data/lib/active_record/postgres_enum/command_recorder.rb +1 -1
- data/lib/active_record/postgres_enum/postgresql_adapter.rb +9 -3
- data/lib/active_record/postgres_enum/schema_dumper.rb +6 -2
- data/lib/active_record/postgres_enum/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b774ca52773f7346d01b9db6bf6b5a914c10253597c6796f6b6619612dfba64
|
4
|
+
data.tar.gz: 92c8bfb4e74845ce4a44d381c775b9443a22e2d091a55904d3deb7d2c0d5d0bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716129b56fd13a1630fb6de9fb0a74608921dcad4e35e47523bc0c2c901fb72aa202eb95f483bd0a0bcd2a1f2fd1cbeb3603fa6b80791274d30688bf82e3417a
|
7
|
+
data.tar.gz: a8c8a21b0164e61d16d2e3ef5ed3d2726bed463ddc0f63dcf36e9b60cb5bed87f699a4a639f68d642b0f11d63a13a057d8113417479091b93b91166dc64eb9b0
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ create_table :person do
|
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
39
|
-
Running the above will create a table :person, with a column :person_mood of type :mood. This will also be saved on schema.rb so that `rake schema:load` works as expected.
|
39
|
+
Running the above will create a table :person, with a column :person_mood of type :mood. This will also be saved on schema.rb so that `rake db:schema:load` works as expected.
|
40
40
|
|
41
41
|
To drop an existing enum:
|
42
42
|
|
@@ -85,7 +85,7 @@ rename_enum_value :mood, "pensive", "wistful"
|
|
85
85
|
|
86
86
|
## Development
|
87
87
|
|
88
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
88
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
89
89
|
|
90
90
|
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).
|
91
91
|
|
@@ -10,8 +10,10 @@ module ActiveRecord
|
|
10
10
|
t.typtype,
|
11
11
|
array_to_string(array_agg(e.enumlabel ORDER BY e.enumsortorder), '\t\t', '') as enumlabels
|
12
12
|
FROM pg_type t
|
13
|
+
INNER JOIN pg_namespace n ON n.oid = t.typnamespace
|
13
14
|
LEFT JOIN pg_enum e ON e.enumtypid = t.oid
|
14
|
-
WHERE typtype = 'e'
|
15
|
+
WHERE t.typtype = 'e'
|
16
|
+
AND n.nspname = ANY(current_schemas(true))
|
15
17
|
GROUP BY t.OID, t.typname, t.typtype
|
16
18
|
ORDER BY t.typname
|
17
19
|
SQL
|
@@ -58,8 +60,12 @@ module ActiveRecord
|
|
58
60
|
def remove_enum_value(name, value)
|
59
61
|
sql = %{
|
60
62
|
DELETE FROM pg_enum
|
61
|
-
WHERE enumlabel
|
62
|
-
AND enumtypid
|
63
|
+
WHERE enumlabel = #{quote value}
|
64
|
+
AND enumtypid IN (SELECT t.oid
|
65
|
+
FROM pg_type t
|
66
|
+
INNER JOIN pg_namespace n ON n.oid = t.typnamespace
|
67
|
+
WHERE t.typname = '#{name}'
|
68
|
+
AND n.nspname = ANY(current_schemas(true)))
|
63
69
|
}
|
64
70
|
execute sql
|
65
71
|
end
|
@@ -22,8 +22,12 @@ module ActiveRecord
|
|
22
22
|
statements << " create_enum #{name.inspect}, [\n#{values}\n ], force: :cascade"
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
# Check if there any enum types to dump - otherwise don't output
|
26
|
+
# anything to prevent empty lines in schema.rb
|
27
|
+
if statements.any?
|
28
|
+
stream.puts statements.join("\n\n")
|
29
|
+
stream.puts
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-postgres_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Merkushin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
168
|
requirements:
|
169
169
|
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
|
-
version: '2.
|
171
|
+
version: '2.7'
|
172
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
174
|
- - ">="
|