adamnet's avatar

Delete migration file in project. Way to restore?

Earlier today I created a migration file for creating a table with a lot of columns, foreign keys etc. Accidentally I deleted it. Is there any way to restore it? Is there a recycle bin into the project?

0 likes
8 replies
tykus's avatar

Was it ever commited in git?

Otherwise, if using PHPStorm, there is a Local History in File >> Local History >> Show History. Other editors/IDEs may have a similar feature?

adamnet's avatar

I use Visual Studio Code editor. There is an option there: Open the Command Palette by pressing Cmd+Shift+P Paste the phrase "Local History: Find Entry to Restore" . I could not find the file Thanks for answering.

tykus's avatar

Not sure how VS Code handles local history... any chance that you had committed the file to git?

shez1983's avatar

but it sounds like h e was working on it and didnt get a chance to save/upload it - in which case git wouldnt have helped..

JussiMannisto's avatar

@shez1983 The term here is commit. You don't need to upload changes anywhere as long as you get in the habit of committing frequently.

@adamnet It looks like VSCode has this feature, sort of. Type CTRL/CMD + P, and find "Local history: Find Entry to Restore". You should find your file contents there. Unlike in PHPStorm, it doesn't look like you can straight up restore the file from history (the IDE gets confused because the file doesn't exist), but at least you can copy the contents and re-create it.

martinbean's avatar

No, I do not use git at all.

@adamnet May I suggest you start doing so? And it will save you in situations like this.

Please or to participate in this conversation.