activerecord-postgres_enum 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- 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/schema_dumper.rb +17 -9
- data/lib/active_record/postgres_enum/version.rb +1 -1
- data/lib/active_record/postgres_enum.rb +15 -15
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4658a60bc93da30adf1d9cb7d2f6fce18521c2bfb063ff822c51b69d2e1f9d34
|
4
|
+
data.tar.gz: 661cde0de2e935c4d2e67e51282073faafd5991b6391e2a4e09669ba3711a6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c880fa8bb243ea447630342c78e272839fbc961b694ec6610b46987ead637d64b5cb29d87550a18c0b654ca17e6afd84511ea7c6a813ab3657e3ab4fb1408f66
|
7
|
+
data.tar.gz: 542a619f5c41b67242aa379524588bb31b1d430d30e9f007244813c6b2ba746d3615a756bd932532a22a2555827f360768e91aadbcff3a814b874ae1c62a4367
|
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
|
|
@@ -4,10 +4,12 @@ module ActiveRecord
|
|
4
4
|
module PostgresEnum
|
5
5
|
# provide support for writing out the 'create_enum' calls in schema.rb
|
6
6
|
module SchemaDumper
|
7
|
-
|
8
|
-
|
7
|
+
unless ActiveRecord::PostgresEnum.rails_7?
|
8
|
+
def tables(stream)
|
9
|
+
types(stream)
|
9
10
|
|
10
|
-
|
11
|
+
super
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
@@ -20,15 +22,21 @@ module ActiveRecord
|
|
20
22
|
statements << " create_enum #{name.inspect}, [\n#{values}\n ], force: :cascade"
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
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
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
unless ActiveRecord::PostgresEnum.rails_7?
|
35
|
+
def prepare_column_options(column)
|
36
|
+
spec = super
|
37
|
+
spec[:enum_type] ||= "\"#{column.sql_type}\"" if column.enum?
|
38
|
+
spec
|
39
|
+
end
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
@@ -6,39 +6,39 @@ require "active_record/connection_adapters/postgresql/schema_statements"
|
|
6
6
|
require "active_record/connection_adapters/postgresql_adapter"
|
7
7
|
require "active_support/lazy_load_hooks"
|
8
8
|
|
9
|
-
require "active_record/postgres_enum/version"
|
10
|
-
require "active_record/postgres_enum/postgresql_adapter"
|
11
|
-
require "active_record/postgres_enum/schema_dumper"
|
12
|
-
require "active_record/postgres_enum/schema_statements"
|
13
|
-
require "active_record/postgres_enum/column"
|
14
|
-
require "active_record/postgres_enum/column_methods"
|
15
|
-
require "active_record/postgres_enum/command_recorder"
|
16
|
-
require "active_record/postgres_enum/enum_validator"
|
17
|
-
|
18
9
|
module ActiveRecord
|
19
10
|
module PostgresEnum
|
20
11
|
def self.rails_7?
|
21
|
-
|
12
|
+
ActiveRecord::VERSION::MAJOR == 7
|
22
13
|
end
|
23
14
|
|
24
15
|
def self.rails_5?
|
25
|
-
|
16
|
+
ActiveRecord::VERSION::MAJOR == 5
|
26
17
|
end
|
27
18
|
end
|
28
19
|
end
|
29
20
|
|
21
|
+
require "active_record/postgres_enum/version"
|
22
|
+
require "active_record/postgres_enum/postgresql_adapter"
|
23
|
+
require "active_record/postgres_enum/schema_dumper"
|
24
|
+
require "active_record/postgres_enum/schema_statements"
|
25
|
+
require "active_record/postgres_enum/column"
|
26
|
+
require "active_record/postgres_enum/column_methods"
|
27
|
+
require "active_record/postgres_enum/command_recorder"
|
28
|
+
require "active_record/postgres_enum/enum_validator"
|
29
|
+
|
30
30
|
ActiveSupport.on_load(:active_record) do
|
31
31
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend ActiveRecord::PostgresEnum::PostgreSQLAdapter
|
32
32
|
|
33
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(
|
34
|
+
ActiveRecord::PostgresEnum::SchemaDumper
|
35
|
+
)
|
36
|
+
|
33
37
|
ActiveRecord::Migration::CommandRecorder.prepend ActiveRecord::PostgresEnum::CommandRecorder
|
34
38
|
|
35
39
|
unless ActiveRecord::PostgresEnum.rails_7?
|
36
40
|
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:enum] = {}
|
37
41
|
|
38
|
-
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(
|
39
|
-
ActiveRecord::PostgresEnum::SchemaDumper
|
40
|
-
)
|
41
|
-
|
42
42
|
if ActiveRecord::PostgresEnum.rails_5?
|
43
43
|
ActiveRecord::ConnectionAdapters::PostgreSQLColumn.prepend(
|
44
44
|
ActiveRecord::PostgresEnum::Column
|
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.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Merkushin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.1'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- merkushin.m.s@gmail.com
|
142
142
|
executables: []
|
@@ -160,7 +160,7 @@ licenses:
|
|
160
160
|
- MIT
|
161
161
|
metadata:
|
162
162
|
allowed_push_host: https://rubygems.org
|
163
|
-
post_install_message:
|
163
|
+
post_install_message:
|
164
164
|
rdoc_options: []
|
165
165
|
require_paths:
|
166
166
|
- lib
|
@@ -168,15 +168,15 @@ 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
|
- - ">="
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
179
|
-
signing_key:
|
178
|
+
rubygems_version: 3.2.32
|
179
|
+
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Integrate PostgreSQL's enum data type into ActiveRecord's schema and migrations.
|
182
182
|
test_files: []
|