mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-01 19:27:39 +08:00
Added Blueprint::charset()
and Blueprint::collation()
. (#7070)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
f2a5d3e90e
commit
e42bc9676f
@ -3,6 +3,7 @@
|
||||
## Added
|
||||
|
||||
- [#7063](https://github.com/hyperf/hyperf/pull/7063) Added methods `nullableUuidMorphs` `uuidMorphs` and `nullableNumericMorphs` to `Hyperf\Database\Schema\Blueprint`.
|
||||
- [#7070](https://github.com/hyperf/hyperf/pull/7070) Added `Blueprint::charset()` and `Blueprint::collation()`.
|
||||
- [#7071](https://github.com/hyperf/hyperf/pull/7071) Added `Hyperf\Database\Schema\Blueprint::tinyText()`.
|
||||
|
||||
# v3.1.43 - 2024-10-10
|
||||
|
@ -120,6 +120,22 @@ class Blueprint
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the character set that should be used for the table.
|
||||
*/
|
||||
public function charset(string $charset): void
|
||||
{
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the collation that should be used for the table.
|
||||
*/
|
||||
public function collation(string $collation): void
|
||||
{
|
||||
$this->collation = $collation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw SQL statements for the blueprint.
|
||||
*
|
||||
|
@ -216,6 +216,21 @@ class MySqlSchemaGrammarTest extends TestCase
|
||||
|
||||
$this->assertCount(1, $statements);
|
||||
$this->assertSame("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) character set utf8mb4 collate 'utf8mb4_unicode_ci' not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);
|
||||
|
||||
$blueprint = new Blueprint('users');
|
||||
$blueprint->create();
|
||||
$blueprint->increments('id');
|
||||
$blueprint->string('email');
|
||||
$blueprint->charset('utf8mb4');
|
||||
$blueprint->collation('utf8mb4_unicode_ci');
|
||||
|
||||
$conn = $this->getConnection();
|
||||
$conn->shouldReceive('getConfig')->once()->with('engine')->andReturn(null);
|
||||
|
||||
$statements = $blueprint->toSql($conn, $this->getGrammar());
|
||||
|
||||
$this->assertCount(1, $statements);
|
||||
$this->assertSame("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'", $statements[0]);
|
||||
}
|
||||
|
||||
public function testBasicCreateTableWithPrefix()
|
||||
|
Loading…
Reference in New Issue
Block a user