-
Notifications
You must be signed in to change notification settings - Fork 25
The "description" method has been corrected #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7f13bdf
5de5c3e
ca479f1
3a23e56
8deb827
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,13 +126,38 @@ public function notNull(): self | |
| return $this->set('nullable', false); | ||
| } | ||
|
|
||
| /** | ||
| * @return $this | ||
| */ | ||
| public function nullable(): self | ||
| { | ||
| return $this->set('nullable', true); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $comment | ||
| * @return $this | ||
| */ | ||
| public function description(string $comment): self | ||
| { | ||
| return $this->set('description', $comment); | ||
| return $this->set('comment', $comment); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $value | ||
| * @return $this | ||
| */ | ||
| public function collate(string $value): self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Different DBs use different values for COLLATE. |
||
| { | ||
| return $this->set('collate', $value); | ||
| } | ||
|
|
||
| /** | ||
| * @return $this | ||
| */ | ||
| public function onUpdateCurrentTimeStamp(): self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MySQL specific. |
||
| { | ||
| return $this->set('onUpdateCurrentTimeStamp', 1); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ class Compiler | |
| protected $params = []; | ||
|
|
||
| /** @var string[] */ | ||
| protected $modifiers = ['unsigned', 'nullable', 'default', 'autoincrement']; | ||
| protected $modifiers = ['unsigned', 'nullable', 'default', 'autoincrement', 'comment', 'onUpdateCurrentTimeStamp', 'collate']; | ||
|
|
||
| /** @var string[] */ | ||
| protected $serials = ['tiny', 'small', 'normal', 'medium', 'big']; | ||
|
|
@@ -258,7 +258,7 @@ protected function handleTypeTime(BaseColumn $column): string | |
| */ | ||
| protected function handleTypeTimestamp(BaseColumn $column): string | ||
| { | ||
| return 'TIMESTAMP'; | ||
| return ' TIMESTAMP DEFAULT CURRENT_TIMESTAMP() '; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -310,6 +310,33 @@ protected function handleModifierDefault(BaseColumn $column): string | |
| return null === $column->get('default') ? '' : 'DEFAULT ' . $this->value($column->get('default')); | ||
| } | ||
|
|
||
| /** | ||
| * @param BaseColumn $column | ||
| * @return string | ||
| */ | ||
| protected function handleModifierComment(BaseColumn $column): string | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MySQL only. |
||
| return $column->get('comment') ? ' COMMENT \'' . $column->get('comment') . '\'' : ''; | ||
| } | ||
|
|
||
| /** | ||
| * @param BaseColumn $column | ||
| * @return string | ||
| */ | ||
| protected function handleModifierOnUpdateCurrentTimeStamp(BaseColumn $column): string | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MySQL only. |
||
| { | ||
| return $column->get('onUpdateCurrentTimeStamp') ? ' ON UPDATE CURRENT_TIMESTAMP() ' : ''; | ||
| } | ||
|
|
||
| /** | ||
| * @param BaseColumn $column | ||
| * @return string | ||
| */ | ||
| protected function handleModifierCollate(BaseColumn $column): string | ||
| { | ||
| return $column->get('collate') ? ' COLLATE ' . $column->get('collate') : ''; | ||
| } | ||
|
|
||
| /** | ||
| * @param BaseColumn $column | ||
| * @return string | ||
|
|
@@ -552,6 +579,7 @@ protected function handleAddForeign(AlterTable $table, $data): string | |
| * @param $data | ||
| * @return string | ||
| */ | ||
|
|
||
| protected function handleSetDefaultValue(AlterTable $table, $data): string | ||
| { | ||
| return 'ALTER TABLE ' . $this->wrap($table->getTableName()) . ' ALTER COLUMN ' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,14 +366,17 @@ public function softDelete(string $column = 'deleted_at'): self | |
| } | ||
|
|
||
| /** | ||
| * @param string $createColumn | ||
| * @param string $updateColumn | ||
| * @return $this | ||
| */ | ||
| public function timestamps(string $createColumn = 'created_at', string $updateColumn = 'updated_at'): self | ||
| public function timestamps($fields = []): self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Breaks backward compatibility! |
||
| { | ||
| $this->dateTime($createColumn)->notNull(); | ||
| $this->dateTime($updateColumn); | ||
| if (!is_array($fields)) | ||
| $fields = [$fields]; | ||
| foreach ($fields as $field) | ||
| $this->timestamp($field); | ||
|
|
||
| $this->timestamp('created_at'); | ||
| $this->timestamp('updated_at'); | ||
| return $this; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Columns are nullable by default, this is redundant.