-
Notifications
You must be signed in to change notification settings - Fork 15
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
2 changed files
with
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
*/ | ||
class Migration extends \yii\db\Migration | ||
{ | ||
use SchemaBuilderTrait; | ||
|
||
public $db = 'clickhouse'; | ||
|
||
|
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,25 @@ | ||
<?php | ||
|
||
namespace bashkarev\clickhouse; | ||
|
||
/** | ||
* Schema builder trait | ||
* | ||
* Provides some shortcuts for specific clickhouse data types and etc. | ||
* | ||
* @see \yii\db\SchemaBuilderTrait For better understanding about logic of this trait | ||
* @method \yii\db\Connection getDb() | ||
*/ | ||
trait SchemaBuilderTrait | ||
{ | ||
/** | ||
* Creates an UUID column | ||
* | ||
* @return ColumnSchemaBuilder | ||
* @see https://clickhouse.tech/docs/en/sql-reference/data-types/uuid/ For more information about UUID columns | ||
*/ | ||
public function uuid(): ColumnSchemaBuilder | ||
{ | ||
return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_UUID); | ||
} | ||
} |