fat_free_crm
fat_free_crm copied to clipboard
Error running migration 20230526212613_convert_to_active_storage.rb
Steps to reproduce:
- git clone ffcrm...
- bundle install
- rake db:create
- rake db:migrate
I get the following error (truncated):
== 20230526211831 CreateActiveStorageTables: migrating ========================
-- create_table(:active_storage_blobs, {:id=>:primary_key})
-> 0.0217s
-- create_table(:active_storage_attachments, {:id=>:primary_key})
-> 0.0273s
-- create_table(:active_storage_variant_records, {:id=>:primary_key})
-> 0.0218s
== 20230526211831 CreateActiveStorageTables: migrated (0.0713s) ===============
== 20230526212613 ConvertToActiveStorage: migrating ===========================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 1, expected 2..3)
~/code/ffcrm/fat_free_crm/db/migrate/20230526212613_convert_to_active_storage.rb:18:in `prepare'
~code/ffcrm/fat_free_crm/db/migrate/20230526212613_convert_to_active_storage.rb:18:in `up'
...
Seems related to erroneous ActiveStorage migration guide code in PaperClip - https://github.com/thoughtbot/paperclip/issues/2603
Potential solution: https://github.com/thoughtbot/paperclip/pull/2568#issuecomment-381629629
What database are you using to get this?
postgresql, will check which version
ugh i tested the active storage migration on sqlite and mysql, shouldve checked pg too :/
I'm not sure if this is useful, but this is a hacky change that at least the migration runs - though without prepare statements unfortunately.
ActiveRecord::Base.connection.raw_connection.then do |conn|
unless conn.is_a?(PG::Connection)
ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
INSERT INTO active_storage_blobs (
`key`, filename, content_type, metadata, byte_size, checksum, created_at
) VALUES (?, ?, ?, '{}', ?, ?, ?)
SQL
ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
INSERT INTO active_storage_attachments (
name, record_type, record_id, blob_id, created_at
) VALUES (?, ?, ?, #{get_blob_id}, ?)
SQL
end
end
I went through the same error. I tested both with postgres and mysql and I always have some error to do this migration
~~Here's a PR that at least allows the migration to run on Postgres. I haven't been able to test on MySQL or other RDBMSes~~
~~https://github.com/fatfreecrm/fat_free_crm/pull/1135~~
~~This may not be generally useful, but maybe there's something here that someone can pick through to get things working on their own boxes. I had to update Ruby in order to get mini_racer
to install.~~
Per request from @CloCkWeRX , the fix for this has been broken out into a separate PR (see #1137)
Can this be closed now #1137 is in master
?