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

Don't use schema cache when checking schema migrations #43877

Merged

Commits on Dec 15, 2021

  1. Don't use schema cache when checking schema migrations

    I noticed this while debugging a separate issue locally. When
    `lazily_load_schema_cache` is set to true AND there's a schema cache,
    running `db:drop` twice will raise a `no such table: schema_migrations`
    error. The problem here was that when `check_protected_environments` is
    run before drop, the task checks for the latest environment. That check
    looks at `table_exists?` defined in `model_schema.rb`. The issue is that
    the model schema is checking `connection.schema_cache.data_source_exists?`.
    
    When checking whether the environment is protected or schema migrations
    we don't want to use the schema cache. We want to check the database
    directly. The schema cache really is for the app after boot, so it's
    safe to skip the schema cache in this area since we want to check the
    database directly.
    eileencodes committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    920a58a View commit details
    Browse the repository at this point in the history