rails: Rails 7.1.1: UUID support for MariaDB/MySQL is missing -> ActiveStorage setup migration fails to correctly dump the new schema.rb (with primary key type: UUID)

Steps to reproduce

After running the ActiveStorage setup, the migration producing the new schema.rb dump appears to fail, the beginning of it looking like this:

ActiveRecord::Schema[7.0].define(version: 2023_09_29_141433) do
# Could not dump table "active_storage_attachments" because of following StandardError
#   Unknown type 'uuid' for column 'id'

# Could not dump table "active_storage_blobs" because of following StandardError
#   Unknown type 'uuid' for column 'id'

# Could not dump table "active_storage_variant_records" because of following StandardError
#   Unknown type 'uuid' for column 'id'
...

In the config/application.rb file, I have added:

config.generators do |g|
  g.orm :active_record, primary_key_type: :uuid
end

However, looking at the generated DB tables in phpMyAdmin, all key and foreign-key values in the “Type” columns correctly show “uuid” (MariaDB supports the UUID data type natively).

System configuration

Rails version: 7.0.4.3 Ruby version: 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] MariaDB version: 11.1.2 gem mysql2 version: 0.5.5

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Got it, so this would be a new feature. That is fine, let’s build it, but it will only be present in 7.2.

Yes. We should support. I’d consider that a bug.

Ok, I will try to come up with something on the weekend.

uuids are working in migrations, because we can specify basically any type in t.column :column_name, :some_type and it will work. But it is not dumped into the schema file.

I was asking if it was supported, because I was surprised to not found it in mysql rails adapter, but it is explicitly supported in postgres adapter. Maybe I am missing something?

I can try to work on introducing it into rails, if desired.