diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-01-07 18:55:03 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-01-07 18:55:03 +0100 |
commit | 00e2586a42931567d2ac18350d41dd882e7fcd92 (patch) | |
tree | 93f68b2d3307b8f64187444a769a92cebf135caa | |
parent | 66eb0bdf9eb080ab3d8becd7cebe7081ca2a06b4 (diff) | |
download | hmnoweb-00e2586a42931567d2ac18350d41dd882e7fcd92.tar.gz hmnoweb-00e2586a42931567d2ac18350d41dd882e7fcd92.tar.bz2 hmnoweb-00e2586a42931567d2ac18350d41dd882e7fcd92.zip |
Handle non-matching GalleryLink entries inmigration.
-rw-r--r-- | db/migrate/20180107152351_replace_title_with_date_bands_venue.refinery_gallery_links.rb | 12 | ||||
-rw-r--r-- | vendor/extensions/gallery_links/db/migrate/2_replace_title_with_date_bands_venue.rb | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/db/migrate/20180107152351_replace_title_with_date_bands_venue.refinery_gallery_links.rb b/db/migrate/20180107152351_replace_title_with_date_bands_venue.refinery_gallery_links.rb index 86e9dd8..2f79338 100644 --- a/db/migrate/20180107152351_replace_title_with_date_bands_venue.refinery_gallery_links.rb +++ b/db/migrate/20180107152351_replace_title_with_date_bands_venue.refinery_gallery_links.rb @@ -7,9 +7,15 @@ class ReplaceTitleWithDateBandsVenue < ActiveRecord::Migration Refinery::GalleryLinks::GalleryLink.all.each do |g| m = g.title.match /^(.+) (\d{2}\/\d{2}\/\d{2}) @ ([^.]+).$/ - g.date = Date.strptime(m[2], '%d/%m/%y') - g.bands = m[1] - g.venue = m[3] + if m + g.date = Date.strptime(m[2], '%d/%m/%y') + g.bands = m[1] + g.venue = m[3] + else + g.date = Date.today + g.bands = g.title + g.venue = nil + end g.save! end diff --git a/vendor/extensions/gallery_links/db/migrate/2_replace_title_with_date_bands_venue.rb b/vendor/extensions/gallery_links/db/migrate/2_replace_title_with_date_bands_venue.rb index 01bb932..87492b6 100644 --- a/vendor/extensions/gallery_links/db/migrate/2_replace_title_with_date_bands_venue.rb +++ b/vendor/extensions/gallery_links/db/migrate/2_replace_title_with_date_bands_venue.rb @@ -6,9 +6,15 @@ class ReplaceTitleWithDateBandsVenue < ActiveRecord::Migration Refinery::GalleryLinks::GalleryLink.all.each do |g| m = g.title.match /^(.+) (\d{2}\/\d{2}\/\d{2}) @ ([^.]+).$/ - g.date = Date.strptime(m[2], '%d/%m/%y') - g.bands = m[1] - g.venue = m[3] + if m + g.date = Date.strptime(m[2], '%d/%m/%y') + g.bands = m[1] + g.venue = m[3] + else + g.date = Date.today + g.bands = g.title + g.venue = nil + end g.save! end |