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

Fetch from Upstream #1

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open

Conversation

tcannonfodder
Copy link
Collaborator

No description provided.

simi and others added 30 commits January 21, 2018 10:16
Fix mysql adapter link in README.md.
Maybe it's time to drop support for those versions of Ruby that are no
longer being updated? 2.1 is currently end of life, and 2.2 is going to
be end of life'd at the end of March.
As of 31/3/2018, Ruby 2.2 and lower are officially unsupported. Also,
Rails 4.1 and lower are completely unsupported as well, so I removed
those here. Made stuff much cleaner!
By default, creating a materialized view causes the associated query to
be run immediately. The `create view` statement does not complete until
the view is populated. While this is a good default, it may be
particularly expensive and potentially not desired during deploys.
Specifying `no_data: true`, allows the view to be created without a
refresh. It will not be usable until it is manually refreshed.
…umper-output

Remove extra space from schema dumper output
* Update Appraisals and regenerate, to match changes in #232
* Update required Ruby version to match discussion in #232
* Add Rails 5.2 to Appraisals
* Add Rails 5.2 to Travis config
* Add 'ApplicationRecord' to fix generated models on 5.0+
`pg` 0.21 + has deprecated PGConn in favor of `PG::Connection`. This
change fixes the following deprecation:

> The PGconn, PGresult, and PGError constants are deprecated, and will
be removed as of version 1.0
When we moved to our own organization from the thoughtbot org, we lost
the hound-provided rubocop config associated with the thoughtbot org.
This change updates to the prefered hound config format that references
our own `.rubocop.yml` file.

How did I settle on the rubocop rules? Well, I ran rubocop on the
codebase and either fixed what came up or added exceptions. We have lots
of line length violations that I didn't fix. For the most part, I like
the encouragement to stay at 80 characters, but sometimes it's not worth
it. I think getting the hound reminder in the PR is sufficient enough
for us to have a conversation.
Ruby 2.6 is out, so I've added it to the matrix. Rails 6 (rails edge)
requires 2.5+ so we can skip building it with older rubies.
Addresses #258 - cascade failing to identify dependent views when the
`view_to_refresh` is a substring of a dependency.
In the words of Tom Brady, "We're still here!"
Some folks add `;` to the end of their view definitions to terminate the
statement. When this is combined with `no_data: true`, an exception was
being raised because `WITH NO DATA` was being interprested as a
separate SQL statement.

To fix this, we remove the trailing semicolon from the SQL definition
before adding `WITH NO DATA`.

Fixes #272
No releases in over a year, and then two in three days? Let's get it.
Our existing build matrix was a little out of date. We were missing
Rails 6 and Ruby 2.7. I could have just added those and called it a day,
but our build matrix was already getting unwieldy.

I started by removing Ruby 2.3, which is no longer receiving updates. I
then removed Rails versions older than 5.2 for the same reason. Finally,
I removed the Rubies between 2.4 and 2.7 on the grounds that testing on
the oldest currently-supported ruby and the newest is sufficient.

Scenic's Rails and Ruby version support remains unchanged, but we're
limiting CI to a reasonable combination based on ongoing support from
Ruby and Rails. We're saving build time and CO2 emissions.
Prior to this change, `create_view :greetings, version: 2` would error
because it was reversed to `drop_view :greetings, version: 2`. The
`drop_view` method in our schema statements does not take a `version`
argument because that wouldn't make sense.

This change removes the `version` argument while leaving others (i.e.
`materialized`).
Previous to this change, using the cascading refresh behavior did not
also pass through the option to concurrently refresh as one would
expect. This meant that while the named view would be refreshed
concurrently when desired, none of its dependencies would.

Fixes #276
Semantically, I agree that the changelog for a release is the list
of every commit and that what we typically refer to as a changelog these
days is really a list of newsworthy changes. However, it seems to me
that battle is lost and that people expect this file to be named
`CHANGELOG.md`. So here it is.
calebhearth and others added 30 commits February 11, 2022 21:09
Postgres 14 [introduced] an internal view pg_stat_statements_info, which
we need to exclude from our dumper because including it causes loading
the schema to fail:

    PG::DuplicateTable: ERROR:  relation "pg_stat_statements_info" already exists

To test this, enable pg_stat_statements in the dummy database. This is a
reasonable addition as the majority of rails apps are using this
extension and it's cleaner and less error-prone than adding a fake view
of the same name in a specific test for this case.

To support this view, we're currently specifically excluding it in the
query used in the Postgres adapter to load views. Rather then excluding
it by name, we could do an extension of our current exclusion for
extension-owned views, `AND c.relname NOT IN (SELECT extname FROM
pg_extension)` by excluding any views with an extension name included
rather than exact matches. I'm not convinced that this is more robust
than excluding exact names has been shown to be by this bug.

Fixes #348
* Fix ERB deprecation warning

example warning:
```
lib/generators/scenic/model/model_generator.rb:39: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
```

followed Ruby standard library style to make distinction on ERB version check:
ruby/ruby@3406c5d
This flag was introduced in #368 but hasn't been in a release yet. I was
writing up the next release's changelog and I wasn't thrilled with
having an underscore in a CLI flag.

There's something to be said for `--replace_view` matching the schema
method that the generated method invokes but I think `--replace` is
still better.
We're not an active enough project to keep up with master as part of a
required build task. I don't want to turn off any contributors who see a
red build against an unreleased version of Rails.

I think we could rework these as a separate workflow that reports status
appropriately but is not required, but I'll leave that for another day.
You cannot use `replace_view` on a materialized view. You can use
`replace_view` on any standard postgres view that may or may not depend
or be depended on by a materialized view.
REFRESH MATERIALIZED VIEW CONCURRENTLY doesn't work for a view which is
not populated, even it has unique index. This method is useful to
perform concurrent refresh if it's possible.

Real use case in Rails will be like this:

* Database is loaded from structure.sql to run specs, but the view isn't
  populated yet so concurrent refresh is not possible. We want to
  fallback to normal(non-concurrent) refresh in this case.
* After initial population, views are expected to be refreshed
  concurrently. It's possible because the view is already populated.

Co-authored By: Derek Prior <[email protected]>
We had been using Hound CI and a custom RuboCop config to encourage
adhering to our style guide. In the last couple of years, Standard has
emerged and gained steam as a "set it and forget it" RuboCop
configuration for Ruby. Maintaining our own opinionated RuboCop
configuration is not something I care to do any longer. This change:

1. Adds Standard
2. Fixes all[^1] off the issues it detects
3. Adds Standard to CI
4. Removes our hound and RuboCop configuration

Adding Standard as an explicit CI step will require compliance for
passing builds, which is a departure from our previous setup of
only commenting via Hound. I think the time is right for this change
given the maturity of auto-fixers and integrations within various Ruby
workflows.

[^1]: We continue to allow the use of `eval` in our specs
Upcoming changes like [topological sorting][1] have the potential to
write views to `db/schema.rb` in an order that does not respect
dependencies. This adds a test to ensure that views in all schemas are
both included, and in the correct dependency order.

[1]: #398
This reverts commit d0f2052. It is
failing every build on main.
In order to use the model to `find` individual records, the primary key must be explicitly defined.

At least that's my experience with PostgreSQL.

Also, see https://arjanvandergaag.nl/blog/view-backed-activerecord-models.html
- Reformat FAQ sections to be H3 to improve hierarchy ans so that they
  can be linked to directly
- Add several known blog posts about Scenic
Also remove ~>0.19 constraint on pg gem, which conflicts with ~>1.1
constraint in Gemfile
Upcoming changes like [topological sorting][1] have the potential to
write views to `db/schema.rb` in an order that does not respect
dependencies. This adds a test to ensure that views in all schemas are
both included, and in the correct dependency order.

[1]: #398
Co-authored-by: Mykhaylo Sorochan <[email protected]>
Co-authored-by: Edward Loveall <[email protected]>
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.