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

cleanup deleted my project #15

Closed
erichanson opened this issue Dec 15, 2020 · 7 comments
Closed

cleanup deleted my project #15

erichanson opened this issue Dec 15, 2020 · 7 comments

Comments

@erichanson
Copy link

The cleanup just deleted my whole project because I set RuntimePath to ./ and apparently the Stop method deletes the entire directory? Luckily version control, but I lost all my certs and an hour or so of work. Cool project, but this was a pretty big surprise and a major foot-gun.

@erichanson
Copy link
Author

Dug into this a bit more. It isn't cleanup that does the deleting, it's the Start() method, which calls os.RemoveAll().

What do you think of the idea of splitting up Start into two methods, one that initializes the new database and one that starts the server? Specifically, I'm trying to use this to persist a simple database across multiple invocations, so that when I run the program a second time, it can check to see if the database already exists, and if so, skip calling the part that initializes it.

@fergusstrange
Copy link
Owner

Apologies for the slow reply!

Yes something like this sounds good. I'd like to maintain backward compatibility and avoid a major version bump however so it might be worth looking into adding something along the lines of StartWithoutClean() and a Clean()?

Best thing to do is get up some code and we can work through it together. I should be a little more speedy on replies now as well into the new year.

Thanks and look forward to seeing what you come up with!

@erichanson
Copy link
Author

erichanson commented Jan 3, 2021

I made some local modifications, just to get it working for myself:

https://github.com/erichanson/embedded-postgres

It was pretty easy, but it isn't backwards compatible though. I'd like to see an API that had all the steps broken out into their own methods:

  • check for existing installation at specified path
  • install the server files
  • check to see if server is running
  • start the server
  • create the database
  • stop the database
  • delete the server

Maybe we could keep the Start() method as a method that calls all the above methods?

@fergusstrange
Copy link
Owner

All of the above sounds very reasonable. Have a crack at manipulating your fork and see if we can come up with something? Assuming all methods are new and the Start() and Stop() API remain unchanged from the surface then this should be backward compatible!

Looking forward to what you come up with and give me a shout if you want to collaborate on the pull request 👍

@fergusstrange
Copy link
Owner

Closing due to inactivity.

Feel free to reopen should you have a crack at opening a PR for this.

@fergusstrange
Copy link
Owner

Hi @erichanson,

Better late than never but this may be of use to you https://github.com/fergusstrange/embedded-postgres/releases/tag/v1.4.0

@erichanson
Copy link
Author

Hey that's great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants