@@ -42,6 +42,24 @@ public function __construct(EntityManagerInterface $em, GitService $git, $kernel
4242 $ this ->fs = new Filesystem ();
4343 }
4444
45+ public function getDumpPath ($ hash )
46+ {
47+ $ outFolder = sprintf ('%s/../var/git-doctrine-migration ' , $ this ->kernelRootDir );
48+
49+ if (!$ this ->fs ->exists ($ outFolder )) {
50+ $ this ->fs ->mkdir ($ outFolder , 0700 );
51+ }
52+
53+ $ outPath = sprintf ('%s/%s.sql ' , $ outFolder , $ hash );
54+
55+ return $ outPath ;
56+ }
57+
58+ public function dumpExists ($ hash )
59+ {
60+ return $ this ->fs ->exists ($ this ->getDumpPath ($ hash ));
61+ }
62+
4563 /**
4664 * Dump
4765 */
@@ -55,13 +73,7 @@ public function dump()
5573
5674 $ currentHash = $ this ->git ->getCurrentHash ();
5775
58- $ outFolder = sprintf ('%s/../var/git-doctrine-migration ' , $ this ->kernelRootDir );
59-
60- if (!$ this ->fs ->exists ($ outFolder )) {
61- $ this ->fs ->mkdir ($ outFolder , 0700 );
62- }
63-
64- $ outPath = sprintf ('%s/%s.sql ' , $ outFolder , $ currentHash );
76+ $ outPath = $ this ->getDumpPath ($ currentHash );
6577
6678 $ command = sprintf (
6779 'mysqldump --user="%s" --password="%s" --host="%s" "%s" > "%s" ' ,
@@ -84,7 +96,7 @@ public function restore($filePath, $force = true)
8496 $ database = $ connection ->getDatabase ();
8597
8698 $ command = sprintf (
87- 'mysql -u "%s" -p "%s" -h "%s" %s "%s" < "%s" ' ,
99+ 'mysql --user= "%s" --password= "%s" --host= "%s" %s "%s" < "%s" ' ,
88100 $ user ,
89101 $ password ,
90102 $ host ,
@@ -93,8 +105,6 @@ public function restore($filePath, $force = true)
93105 $ filePath
94106 );
95107
96- die (dump ($ command ));
97-
98108 exec ($ command );
99109 }
100110}
0 commit comments