activerecord-postgres_enum 1.2.0 → 1.3.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: 65fc162010507d18b3607853f938bc02f2106ba56764d020943a241c00af3f07
4
- data.tar.gz: 42eb21dd6b8441e8ca5589b38a30da8cbc646de28c89ecf58f09df5c92c67f54
3
+ metadata.gz: 2e453014b2e32bcb23b20fd8c1f2dbb628690f303a61368bfad37564868244e4
4
+ data.tar.gz: 55b98925e297a91892c5c284e53564a6012cdb82e2494b93505974207e8d7de2
5
5
  SHA512:
6
- metadata.gz: 753abb413ecf0ee2a32e68c3bf1be93c3678c75b1b578a9c3177426bb31a8bbeff9010dc7550f66a2b710394ca97eb11e17eaeedbd17d1f6f0ddb7ddd1ce5799
7
- data.tar.gz: 76200a6b37e19b00066a133d5ae377f9a3396681ac7bda6031b1cb89a1c0316ea9ae2c1de69c0f0ea1eb0fab196abad4cd7f0be23f7e04ae0fb34de614a51216
6
+ metadata.gz: 45e0ba20aeaf52968c9022fca7aed356272ad2deb9883c98020d0bcdc17dfa73786fac4776f1f8cd02b45babe4a1344b5bcf9e516b8c3161275713910babc797
7
+ data.tar.gz: 66fd78a22198c3326b66ce410fac6782599164d3087473b1e3d5550e94801af37407d85786ca38c5f4c5c0503b5320dcde7c377a5d1ef3f94db72f4b236a73f2
@@ -42,13 +42,19 @@ module ActiveRecord
42
42
  end
43
43
  end
44
44
 
45
- def create_enum(name, values)
45
+ def create_enum(name, values, if_not_exists: nil)
46
+ return if if_not_exists && enums.include?(name.to_sym)
47
+
46
48
  values = values.map { |v| quote v }
47
49
  execute "CREATE TYPE #{name} AS ENUM (#{values.join(', ')})"
48
50
  end
49
51
 
50
- def drop_enum(name)
51
- execute "DROP TYPE #{name}"
52
+ def drop_enum(name, cascade: nil, if_exists: nil)
53
+ if_exists_statement = 'IF EXISTS' if if_exists
54
+ cascade_statement = 'CASCADE' if cascade
55
+
56
+ sql = "DROP TYPE #{if_exists_statement} #{name} #{cascade_statement}"
57
+ execute sql
52
58
  end
53
59
 
54
60
  def rename_enum(name, new_name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module PostgresEnum
5
- VERSION = "1.2.0"
5
+ VERSION = "1.3.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.2.0
4
+ version: 1.3.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-24 00:00:00.000000000 Z
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord