Skip to content

rails db:schema:load creates column with wrong data type (VARBINARY instead of BINARY) #56037

@john-999

Description

@john-999

Steps to reproduce

schema.rb

create_table "users", id: false, force: :cascade do |t|
  t.binary "id", limit: 16, null: false, primary_key: true
  # OR: t.binary "id", limit: 16, null: false, primary_key: true, type: "BINARY(16)" # This addition does not change anything
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end

OR (yields the same result):

create_table "users", id: { type: :binary, limit: 16 }, force: :cascade do |t|
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end

Create the tables

$ bin/rails db:schema:load

Expected behavior

Column Users.id should be of type BINARY(16).

Actual behavior

Column Users.id is of type VARBINARY(16).

Even if one monkey-patches the situation by running migrations containing raw SQL, to get to the correct data type: The schema.rb will always remain the same (since it's auto-generated by Rails), meaning that it can never be "loaded" (used to create the DB tables). So there is still no solution.

(Also: I see that Rails still ignores MariaDB regarding UUID support - does the Rails Core Team discourage the use of MariaDB for some reason? If so, why? I consider it to be superior to MySQL.)

System configuration

Rails version: Rails 7.2.3

Ruby version: ruby 3.4.7

Database version: mariadb from 12.1.1-MariaDB, client 15.2 for debian-linux-gnu (x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions