dynamic_migrations 3.8.3 → 3.8.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a9d25190ae4b67f3154feae64f9aa7a11d6b6effc9a6422cce43cde28cbcc68
|
4
|
+
data.tar.gz: 6a7a23a1d7793155f383899ec83f3477ec18581cf94a762a0729466e6d791ac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84c9ed288329dbb5cc687335820feb293dd4aced564d9ebd8c65e0a84ab12368f8a2b774bef93af9fb9c845fb889eb8daadb9f8c60229e00cc8a78ce768ff3cd
|
7
|
+
data.tar.gz: e2b639cc38df40ed02de870e97707a71a1305819ce3eeac3d61384cdda75c764a3793616149187bf2eed3a40443a3c30f2b19d32ca3a13cf1da2a5f010e01571
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.8.4](https://github.com/craigulliott/dynamic_migrations/compare/v3.8.3...v3.8.4) (2023-10-06)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* asserting that enum values must be unique strings, and adding ability to add additional enum values ([5cf6093](https://github.com/craigulliott/dynamic_migrations/commit/5cf6093eed96387042f70987c3999b40e4041b76))
|
9
|
+
|
3
10
|
## [3.8.3](https://github.com/craigulliott/dynamic_migrations/compare/v3.8.2...v3.8.3) (2023-10-06)
|
4
11
|
|
5
12
|
|
@@ -13,6 +13,9 @@ module DynamicMigrations
|
|
13
13
|
class ExpectedValuesError < StandardError
|
14
14
|
end
|
15
15
|
|
16
|
+
class ValueAlreadyExistsError < StandardError
|
17
|
+
end
|
18
|
+
|
16
19
|
attr_reader :schema
|
17
20
|
attr_reader :name
|
18
21
|
attr_reader :values
|
@@ -25,8 +28,6 @@ module DynamicMigrations
|
|
25
28
|
|
26
29
|
@columns = []
|
27
30
|
|
28
|
-
@values = []
|
29
|
-
|
30
31
|
raise ExpectedSchemaError, schema unless schema.is_a? Schema
|
31
32
|
@schema = schema
|
32
33
|
|
@@ -36,7 +37,10 @@ module DynamicMigrations
|
|
36
37
|
unless values.is_a?(Array) && values.count > 0
|
37
38
|
raise ExpectedValuesError, "Values are required for enums"
|
38
39
|
end
|
39
|
-
@values =
|
40
|
+
@values = []
|
41
|
+
values.each do |value|
|
42
|
+
add_value value
|
43
|
+
end
|
40
44
|
|
41
45
|
unless description.nil?
|
42
46
|
raise ExpectedStringError, description unless description.is_a? String
|
@@ -45,6 +49,18 @@ module DynamicMigrations
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
52
|
+
def add_value value
|
53
|
+
unless value.is_a? String
|
54
|
+
raise ValueMustBeStringError, "Value `#{value}` must be a string"
|
55
|
+
end
|
56
|
+
|
57
|
+
if @values.include? value
|
58
|
+
raise ValueAlreadyExistsError, "Value `#{value}` already exists in enum `#{name}`"
|
59
|
+
end
|
60
|
+
|
61
|
+
@values << value
|
62
|
+
end
|
63
|
+
|
48
64
|
# returns true if this enum has a description, otehrwise false
|
49
65
|
def has_description?
|
50
66
|
!@description.nil?
|
@@ -16,6 +16,7 @@ module DynamicMigrations
|
|
16
16
|
def full_name: -> Symbol
|
17
17
|
def has_description?: -> bool
|
18
18
|
def add_column: (Schema::Table::Column column) -> void
|
19
|
+
def add_value: (String value) -> void
|
19
20
|
def differences_descriptions: (Enum other_enum) -> Array[String]
|
20
21
|
|
21
22
|
class ExpectedSchemaError < StandardError
|
@@ -23,6 +24,12 @@ module DynamicMigrations
|
|
23
24
|
|
24
25
|
class ExpectedValuesError < StandardError
|
25
26
|
end
|
27
|
+
|
28
|
+
class ValueAlreadyExistsError < StandardError
|
29
|
+
end
|
30
|
+
|
31
|
+
class ValueMustBeStringError < StandardError
|
32
|
+
end
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|