Skip to content

Commit

Permalink
Added SchemaBuilderTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
zkelo committed Sep 16, 2021
1 parent 4d6a942 commit cbeb6df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class Migration extends \yii\db\Migration
{
use SchemaBuilderTrait;

public $db = 'clickhouse';

Expand Down
25 changes: 25 additions & 0 deletions SchemaBuilderTrait.php
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);
}
}

0 comments on commit cbeb6df

Please sign in to comment.