-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from packbackbooks/add-statement-batching
Add Statement Batching For PtOnlineSchemaChangeConnection
- Loading branch information
Showing
4 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Daursu\ZeroDowntimeMigration; | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Connection; | ||
use Illuminate\Database\Schema\Grammars\Grammar; | ||
|
||
/** | ||
* A variant of `Blueprint` that allows for connection types to define a `statements` | ||
* method to process an array of SQL query strings at once. For example, pt-online-schema-change | ||
* lets you pass multiple alter operations to be run on the cloned table. | ||
*/ | ||
class BatchableBlueprint extends Blueprint | ||
{ | ||
public function build(Connection $connection, Grammar $grammar) | ||
{ | ||
if (method_exists($connection, 'statements')) { | ||
$statements = $this->toSql($connection, $grammar); | ||
return !empty($statements) ? $connection->statements($statements) : null; | ||
} | ||
|
||
return parent::build($connection, $grammar); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters