Skip to content

Commit

Permalink
Merge pull request #13 from envor/main
Browse files Browse the repository at this point in the history
use migration path if one is set on datastore model
  • Loading branch information
inmanturbo committed Mar 11, 2024
2 parents 50e77ca + 438b2e4 commit eea9530
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to `laravel-datastore` will be documented in this file.

## v1.2.8 - 2024-03-08

### What's Changed

* Bump ramsey/composer-install from 2 to 3 by @dependabot in https://github.com/envor/laravel-datastore/pull/10

### New Contributors

* @dependabot made their first contribution in https://github.com/envor/laravel-datastore/pull/10

**Full Changelog**: https://github.com/envor/laravel-datastore/compare/v1.0.2...v1.2.8

## v1.2.7 - 2024-03-06

### What's Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ return new class extends Migration
$table->id();
$table->uuid('uuid')->index()->unique();
$table->string('name')->index()->unique();
$table->text('migration_path')->nullable();
$table->string('driver');
$table->nullableMorphs('owner');
$table->timestamps();
Expand Down
9 changes: 7 additions & 2 deletions src/Concerns/HasDatastoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ protected static function bootHasDatastoreDriver()
static::creating(function (self $model) {
if (! $model->driver) {
$model->driver = $model::DEFAULT_DRIVER;
// $model->save();
}
$model->createDatabase()->migrate();
});
Expand Down Expand Up @@ -61,6 +60,12 @@ public function migrate()

public function database(): ?Datastore
{
return $this->driver->toNewDatabase($this->name);
$database = $this->driver->toNewDatabase($this->name);

if (isset($this->migration_path)) {
$database->migratePath($this->migration_path);
}

return $database;
}
}

0 comments on commit eea9530

Please sign in to comment.