Skip to content
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

Delete orphaned reference author names #706

Closed
1 task done
jonkerz opened this issue Jun 5, 2019 · 1 comment
Closed
1 task done

Delete orphaned reference author names #706

jonkerz opened this issue Jun 5, 2019 · 1 comment
Labels
Milestone

Comments

@jonkerz
Copy link
Member

jonkerz commented Jun 5, 2019

Only old cases. There should be no new cases after 68739cd

These: ReferenceAuthorName.where.not(reference_id: Reference.select(:id)).count # ~250

  • Run script
jonkerz = User.find 60
Activity.execute_script_activity jonkerz, "Delete orphaned reference author names, see %github706"

# For PaperTrail
antcat_bot = User.find 62
PaperTrail.whodunnit = antcat_bot.id

# For the activity feed
User.current = antcat_bot

class ReferenceAuthorNameObserver
  def before_destroy _
    # Suppress `reference_author_name.reference.invalidate_caches`
  end
end

ReferenceAuthorName.where.not(reference_id: Reference.select(:id)).each(&:destroy)
@jonkerz jonkerz added the script label Jun 5, 2019
@jonkerz jonkerz changed the title [WIP] Remove orphaned reference author names Remove orphaned reference author names Jun 5, 2019
@jonkerz jonkerz changed the title Remove orphaned reference author names Delete orphaned reference author names Jun 7, 2019
@jonkerz
Copy link
Member Author

jonkerz commented Jun 7, 2019

@jonkerz jonkerz closed this as completed Jun 7, 2019
@jonkerz jonkerz added this to the 3.0.35 milestone Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant