File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Drush \Commands ;
4+
5+ use Consolidation \AnnotatedCommand \CommandData ;
6+
7+ /**
8+ * Edit this file to reflect your organization's needs.
9+ */
10+ class PolicyCommands extends DrushCommands {
11+
12+ /**
13+ * Prevent catastrophic braino. Note that this file has to be local to the
14+ * machine that initiates the sql:sync command.
15+ *
16+ * @hook validate sql:sync
17+ *
18+ * @throws \Exception
19+ */
20+ public function sqlSyncValidate (CommandData $ commandData ) {
21+ if ($ commandData ->input ()->getArgument ('target ' ) == '@live ' ) {
22+ throw new \Exception (dt ('Per !file, you may never overwrite the production database. ' , ['!file ' => __FILE__ ]));
23+ }
24+ }
25+
26+ /**
27+ * Limit rsync operations to production site.
28+ *
29+ * @hook validate core:rsync
30+ *
31+ * @throws \Exception
32+ */
33+ public function rsyncValidate (CommandData $ commandData ) {
34+ if (preg_match ("/^@live/ " , $ commandData ->input ()->getArgument ('target ' ))) {
35+ throw new \Exception (dt ('Per !file, you may never rsync to the production site. ' , ['!file ' => __FILE__ ]));
36+ }
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments