-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from aploshay/POD-1795_serialized_fields
[POD-1795] reconfigure serialized fields
- Loading branch information
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class MemnonInvoiceSubmission < ActiveRecord::Base | ||
serialize :problems_by_row | ||
serialize :problems_by_row, JSON | ||
validates :filename, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AddSerializedFields < ActiveRecord::Migration | ||
def up | ||
add_column :memnon_invoice_submissions, :problems_by_row_json, :text, limit: 4294967295 | ||
add_column :digital_statuses, :options_json, :text, limit: 65535 | ||
end | ||
def down | ||
remove_column :memnon_invoice_submissions, :problems_by_row_json | ||
remove_column :digital_statuses, :options_json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class PopulateSerializedFields < ActiveRecord::Migration | ||
def up | ||
puts "Populating MemnonInvoiceSubmission: #{MemnonInvoiceSubmission.count}" | ||
MemnonInvoiceSubmission.find_in_batches.with_index do |group, batch| | ||
puts "processing batch #{batch}" | ||
group.each_with_index do |mis, i| | ||
puts "#{i+1}: #{mis.id}" | ||
mis.problems_by_row_json = mis.problems_by_row | ||
mis.save! | ||
end | ||
end | ||
puts "Populating DigitalStatus: #{DigitalStatus.count}" | ||
DigitalStatus.find_in_batches.with_index do |group, batch| | ||
puts "processing batch #{batch}" | ||
group.each_with_index do |ds, i| | ||
puts "#{i+1}: #{ds.id}" | ||
ds.options_json = ds.options | ||
ds.save! | ||
end | ||
end | ||
end | ||
def down | ||
puts "no action on rollback" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class RenameSerializedFields < ActiveRecord::Migration | ||
def up | ||
rename_column :memnon_invoice_submissions, :problems_by_row, :problems_by_row_yaml | ||
rename_column :memnon_invoice_submissions, :problems_by_row_json, :problems_by_row | ||
rename_column :digital_statuses, :options, :options_yaml | ||
rename_column :digital_statuses, :options_json, :options | ||
end | ||
def down | ||
rename_column :memnon_invoice_submissions, :problems_by_row, :problems_by_row_json | ||
rename_column :memnon_invoice_submissions, :problems_by_row_yaml, :problems_by_row | ||
rename_column :digital_statuses, :options, :options_json | ||
rename_column :digital_statuses, :options_yaml, :options | ||
end | ||
end |