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 comment and table_comment table schema definition #51661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mechnicov
Copy link
Contributor

@mechnicov mechnicov commented Apr 25, 2024

Motivation / Background

This Pull Request has been created because these methods are missing, but could be helpful for bulk changes of the table. This will allow you to add comment(s) to the table and/or to the column(s) using single block, improving readability and performance because of single query

Detail

This Pull Request adds comment and table_comment for change_table definition

change_table :users, bulk: true do |t|
  t.comment :login, "Username"
  t.table_comment "Usual users"
end

Additional information

This was intended as non-breaking change

Checklist

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@mechnicov
Copy link
Contributor Author

May be t.column_comment (or just t.comment) and t.table_comment is better

@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch 5 times, most recently from 81b37be to 93bb278 Compare May 2, 2024 05:04
@mechnicov
Copy link
Contributor Author

Hello @rafaelfranca

I see you merged similar commit

f84e1eb

Please review my PR as well. Thank you

@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch from 93bb278 to 817ee08 Compare May 14, 2024 02:03
@zzak
Copy link
Member

zzak commented May 19, 2024

I don't think this is the same as validate_check_constraint, and is not supported for all adapters.

@mechnicov
Copy link
Contributor Author

Hello @zzak. Thank you for your reply. Currently in the abstract adapter there are exceptions when comments are not supported and specific methods for PostgreSQL and MySQL 1, 2 adapters

Maybe you have some idea how to improve PR changes?

@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch 2 times, most recently from 741532c to f9ec6b7 Compare May 19, 2024 19:53
@mechnicov mechnicov changed the title Add change_column_comment and change_table_comment table schema definition Add comment and table_comment table schema definition May 19, 2024
@mechnicov
Copy link
Contributor Author

I've added condition for tests (only for adapters that support comments). As for the lib code, the issue with adapters that don't support comments will be resolved at the schema statement level (as I wrote above, there will be exceptions if the appropriate methods are not defined in the specific adapter). I've also changed naming (t.comment rather than t.change_column_comment looks like the rest of existing methods)

@zzak could you look at the PR?

@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch 4 times, most recently from 9b23b52 to ea52b4c Compare May 22, 2024 20:14
@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch 2 times, most recently from 2f5ab2d to 1310419 Compare May 31, 2024 22:02
@mechnicov mechnicov force-pushed the add-change-comment-schema-definition branch from 1310419 to c75095d Compare June 3, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants