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

Prevent GreenField from being used in production mode #47

Open
daniols opened this issue Feb 11, 2020 · 3 comments
Open

Prevent GreenField from being used in production mode #47

daniols opened this issue Feb 11, 2020 · 3 comments

Comments

@daniols
Copy link

daniols commented Feb 11, 2020

In one of the project that I work on we managed to forget to switch to LiveField before deploying the app to production. Now that we need to change from GreenField to LiveField we don't have a clear way of doing this. It would be nice if we could somehow prevent us, or at least make it a concious choice of the developer, from deploying to production while Galactic Waste is configured with GreenField.

@carl-berg
Copy link
Collaborator

carl-berg commented Feb 11, 2020

Might be hard for GWM to detect if it's running in production or not.

Maybe there needs to be an explicit option to allow clean to make it harder to deploy GreenField to production?

@carl-berg
Copy link
Collaborator

carl-berg commented Feb 11, 2020

Not sure if i know what @mattiasnordqvist intends with #22, but i would assume that it involves deconstructing modes into separate actions so that one could compose what you want the migrator to do. In that case "clean" could maybe become something that is turned on only during development like this

if (env.IsDevelopment())
{
    migrator.EnableClean();
}

@mattiasnordqvist
Copy link
Owner

mattiasnordqvist commented Feb 11, 2020

I'm thinking we could run some checks before doing anything at all.
Maybe some function called IsAllowedToRun() in the abstract field class, if any class like that exists.
The default behaviour of the GreenField-field.IsAllowedToRun() could be to only return true if the actual computer it is running on, or database it is connecting to, can be found in some explicitly declared configuration.

So if I'd like to allow running greenfield on my own personal development computer, I must make sure to pass my sql servers hostname as a parameter, either through console input or a config file.

That way, if my dev-config-file accidently gets deployed to a production server, the configuration of allowed greenfield connectionstrings won't match up with the database it is connected to.

This will require some more initial setup (adding your server-name to the appconfig) before you can start developing, but I think its ok. At least it is better than accidently running greenfields destroy database in production. :)

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

No branches or pull requests

3 participants