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

Best practices for adding comments to views / mat views? #425

Open
Riveascore opened this issue Oct 22, 2024 · 1 comment
Open

Best practices for adding comments to views / mat views? #425

Riveascore opened this issue Oct 22, 2024 · 1 comment

Comments

@Riveascore
Copy link

We're also using the strong_migrations gem

@derekprior
Copy link
Contributor

You can add comments to your .sql file generated by Scenic. However, when the SQL file is run, Postgres saves the structure of the view, not the contents of the SQL file. So the comment is essentially discarded and won't appear in schema.rb either.

I have just learned, however, that Postgres supports a COMMENT command (as of Postgres 12) which can be used to add metadata to objects including views. Scenic does not support this. You could add a comment using execute but it wouldn't be dumped by the schema dumper.

It looks like some time ago, Rails did add support for comments to columns, fields, indexes, etc. Scenic does not support this. We almost definitely could support it (adding comment: as an argument to create_view, adding methods to manage view comments, adding support to dump them), but I'm honestly not sure I've ever had a desire to have a schema-persisted comment. Seems like a lot of work for something I can't really think of a use case for.

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

No branches or pull requests

2 participants