activerecord-postgres_enum 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a1b82a6fcd24c4c9811b824bbe1dc8db8043dc7285a6481a029d9b88fe92410
|
4
|
+
data.tar.gz: f7989568c9a5db1a33fac706e4baf98ffdbde8b6d23f9625182def8b1370b19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4d78fdc5af2ed94e53c749f365a1c1ef9c5a1a43c5aa2a56861db99381ee991749f6e51d5114182058c0b9936eef6a96cbbb390cda7b05760169312244cc57
|
7
|
+
data.tar.gz: aaed102da13bc6f8ccd8bd5994ea9d6c9ec88ff72cafd537ea225126f9ccb29ab570e5ab7958eecb747365f67b7d870386c1642264cfedec10a3887dd501c6b3
|
@@ -3,6 +3,26 @@
|
|
3
3
|
module ActiveRecord
|
4
4
|
module PostgresEnum
|
5
5
|
module PostgreSQLAdapter
|
6
|
+
# For Rails >= 5.2
|
7
|
+
# https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_dumper.rb
|
8
|
+
module SchemaDumperExt
|
9
|
+
def prepare_column_options(column)
|
10
|
+
spec = super
|
11
|
+
spec[:enum_name] = column.sql_type.inspect if column.type == :enum
|
12
|
+
spec
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# For Rails <5.2
|
17
|
+
# https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_dumper.rb
|
18
|
+
module ColumnDumperExt
|
19
|
+
def prepare_column_options(column)
|
20
|
+
spec = super
|
21
|
+
spec[:enum_name] = column.sql_type.inspect if column.type == :enum
|
22
|
+
spec
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
6
26
|
DEFINED_ENUMS_QUERY = <<~SQL
|
7
27
|
SELECT t.OID, t.typname, t.typtype, array_agg(e.enumlabel) as enumlabels
|
8
28
|
FROM pg_type t
|
@@ -15,8 +15,21 @@ ActiveSupport.on_load(:active_record) do
|
|
15
15
|
require "active_record/postgres_enum/extensions"
|
16
16
|
|
17
17
|
ActiveRecord::SchemaDumper.prepend ActiveRecord::PostgresEnum::SchemaDumper
|
18
|
+
|
18
19
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend ActiveRecord::PostgresEnum::PostgreSQLAdapter
|
19
20
|
|
21
|
+
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDumper)
|
22
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDumper.prepend(
|
23
|
+
ActiveRecord::PostgresEnum::PostgreSQLAdapter::ColumnDumperExt
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper)
|
28
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(
|
29
|
+
ActiveRecord::PostgresEnum::PostgreSQLAdapter::SchemaDumperExt
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
20
33
|
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:enum] = {
|
21
34
|
name: 'enum'
|
22
35
|
}
|
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: 0.
|
4
|
+
version: 0.5.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: 2019-02-
|
11
|
+
date: 2019-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|