-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: auto add content column to table if not present
- Loading branch information
1 parent
a1bc247
commit f5bce3f
Showing
6 changed files
with
56 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Orbit\Contracts; | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
interface ModifiesSchema | ||
{ | ||
public function schema(Blueprint $table): void; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Orbit\Support; | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\ColumnDefinition; | ||
|
||
/** @internal */ | ||
class BlueprintUtilities | ||
{ | ||
public static function hasColumn(Blueprint $table, string $column): bool | ||
{ | ||
return collect($table->getColumns())->contains(static fn (ColumnDefinition $definition): bool => $definition->name === $column); | ||
} | ||
} |
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,11 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Orbit\Support\BlueprintUtilities; | ||
|
||
it('can determine column existence in blueprint', function () { | ||
$blueprint = new Blueprint('test'); | ||
$blueprint->text('content')->nullable(); | ||
|
||
expect(BlueprintUtilities::hasColumn($blueprint, 'content'))->toBeTrue(); | ||
}); |