caboose-cms 0.2.102 → 0.2.103
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 +8 -8
- data/app/models/caboose/utilities/schema.rb +6 -32
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzU1NTA3NjgwNTZiODk5YjU1NmNiYTdkYmUwYTllYjFlMjNhYzcxMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTRlZWMxNTYxYzQ0ZDU3YjkwYTJlZDRhMDczOWI2ZmU5MzJjODM3Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGYxMjVkOGJjNTlmYzJlODIxODcyMmU1MjNkZTMxMjMwMTFjOTMwZWM0OWQx
|
10
|
+
NjZiZTM0ZDM0NWMxZTI0NGY5NTRlZGVhNzA2OTM3NGNkZTNmYmRhZDc0NjY2
|
11
|
+
NzYwN2E0ZDk5MmQxMGVhNWEyNmZkZDc5NDM1MmNhMTE4NTJkNWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmE4MDlhMDEzNWZlZjZkZmU5ZDFhNjcyNTJjNzI0ZTAwYTM2N2Q1NjJlYjk2
|
14
|
+
ODQ0MzAxNDlhZjBmMjY2YzYwZGZhZTE1ZmNmMmI0OWI1ZTFmNTNjN2ViYjI1
|
15
|
+
M2E1N2MxMTNmNThiZjBjNGRjOTk0ZjQzMGUzMDRlMWFjZTQ3ZTk=
|
@@ -34,8 +34,7 @@ class Caboose::Utilities::Schema
|
|
34
34
|
def self.create_schema
|
35
35
|
return if self.schema.nil?
|
36
36
|
|
37
|
-
rename_tables
|
38
|
-
remove_columns
|
37
|
+
rename_tables
|
39
38
|
|
40
39
|
c = ActiveRecord::Base.connection
|
41
40
|
self.schema.each do |model, columns|
|
@@ -57,39 +56,14 @@ class Caboose::Utilities::Schema
|
|
57
56
|
end
|
58
57
|
|
59
58
|
# Column exists, but not with the correct data type, try to change it
|
60
|
-
else
|
61
|
-
|
59
|
+
else
|
62
60
|
c.execute("alter table #{tbl} alter column #{col[0]} type #{col[1]} using cast(#{col[0]} as #{col[1]})")
|
63
|
-
|
64
|
-
# Add a temp column
|
65
|
-
#c.remove_column tbl, "#{col[0]}_temp" if c.column_exists?(tbl, "#{col[0]}_temp")
|
66
|
-
#if col.count > 2
|
67
|
-
# c.add_column tbl, "#{col[0]}_temp", col[1], col[2]
|
68
|
-
#else
|
69
|
-
# c.add_column tbl, "#{col[0]}_temp", col[1]
|
70
|
-
#end
|
71
|
-
|
72
|
-
# Copy the old column and cast with correct data type to the new column
|
73
|
-
#model.all.each do |m|
|
74
|
-
# m["#{col[0]}_temp"] = case col[1]
|
75
|
-
# when :integer then m[col[0]].to_i
|
76
|
-
# when :string then m[col[0]].to_s
|
77
|
-
# when :text then m[col[0]].to_s
|
78
|
-
# when :numeric then m[col[0]].to_f
|
79
|
-
# when :datetime then DateTime.parse(m[col[0]])
|
80
|
-
# when :boolean then m[col[0]].to_i == 1
|
81
|
-
# else nil
|
82
|
-
# end
|
83
|
-
# m.save
|
84
|
-
#end
|
85
|
-
|
86
|
-
# Remove the old column and rename the new one
|
87
|
-
#c.remove_column tbl, col[0]
|
88
|
-
#c.rename_column tbl, "#{col[0]}_temp", col[0]
|
89
61
|
|
90
62
|
end
|
91
63
|
end
|
92
|
-
end
|
64
|
+
end
|
65
|
+
|
66
|
+
remove_columns
|
93
67
|
create_indexes
|
94
68
|
|
95
69
|
self.schema.each do |model, columns|
|
@@ -104,7 +78,7 @@ class Caboose::Utilities::Schema
|
|
104
78
|
self.indexes.each do |table, indexes|
|
105
79
|
indexes.each do |index|
|
106
80
|
c.add_index table, index if !c.index_exists?(table, index)
|
107
|
-
end
|
81
|
+
end
|
108
82
|
end
|
109
83
|
end
|
110
84
|
|
data/lib/caboose/version.rb
CHANGED