Last active
March 25, 2016 03:29
-
-
Save dcb9/dc363b5d3e45be03f1cf to your computer and use it in GitHub Desktop.
add comment function in column builder in yii2 2.0.7
This file contains hidden or 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
diff --git a/ColumnSchemaBuilder.php b/ColumnSchemaBuilder.php | |
index bfa26bd..45ca8f5 100644 | |
--- a/ColumnSchemaBuilder.php | |
+++ b/ColumnSchemaBuilder.php | |
@@ -51,6 +51,7 @@ class ColumnSchemaBuilder extends Object | |
* @since 2.0.7 | |
*/ | |
protected $isUnsigned = false; | |
+ protected $comment; | |
/** | |
@@ -109,6 +110,11 @@ class ColumnSchemaBuilder extends Object | |
return $this; | |
} | |
+ public function comment($comment){ | |
+ $this->comment = $comment; | |
+ return $this; | |
+ } | |
+ | |
/** | |
* Marks column as unsigned. | |
* @return $this | |
@@ -145,7 +151,17 @@ class ColumnSchemaBuilder extends Object | |
$this->buildNotNullString() . | |
$this->buildUniqueString() . | |
$this->buildDefaultString() . | |
- $this->buildCheckString(); | |
+ $this->buildCheckString(). | |
+ $this->buildCommentString(); | |
+ } | |
+ | |
+ /** | |
+ * Builds the not null constraint for the column. | |
+ * @return string returns 'NOT NULL' if [[isNotNull]] is true, otherwise it returns an empty string. | |
+ */ | |
+ protected function buildCommentString() | |
+ { | |
+ return $this->comment ? " COMMENT '$this->comment'": ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment