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

[9.x] Add ability to add table comments for MySQL and Postgres #42401

Merged
merged 6 commits into from
May 17, 2022
Merged

[9.x] Add ability to add table comments for MySQL and Postgres #42401

merged 6 commits into from
May 17, 2022

Conversation

andrewbroberg
Copy link
Contributor

@andrewbroberg andrewbroberg commented May 16, 2022

This PR adds the ability to add a comment to a table in MySQL and Postgres

Schema::table('posts', function (Blueprint $table) {
    $table->comment('This is a comment');
})

This feature is useful for us so that our Business Intelligence team can better understand our database schema. We can already add comments on columns, adding comments on the table itself will also be beneficial in helping describe it.

@andrewbroberg andrewbroberg marked this pull request as ready for review May 16, 2022 23:12
@andrewbroberg
Copy link
Contributor Author

Will this be accepted into 8.x as well if I raise a PR to that branch too?

@driesvints
Copy link
Member

@andrewbroberg 8.x is closed for new features.

@taylorotwell taylorotwell merged commit 9da642c into laravel:9.x May 17, 2022
@telkins
Copy link
Contributor

telkins commented May 17, 2022

@andrewbroberg This is great...! And funny. At work today while reviewing a colleague's PR, we started to talk about how it would be nice to be able to add comments to tables and that it was a surprise that it wasn't already in the framework. 🤣

Thanks for this contribution...! You save me a little work in trying to do it myself...and gave me and my team a few laughs, too. 🤓

@andrewbroberg
Copy link
Contributor Author

@telkins sounds like perfect timing!

@GC-Mark
Copy link

GC-Mark commented May 18, 2022

@andrewbroberg This is great...! And funny. At work today while reviewing a colleague's PR, we started to talk about how it would be nice to be able to add comments to tables and that it was a surprise that it wasn't already in the framework. 🤣

Thanks for this contribution...! You save me a little work in trying to do it myself...and gave me and my team a few laughs, too. 🤓

Interestingly this has been proposed and rejected in numerous PRs in the past. Happy to finally see it merged though!

@Sophist-UK
Copy link

What happens if I create a Migration with $table->comment('text') but I am using sqlserver or sqlite?

Does this create an exception, or is the comment call ignored? Are there tests for this boundary condition?

P.S. My vote is that comments on tables or columns should be ignored if the database doesn't support it, but I recognise that others may believe the opposite.

@andrewbroberg
Copy link
Contributor Author

@Sophist-UK if I am reading it correctly, it will be silently ignored if it doesn't exist on the driver. toSql method on the Blueprint class looks to handle this logic.

@Sophist-UK
Copy link

@andrewbroberg That is exactly what I would hope would happen. 😃

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.

None yet

6 participants