Open
Description
If your application is adding solid_cache and you have config.active_record.schema_format = :sql
set, should the cache_schema.rb file be generated?
I was under the impression that you would not since:
- the application's database does not have a corresonding schema.rb
- the database.yml files specify a
migrations_path
which is where you would add the migration to create thesolid_cache_entries
table, not via the cache_schema.rb file.
db:seed
Gets run twice
The reason I bring this up is that if for some reason a developer follows these steps, the db:seed
task will be run a 2nd time on the application's database. Here are the steps to reproduce:
rails new solid-cache-app --database=postgresql
rails g model Dog
. Add aname
attribute to the dog and add this to the seeds.rb fileDog.create(name: "Fido")
- Set
config.active_record.schema_format = :sql
in application.rb - Run
rails db:prepare
add cache database steps
- Update the database.yml file to include the cache database
development:
primary: &primary_development
<<: *default
database: multiple_db_app_development
cache:
<<: *primary_development
database: multiple_db_app_development_cache
migrations_paths: db/cache_migrate
- Create a migration for the solid_cache_entries.
class AddCacheDatabaseEntries < ActiveRecord::Migration[8.0]
def change
create_table "solid_cache_entries" do |t|
t.binary "key", limit: 1024, null: false
t.binary "value", limit: 536_870_912, null: false
t.datetime "created_at", null: false
t.integer "key_hash", limit: 8, null: false
t.integer "byte_size", limit: 4, null: false
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
t.index %w[key_hash byte_size], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
end
end
end
- Remove the
cache_schema.rb
file because of the reasons mentioned above. - Run
rails db:prepare
.
Expect the seed file to not have run on the primary database
Actual results: Seed file was run on primary database and you now have two dogs named Fido.
Environment
Rails version: 8.0.1
solid_cache version: 1.0.6
Ruby version: 3.4.1
Metadata
Metadata
Assignees
Labels
No labels