ActiveStorage failing because PK assumption
rromanchuk opened this issue · 4 comments
Out of the box install looks to be failing from bigint assumptions
PG::NotNullViolation: ERROR: null value in column "record_id" of relation "active_storage_attachments" violates not-null constraint
DETAIL: Failing row contains (84f40d7b-6648-4d8b-9491-09dc17c0bf2b, file, Spina::Image, null, e8f5e234-918e-45cf-ad14-a8ba317cd425, 2022-12-22 06:08:52.18749).
My project uses uuid
s
Rails.application.config.generators { |g| g.orm :active_record, primary_key_type: :uuid }
ActiveStorage actually detects this on install and uses uuid instead of bigints https://edgeguides.rubyonrails.org/active_storage_overview.html#setup
Couldn't find any other issues opened or closed. You think I would have luck just wiping the migration and re-running brute forcing key type or am I going to run into trouble?
Spina doesn't setup ActiveStorage for you, that's just Rails. Wiping the migration and doing it again should fix it I think.
@Bramjetten yeah I know, ActiveStorage
's generators honored my PK strategy, instead of using the default int. I don't want to change active record back to ints, I want spina to support UUID. I'll try providing tests and maybe see if I can follow rails strategy on determining PK strategy on its :install
task
would you be opposed to the install task using a generator to creating a consolidated "public consumption" migration? Just realized it's just copying the entire history of the project, which would make this harder to do, and obfuscates what db:migrate
is about to do
Something like this
https://github.com/ankane/pghero/blob/master/lib/generators/pghero/templates/query_stats.rb.tt
and activestorage/db/migrate/20170806125915_create_active_storage_tables.rb
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.