activerecord-postgres_enum 1.3.0 → 1.4.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: 2e453014b2e32bcb23b20fd8c1f2dbb628690f303a61368bfad37564868244e4
4
- data.tar.gz: 55b98925e297a91892c5c284e53564a6012cdb82e2494b93505974207e8d7de2
3
+ metadata.gz: 27d16c338c8dcb14b9746be0e941981230c9a7eee7e4704755da15ed9869025a
4
+ data.tar.gz: 5077374a8566971f0236c67e4d52ae0467659f5fe14d384ec331bb58bbfb2df3
5
5
  SHA512:
6
- metadata.gz: 45e0ba20aeaf52968c9022fca7aed356272ad2deb9883c98020d0bcdc17dfa73786fac4776f1f8cd02b45babe4a1344b5bcf9e516b8c3161275713910babc797
7
- data.tar.gz: 66fd78a22198c3326b66ce410fac6782599164d3087473b1e3d5550e94801af37407d85786ca38c5f4c5c0503b5320dcde7c377a5d1ef3f94db72f4b236a73f2
6
+ metadata.gz: a58d412d08199ef784ec320d8534c39b58d150c7bc423aa493ac50602edbb9bd20e6cd176e989ec6629659ceb53117576ae98fb27ba0be9186d5c6bda6d11527
7
+ data.tar.gz: 39a6e9e9bb211cc7c3931f13459b83bf747398d0b0b94df3da0f9471565931b553beedb08b9e645c13654c5e1231f6c99b37c303133a454b80a5ce10c3e8b8ea
@@ -42,9 +42,11 @@ module ActiveRecord
42
42
  end
43
43
  end
44
44
 
45
- def create_enum(name, values, if_not_exists: nil)
45
+ def create_enum(name, values, force: false, if_not_exists: nil)
46
46
  return if if_not_exists && enums.include?(name.to_sym)
47
47
 
48
+ drop_enum(name, cascade: force == :cascade, if_exists: true) if force
49
+
48
50
  values = values.map { |v| quote v }
49
51
  execute "CREATE TYPE #{name} AS ENUM (#{values.join(', ')})"
50
52
  end
@@ -17,10 +17,10 @@ module ActiveRecord
17
17
 
18
18
  @connection.enums.each do |name, values|
19
19
  values = values.map { |v| " #{v.inspect}," }.join("\n")
20
- statements << " create_enum #{name.inspect}, [\n#{values}\n ]"
20
+ statements << " create_enum #{name.inspect}, [\n#{values}\n ], force: :cascade"
21
21
  end
22
22
 
23
- stream.puts statements.join("\n")
23
+ stream.puts statements.join("\n\n")
24
24
  stream.puts
25
25
  end
26
26
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module PostgresEnum
5
- VERSION = "1.3.0"
5
+ VERSION = "1.4.0"
6
6
  end
7
7
  end
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: 1.3.0
4
+ version: 1.4.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: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: '0'
175
+ version: '2.5'
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="