-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Doctrine; | ||
|
||
use Doctrine\DBAL\ParameterType; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
/** | ||
* @author dmitry-kulikov | ||
* @see https://github.com/laravel/framework/issues/8840 | ||
*/ | ||
class TinyInteger extends Type | ||
{ | ||
/** | ||
* The name of the custom type. | ||
*/ | ||
public const NAME = 'tinyinteger'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function convertToPHPValue($value, AbstractPlatform $platform) | ||
{ | ||
return $value === null ? null : (int)$value; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string | ||
{ | ||
$unsigned = !empty($column['unsigned']) ? ' UNSIGNED' : ''; | ||
$autoincrement = !empty($column['autoincrement']) ? ' AUTO_INCREMENT' : ''; | ||
|
||
return 'TINYINT' . $unsigned . $autoincrement; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName(): string | ||
{ | ||
return static::NAME; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBindingType(): int | ||
{ | ||
return ParameterType::INTEGER; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
database/migrations/tenant/0.4.0/2023_12_27_021144_change_levels_22.php
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,31 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('levels', function (Blueprint $table) { | ||
// FUCK: Kill Me Please https://github.com/laravel/framework/issues/8840 | ||
$table->tinyInteger('length')->nullable()->change(); | ||
$table->tinyInteger('epic')->nullable()->change(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('levels', function (Blueprint $table) { | ||
$table->unsignedTinyInteger('length')->nullable()->change(); | ||
$table->boolean('epic')->nullable()->change(); | ||
}); | ||
} | ||
}; |