welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 165 forks source link

Prevent database push #113

Closed Boztown closed 9 years ago

Boztown commented 9 years ago

Is there any option in the Movefile or a simple hack I could introduce to basically disable the "push" command for the database? I love being able to pull the database and pushing it up is handy initially but could be really dangerous for my team at a certain point.

alessandro-fazzi commented 9 years ago

Hey @Boztown,

you're interested in disable the command even if called by command line? Mmmmhhhhh...you could try to monkey patch the push method in cli.rb w/ something like

    def push
      deployer = Wordmove::Deployer::Base.deployer_for(options)
      handle_options(options) do |task|
        deployer.send("push_#{task}") unless task == 'db'
      end
    end

I can't test it at this time, sorry. @delphaber your opinion?

Boztown commented 9 years ago

Yeah, I'm just thinking about a team working on something. The other methods would be safe enough if you were using source control but often there comes a point where a client or project manager begins to enter data into the dev/stage site. At that point I usually put a halt on pushing the database and we're forced to move up settings and other non-content db data manually. With Wordmove I'm afraid a dev will run "wordmove push --db" out of habit (or reverse search on the command-line) and wipe the content. I do realize there are back-ups made.

I guess I'm thinking a setting in the Movefile like "allow_db_push: true/false" for a particular environment would be cool. Maybe it's too specific to my needs. I'll see if I can add that to a fork and you can take a look.

alessandro-fazzi commented 9 years ago

@Boztown I understand your thoughts and needs.

Having a pull request would be great for such implementation, but I'd follow a more generic approach in order to avoid implementing specs chained to a single need. For example, imagine in the Movefile:

- deny_commands
  - push
    - db

and in the right class (consider it as just pseudo-code):

def push
  deployer = Wordmove::Deployer::Base.deployer_for(options)
  handle_options(options) do |task|
    unless options[:deny_commands][:push].include? task do
      deployer.send("push_#{task}") unless 
    end
  end
end

Taking apart the engineering: that way we'll have a generic implementation to disallow arbitrary commands.

I hope I've been a little inspiring :)

Keep us tuned in

Cheers

alessandro-fazzi commented 9 years ago

I'll close this due to inactivity, but always ready to see a PR happen :)

essenmitsosse commented 7 years ago

I would still find this feature super handy. Would be great if someone could implement it.