clickhouse-activerecord icon indicating copy to clipboard operation
clickhouse-activerecord copied to clipboard

Schema dumps do not support primary keys of type other than :integer/UInt32

Open danielwestendorf opened this issue 4 months ago • 2 comments

Previous to ddfa259bbec88aefa3eaf2942392b8473a477601, we saw table definitions dumped as such:

create_table "my_table", id: false, force: :cascade do |t|
  t.integer "id", unsigned: true, limit: 2, null: false
  ...
end

after the above mentioned commit, the same table will now be dumped as such:

create_table "my_table", id: :integer, unsigned: true, limit: 2 force: :cascade do |t|
  ...
end

which omits the id column definition. This matches what we'd see in other database types' schema dumps. The problem however, is that if this schema is loaded, however, the unsigned and limit options are not considered, and the primary key will not match the original definition. As such, a subsequent dump would look like this:

create_table "my_table", id: :integer force: :cascade do |t|
  ...
end

which is no longer accurate. This results in schemas which drift from the original definition.

danielwestendorf avatar Oct 17 '24 22:10 danielwestendorf