-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add empty WHN markdown field and update existing live forms
- Loading branch information
1 parent
8614f9c
commit bb55502
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
db/migrate/20231116142411_add_what_happens_next_markdown_to_forms.rb
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,23 @@ | ||
class AddWhatHappensNextMarkdownToForms < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :forms, :what_happens_next_markdown, :text | ||
|
||
reversible do |direction| | ||
Form.find_each do |form| | ||
if form.made_live_forms.present? | ||
made_live_form = form.made_live_forms.last | ||
form_blob = JSON.parse(made_live_form.json_form_blob, symbolize_names: true) | ||
|
||
direction.up do | ||
form_blob[:what_happens_next_markdown] = nil | ||
end | ||
direction.down do | ||
form_blob.delete(:what_happens_next_markdown) | ||
end | ||
|
||
made_live_form.update!(json_form_blob: form_blob.to_json) | ||
end | ||
end | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.