Skip to content

Commit 13bbe1a

Browse files
committed
Update createTables issue
1 parent 55298c0 commit 13bbe1a

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

src/Drivers/MysqlDumper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public function prepareQuick()
172172
return $this->quick ? '--quick' : '';
173173
}
174174

175+
public function prepareCreateTables()
176+
{
177+
return !$this->createTables ? '--no-create-info' : '';
178+
}
179+
175180
public function prepareSkipComments()
176181
{
177182
return $this->skipComments ? '--skip-comments' : '';

src/Drivers/PgsqlDumper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ protected function runCommand()
108108
}
109109
}
110110

111+
public function prepareCreateTables()
112+
{
113+
return (!$this->createTables) ? '--data-only' : '';
114+
}
115+
111116
public function prepareUseInserts()
112117
{
113118
return ($this->useInserts) ? '--inserts' : '';

src/Dumper.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,44 +61,6 @@ protected function run()
6161
abstract public function dump();
6262
abstract public function restore();
6363

64-
public function getDumpCommand(string $credentialFile = '', $destinationPath = '')
65-
{
66-
$destinationPath = !empty($destinationPath) ? $destinationPath : $this->destinationPath;
67-
switch (strtolower($this->getDumperClassName())) {
68-
case 'mysqldumper':
69-
$dumpCommand = $this->prepareDumpCommand($credentialFile, $destinationPath);
70-
break;
71-
default:
72-
$dumpCommand = $this->prepareDumpCommand($destinationPath);
73-
break;
74-
}
75-
76-
return $this->removeExtraSpaces($dumpCommand);
77-
}
78-
79-
public function getRestoreCommand(string $credentialFile = '', string $filePath = '')
80-
{
81-
$filePath = !empty($filePath) ? '"' . $filePath : $this->restorePath;
82-
switch (strtolower($this->getDumperClassName())) {
83-
case 'mysqldumper':
84-
$restoreCommand = $this->prepareRestoreCommand($credentialFile, $filePath);
85-
break;
86-
default:
87-
$restoreCommand = $this->prepareRestoreCommand($filePath);
88-
break;
89-
}
90-
91-
return $this->removeExtraSpaces($restoreCommand);
92-
}
93-
94-
public function getDumperClassName()
95-
{
96-
$classWithNamespace = static::class;
97-
$partials = explode("\\", $classWithNamespace);
98-
$className = end($partials);
99-
return $className;
100-
}
101-
10264
public function removeExtraSpaces(string $str)
10365
{
10466
return preg_replace('/\s+/', ' ', $str);

src/Traits/PrepareOptionsTrait.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,41 @@ public function prepareIgnoreTables()
7878
}
7979
}
8080

81-
public function prepareCreateTables()
81+
public function getDumpCommand(string $credentialFile = '', $destinationPath = '')
8282
{
83+
$destinationPath = !empty($destinationPath) ? $destinationPath : $this->destinationPath;
8384
switch (strtolower($this->getDumperClassName())) {
8485
case 'mysqldumper':
85-
return !$this->createTables ? '--no-create-info' : '';
86-
case 'pgsqldumper':
87-
return (!$this->createTables) ? '--data-only' : '';
86+
$dumpCommand = $this->prepareDumpCommand($credentialFile, $destinationPath);
87+
break;
88+
default:
89+
$dumpCommand = $this->prepareDumpCommand($destinationPath);
90+
break;
91+
}
92+
93+
return $this->removeExtraSpaces($dumpCommand);
94+
}
95+
96+
public function getRestoreCommand(string $credentialFile = '', string $filePath = '')
97+
{
98+
$filePath = !empty($filePath) ? '"' . $filePath : $this->restorePath;
99+
switch (strtolower($this->getDumperClassName())) {
100+
case 'mysqldumper':
101+
$restoreCommand = $this->prepareRestoreCommand($credentialFile, $filePath);
102+
break;
103+
default:
104+
$restoreCommand = $this->prepareRestoreCommand($filePath);
105+
break;
88106
}
107+
108+
return $this->removeExtraSpaces($restoreCommand);
109+
}
110+
111+
public function getDumperClassName()
112+
{
113+
$classWithNamespace = static::class;
114+
$partials = explode("\\", $classWithNamespace);
115+
$className = end($partials);
116+
return $className;
89117
}
90118
}

0 commit comments

Comments
 (0)