Skip to content

Commit

Permalink
Maintain primary key type specificity (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwestendorf authored Nov 18, 2024
1 parent 06020dd commit 83675de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/clickhouse-activerecord/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def table(table, stream)
end
end

def column_spec_for_primary_key(column)
spec = super

id = ActiveRecord::ConnectionAdapters::ClickhouseAdapter::NATIVE_DATABASE_TYPES.invert[{name: column.sql_type.gsub(/\(\d+\)/, "")}]
spec[:id] = id.inspect if id.present?

spec.except!(:limit, :unsigned) # This can be removed at some date, it is only here to clean up existing schemas which have dumped these values already
end

def function(function, stream)
stream.puts " # FUNCTION: #{function}"
sql = @connection.show_create_function(function)
Expand Down

0 comments on commit 83675de

Please sign in to comment.