Error adding constraint

18 views
Skip to first unread message

César Amador

unread,
Jul 6, 2017, 3:35:08 AM7/6/17
to Rails SQLServer Adapter
Hi there,

I'm getting an error when I run this migration:

$ rails db:migrate                                                                   == 20170705120339 ChangeMyFieldInMyTable: migrating ==============
-- change_column_default(:my_tables, :my_field, {:from=>"N", :to=>nil})
rails aborted
!
StandardError: An error has occurred, this and all later migrations canceled:

TinyTds::Error: Incorrect syntax near '.'.: ALTER TABLE [dbo].[my_tables] ADD CONSTRAINT DF_dbo.my_tables_my_field DEFAULT NULL FOR [my_field]

I think the offending part is that 'DF_dbo' in 'ADD CONSTRAINT DF_dbo.my_tables_my_field', but I don't know how to solve it.

Does it something to do this code in my initializer?

ActiveRecord::Base.table_name_prefix = 'dbo.'

# https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/381#issuecomment-76366715
ActiveRecord::ConnectionAdapters::SQLServerAdapter.use_output_inserted = false

I'm using SQL Server 2014/Ruby 2.3.3/Rails 5.0.1/activerecord-sqlserver-adapter 5.0.3/tiny_tds 1.1.0

Could you, please, help me.

Many thanks!
Reply all
Reply to author
Forward
0 new messages