-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations to remove Drupal gallery and integrate into node revision #11371
Migrations to remove Drupal gallery and integrate into node revision #11371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Have you tested it out, did you need to test it in unstable or anything?
Restarted the system test which was a random container crash. |
This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here: |
This is ready to merge if @anirudhprabhakaran3 gives a +1 on the testing/stable question! |
Yeah, I'll test it on unstable in a few minutes. I was also wondering if I should remove the |
If you like, go ahead, but I think 2 PRs is fine too! |
Just let me know what you decide and we can merge this whenever you're ready. Great work! |
Codecov Report
@@ Coverage Diff @@
## main #11371 +/- ##
==========================================
- Coverage 82.46% 82.41% -0.06%
==========================================
Files 98 97 -1
Lines 5999 5975 -24
==========================================
- Hits 4947 4924 -23
+ Misses 1052 1051 -1
|
This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here: |
Code Climate has analyzed commit 98fcb49 and detected 0 issues on this pull request. View more on Code Climate. |
This pull request generated screenshots of many common pages in the running app. You should be able to download and view them here: |
Hi! I think we can review, test and merge this MR now. I think I've removed all the related dependencies now. Sorry for the delay! |
Hi @anirudhprabhakaran3 i'd like to try but i want to check on stable once we merge it. What is an example page of where on the live site we use the image gallery, so I can confirm it still displays the images after we merge this on stable? |
https://stable.publiclab.org/notes/eymund-diegel/10-26-2012/hello-kitty-watchdog-patrols-gowanus-canal-skies didn't work, strangely, even before stable began to build. |
The error in stable is due to a migration:
Do we need to run the migration first, then in a second PR, remove the 'gallery' method? |
.order('field_image_gallery_fid') | ||
end | ||
|
||
def gallery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here, we are actually removing the method we need to use in the migration. We can use the definition itself to resolve this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we'll have to be sure it runs all together -- this PRs commit, and the new changes, and gets built in a container all together. Because it will fail if they are done in 2 different builds.
Node.all.each do |node| | ||
new_revision = node.revisions.first.dup | ||
gallery_images = "" | ||
node.gallery.each do |image| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I changed this and directly referenced it as node&.drupal_content_field_image_gallery.each do |image|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And noting the fixes @anirudhprabhakaran3 had added in this PR too: #11393
Oh darn, that didn't work.
|
@@ -359,20 +359,6 @@ def scraped_image | |||
match&.split('src="')&.last&.split('"')&.first | |||
end | |||
|
|||
# was unable to set up this relationship properly with ActiveRecord associations | |||
def drupal_content_field_image_gallery | |||
DrupalContentFieldImageGallery.where(nid: nid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah its because that was also not a built-in method - we deleted it too! OK, will adapt to this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, here it is:
gallery = DrupalContentFieldImageGallery.where(nid: node.nid) | |
.order('field_image_gallery_fid') | |
gallery.each do |image| | |
html = "<a target='_blank' href='#{image&.image&.path(:original)}'><img rel='tooltip' data-title='#{image&.description}' style='margin-bottom:4px;' class='rounded' src='#{image&.image&.path(:thumb)}' /></a>" | |
gallery_images << html unless image.nil? || image.image.nil? || image.image.path.nil? | |
end |
:-( == 20220828142008 RemoveDrupalGalleryFromNode: migrating ======================
|
I'm not sure why that didn't work. I'll check the schema and see if the following migration somehow got run, which would have eliminated that class? |
@@ -1,27 +0,0 @@ | |||
require 'php_serialize' | |||
|
|||
class DrupalContentFieldImageGallery < ApplicationRecord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I think it didn't work because we deleted this entire file. So we either need to re-add it, or we need to do raw SQL. I think I will re-add this file so that the migration can succeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phew, a lot of editing on main, but fingers X this works: cb073ae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…tion can complete follow-up to #11371
OK, we'll need a few more files.
|
Oof, ok, so i'm just going to check for existence of all necessary fields before: Didn't need to re-add more files, just more nil checks. |
Another error - this time, a validation error, which I think means we're close:
|
https://ci-j.publiclab.org/job/Plots-Stable/3313/console - odd, same error. |
That's odd. It's pretty clear here:
|
So, I think what's happening is that the validation will not allow space characters... but a body of " " (one or more spaces) still reads as not |
Hmm, no, that doesn't seem right -- I checked the output of all 21 records where body is "" (from the total nids here), and all are just empty. Anyways I tried just changing all to |
Strangely it didn't seem to try to run migrations: https://ci-j.publiclab.org/job/Plots-Stable/3315/console I may need to trigger it with a new PR merge. |
No, it did build, but no, it also didn't work. Same error. I'm going to insert a log comment in the migration. If that doesn't work, I will try manually running the migration in the Rails console before doing more. |
OK, i believe I found it:
So there, it's not empty, but it is whitespace. OK, trying again, this time it got stuck on |
Error:
|
Tracking that here: #11355 (comment) |
OK, that's resolved. Phew. Sorry @anirudhprabhakaran3 that was a really involved process but it highlights the challenges of removing infrastructure in the correct order. I'm glad we finally got that done, and apologies for making several commits to main, that is really not typical of the process we want, but I kept thinking we were just about to solve it. No harm done, and next time we should more thoroughly test the process on unstable. Thanks for your patience! |
Also i had to add the absolute hostnames to the page in the dev console to see them. They had all pointed back at stable.publiclab.org instead of publiclab.org, but when i changed it, they all appeared. Great!!! |
Fixes #4074
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowThis PR for now only makes the migration from Drupal Galleries to Node revisions. In another commit, I'll add the migration for the removal of the table itself.
CC: #11185