diff options
Diffstat (limited to 'src/Database/Migration')
-rw-r--r-- | src/Database/Migration/Migrate.php | 40 | ||||
-rw-r--r-- | src/Database/Migration/MigrationServiceProvider.php | 11 |
2 files changed, 27 insertions, 24 deletions
diff --git a/src/Database/Migration/Migrate.php b/src/Database/Migration/Migrate.php index 3a08bb6e..9c6d3e43 100644 --- a/src/Database/Migration/Migrate.php +++ b/src/Database/Migration/Migrate.php @@ -18,7 +18,7 @@ class Migrate protected $app; /** @var SchemaBuilder */ - protected $scheme; + protected $schema; /** @var callable */ protected $output; @@ -29,13 +29,13 @@ class Migrate /** * Migrate constructor * - * @param SchemaBuilder $scheme + * @param SchemaBuilder $schema * @param Application $app */ - public function __construct(SchemaBuilder $scheme, Application $app) + public function __construct(SchemaBuilder $schema, Application $app) { $this->app = $app; - $this->scheme = $scheme; + $this->schema = $schema; $this->output = function () { }; } @@ -77,6 +77,21 @@ class Migrate } /** + * Setup migration tables + */ + public function initMigration() + { + if ($this->schema->hasTable($this->table)) { + return; + } + + $this->schema->create($this->table, function (Blueprint $table) { + $table->increments('id'); + $table->string('migration'); + }); + } + + /** * Get all migrated migrations * * @return Collection @@ -156,28 +171,13 @@ class Migrate } /** - * Setup migration tables - */ - protected function initMigration() - { - if ($this->scheme->hasTable($this->table)) { - return; - } - - $this->scheme->create($this->table, function (Blueprint $table) { - $table->increments('id'); - $table->string('migration'); - }); - } - - /** * Init a table query * * @return Builder */ protected function getTableQuery() { - return $this->scheme->getConnection()->table($this->table); + return $this->schema->getConnection()->table($this->table); } /** diff --git a/src/Database/Migration/MigrationServiceProvider.php b/src/Database/Migration/MigrationServiceProvider.php index 15d06eaf..310b2114 100644 --- a/src/Database/Migration/MigrationServiceProvider.php +++ b/src/Database/Migration/MigrationServiceProvider.php @@ -3,16 +3,19 @@ namespace Engelsystem\Database\Migration; use Engelsystem\Container\ServiceProvider; -use Engelsystem\Database\Db; +use Engelsystem\Database\Database; use Illuminate\Database\Schema\Builder as SchemaBuilder; class MigrationServiceProvider extends ServiceProvider { public function register() { - $schema = Db::connection()->getSchemaBuilder(); - $this->app->instance('db.scheme', $schema); - $this->app->bind(SchemaBuilder::class, 'db.scheme'); + /** @var Database $database */ + $database = $this->app->get(Database::class); + $schema = $database->getConnection()->getSchemaBuilder(); + + $this->app->instance('db.schema', $schema); + $this->app->bind(SchemaBuilder::class, 'db.schema'); $migration = $this->app->make(Migrate::class); $this->app->instance('db.migration', $migration); |