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

bin/rails solid_cache:install doesn't respect schema_format = :sql #228

Open
MaxLap opened this issue Oct 17, 2024 · 1 comment
Open

bin/rails solid_cache:install doesn't respect schema_format = :sql #228

MaxLap opened this issue Oct 17, 2024 · 1 comment

Comments

@MaxLap
Copy link

MaxLap commented Oct 17, 2024

In my config, I have config.active_record.schema_format = :sql

When running bin/rails solid_cache:install, it creates a db/cache_schema.rb, which appears to then be swiftly ignored by Rails' db:prepare task.

As a result, the database gets created, but is empty... which leads to problems :)

I don't know if sql mode can be supported or not. But if not, I would suggest raising and error in bin/rails solid_cache:install is that config is :sql.

Thanks!

@julianrubisch
Copy link

this has just bitten me too, so here's a workaround that helped:

  1. comment out config.active_record.schema_format = :sql
  2. now, run bin/rails db:create:cache and bin/rails db:prepare DATABASE=cache
  3. comment config.active_record.schema_format = :sql in again
  4. run bin/rails db:schema:dump:cache

that way you end up with a not quite valid cache_structure.sql. In my case, I had to manually add semicolons and remove the CREATE TABLE sqlite_sequence(name,seq); part.

here's the structure, for reference:

CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);

CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY);

CREATE TABLE "solid_cache_entries" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" blob(1024) NOT NULL, "value" blob(536870912) NOT NULL, "created_at" datetime(6) NOT NULL, "key_hash" integer(8) NOT NULL, "byte_size" integer(4) NOT NULL);
CREATE INDEX "index_solid_cache_entries_on_byte_size" ON "solid_cache_entries" ("byte_size");
CREATE UNIQUE INDEX "index_solid_cache_entries_on_key_hash" ON "solid_cache_entries" ("key_hash");
CREATE INDEX "index_solid_cache_entries_on_key_hash_and_byte_size" ON "solid_cache_entries" ("key_hash", "byte_size");
INSERT INTO "schema_migrations" (version) VALUES ('1');

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