Rebuild upload links?

(Stephen Chung) #1

Is there a way to “rebuild” the uploads and post_uploads tables?

For example, I have a whole bunch of video files moved to tombstone for some reason. I have moved the files back, but I fear that they’ll get removed again.

I checked uploads and post_uploads and the records are no longer there. No idea as to cause. (Perhaps me using the Azure Blob Plugin is a reason).

So, if I know that an upload exists, how can I manually rebuild those records?

And how do I manually relink them via post_uploads so that they won’t be removed again?

Azure Blob Storage Plugin
(Régis Hanol) #2

Rebake the posts. It will rebuild the post_uploadslinks”.

(Stephen Chung) #3

No it doesn’t.

Not if the entry in uploads no longer exists. Obviously post_uploads will not be created.

(Mittineague) #4

Is that a “no it doesn’t” I don’t think it will, or a “no it doesn’t” I did try that and it didn’t?

(Stephen Chung) #5

That is a “no it doesn’t because that was the first thing I tried.”

(Régis Hanol) #6

Yeah, if there’s no upload records then there won’t be any post_uploads.

How did you restore the uploads from the tombstone? Did you use the rake task?

(Stephen Chung) #7

Well… :sweat_smile: I just copied them…

Do you mean I can use a rake task to restore the uploads records also?

(Régis Hanol) #8

Yup, it’s called “uploads:recover_from_tombstone”.

(Stephen Chung) #9

This task only works for internal storages.

Sorry, I am using Azure Blob Storage.

(Régis Hanol) #11

My bad. In that case, you’d have to write some code to restore the uploads.

(Stephen Chung) #12

It should be a simple matter to strip out the copying step? I’m not sure how to do that…

(Stephen Chung) #13

So now the PR is merged to prevent missing uploaded file links, can some kind soul please help me write a ruby or psql script to rebuild the missing upload links?