DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

Data Migration in Active Storage after changing the Model name

πŸ€” What does it mean about 'run a migration'

According to Rails Guide, it says

Alt Text

β˜•οΈ My Situation

I changed my model name

  • From: Media
  • To: Medium

Then

All of the objects had not had any attachment.

🧐 WHY?

ActiveStrage is the polymorphic model. So, the records were still looking at the old model. Then, the association is cut.

πŸ”§Treatment from Rails Console

ActiveStorage::Attachment.where(record_type: "Media").update(record_type: "Medium")

Top comments (0)