Skip to content

Commit a49ffff

Browse files
authored
In SQL Server only the first column added should have the ADD keyword (#1086)
1 parent 1ece12b commit a49ffff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
256256
end
257257
end
258258

259+
# In SQL Server only the first column added should have the `ADD` keyword.
260+
def add_timestamps(table_name, **options)
261+
fragments = add_timestamps_for_alter(table_name, **options)
262+
fragments[1..].each { |fragment| fragment.sub!('ADD ', '') }
263+
execute "ALTER TABLE #{quote_table_name(table_name)} #{fragments.join(', ')}"
264+
end
265+
259266
def columns_for_distinct(columns, orders)
260267
order_columns = orders.reject(&:blank?).map { |s|
261268
s = s.to_sql unless s.is_a?(String)

0 commit comments

Comments
 (0)