forked from hackclub/api
-
Notifications
You must be signed in to change notification settings - Fork 0
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 hackclub#337 from hackclub/remove-old-fields-from-…
…email Remove video URL and interesting projects questions from new club applications
- Loading branch information
Showing
10 changed files
with
85 additions
and
17 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
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
7 changes: 7 additions & 0 deletions
7
api/db/migrate/20180127045407_add_legacy_fields_to_new_club_applications.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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddLegacyFieldsToNewClubApplications < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :new_club_applications, :legacy_fields, :json | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
api/db/migrate/20180127045814_remove_video_url_from_new_club_applications.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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveVideoUrlFromNewClubApplications < ActiveRecord::Migration[5.1] | ||
class NewClubApplications < ActiveRecord::Base; end | ||
|
||
def up | ||
NewClubApplications.find_each do |app| | ||
if app.leaders_video_url | ||
app.legacy_fields ||= {} | ||
app.legacy_fields['Video URL'] = app.leaders_video_url | ||
app.save | ||
end | ||
end | ||
|
||
remove_column :new_club_applications, :leaders_video_url | ||
end | ||
|
||
def down | ||
add_column :new_club_applications, :leaders_video_url, :text | ||
|
||
NewClubApplications.find_each do |app| | ||
app.legacy_fields ||= {} | ||
|
||
video = app.legacy_fields['Video URL'] | ||
|
||
if video | ||
app.leaders_video_url = video | ||
app.legacy_fields.delete('Video URL') | ||
app.save | ||
end | ||
end | ||
end | ||
end |
37 changes: 37 additions & 0 deletions
37
api/db/migrate/20180127051157_remove_leaders_project_from_new_club_applications.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,37 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveLeadersProjectFromNewClubApplications < ActiveRecord::Migration[5.1] | ||
class NewClubApplications < ActiveRecord::Base; end | ||
|
||
QUESTION = 'Please tell us about an interesting project, preferably outside '\ | ||
'of class, that two or more of you created together. Include URLs if '\ | ||
'possible.' | ||
|
||
def up | ||
NewClubApplications.find_each do |app| | ||
if app.leaders_interesting_project | ||
app.legacy_fields ||= {} | ||
app.legacy_fields[QUESTION] = app.leaders_interesting_project | ||
app.save | ||
end | ||
end | ||
|
||
remove_column :new_club_applications, :leaders_interesting_project | ||
end | ||
|
||
def down | ||
add_column :new_club_applications, :leaders_interesting_project, :text | ||
|
||
NewClubApplications.find_each do |app| | ||
app.legacy_fields ||= {} | ||
|
||
interesting_project = app.legacy_fields[QUESTION] | ||
|
||
if interesting_project | ||
app.leaders_interesting_project = interesting_project | ||
app.legacy_fields.delete(QUESTION) | ||
app.save | ||
end | ||
end | ||
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
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