Db_schema_dump for SQL Server

We’re using migrations to manage a SQL Server project and have been
running
into a number of issues with db_schema_dump/migrations. Can anyone
confirm
that these are actual issues with the SQL Server adapter and not issues
with
me :slight_smile:

  1. Fields are not properly setup with proper null settings (:null =>
    true /
    false). I’m wondering if we need to update the def columns method in
    activerecord/lib/activerecord/connection_adapters/sqlserver_adapter.rb
    to
    include “IS_NULLABLE as NULL” in the sql we use to retrieve the columns
    so
    that the following line in schema_dumper.rb will work: “tbl.print “,
    :null
    => false” if !column.null”. That’s a total guess and I’m new to Rails
    so am
    not exactly sure how to figure out if that would fix the issue.

  2. Primary key fields are not defined as :primarykey. This brings up
    another issue in general, within migrations if we’re not using the
    default
    “id” for primary key’s are we screwed?

  3. Some default’s are not working in a way that would make sense. For
    instance a datetime column with a default of getdate() results in a
    default
    that looks like: :default => Sat Jan 01 00:00:00 Eastern Standard Time

  1. Are there any defaults for built in RDBMS functions such as
    getdate/sysdate. If not how is that handled?
  1. db_schema_dump seems to blow up when ActiveRecord::
    Base.connection.instance_variable_get("@connection")[“AutoCommit”] =
    false
    is not set in environment.rb, however, all other commands don’t work
    unless
    AutoCommit is set to true.

rake aborted!
DBI::DatabaseError: Count
OLE error code:8000FFFF in Microsoft OLE DB Provider for SQL Server
ITransaction::Commit or ITransaction::Abort was called, and object
is
in a
zombie state.
HRESULT error code:0x80020009
Exception occurred.: EXEC sp_helpindex TABLENAME

Thanks for any assistance!

  • Steve