Skip to content
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

Add nullableMorphs in migrations #2927

Merged
merged 1 commit into from
Dec 21, 2016

Conversation

antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented Dec 20, 2016

I don't know how to better describe that fields will be nullable:

Adds unsigned INTEGER `taggable_id` NULL and STRING `taggable_type` NULL

Or:

Adds nullable unsigned INTEGER `taggable_id` and nullable STRING `taggable_type`

@tillkruss
Copy link
Contributor

You could even shorten it to.

Same as `morphs()`.

Same as nullableTimestamps() does.

@antonkomarev
Copy link
Contributor Author

antonkomarev commented Dec 20, 2016

It's not the same. Because nullableMorphs() generates nullable columns and morphs() generates not nullable columns. So it's not just an alias.

public function morphs($name, $indexName = null)
{
    $this->unsignedInteger("{$name}_id");

    $this->string("{$name}_type");

    $this->index(["{$name}_id", "{$name}_type"], $indexName);
}

public function nullableMorphs($name, $indexName = null)
{
    $this->unsignedInteger("{$name}_id")->nullable();

    $this->string("{$name}_type")->nullable();

    $this->index(["{$name}_id", "{$name}_type"], $indexName);
}

And nullableTimestamps marked as same as timestamps in docs because they have same output result.

public function nullableTimestamps()
{
    $this->timestamps();
}

@taylorotwell taylorotwell merged commit f91dc5c into laravel:5.3 Dec 21, 2016
@antonkomarev antonkomarev deleted the feature/add-nullable-morphs branch December 21, 2016 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants