Skip to content

Instantly share code, notes, and snippets.

@jwpage
Created April 17, 2014 07:05
Show Gist options
  • Save jwpage/10959596 to your computer and use it in GitHub Desktop.
Save jwpage/10959596 to your computer and use it in GitHub Desktop.
Blueprint SQL Execution
diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index 836d013..035dc71 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -58,10 +58,22 @@ class Blueprint {
*/
public function build(Connection $connection, Grammar $grammar)
{
- foreach ($this->toSql($connection, $grammar) as $statement)
- {
- $connection->statement($statement);
- }
+ $this->addImpliedCommands();
+ foreach ($this->commands as $command)
+ {
+ $method = 'compile'.ucfirst($command->name);
+
+ if (method_exists($grammar, $method))
+ {
+ if ( ! is_null($sql = $grammar->$method($this, $command, $connection)))
+ {
+ foreach ((array)$sql as $statement)
+ {
+ $connection->statement($statement);
+ }
+ }
+ }
+ }
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment