Rails 5.2.3 schema load failing for Microsoft SQL Server

Trying to install a Rails 5.2.3 application on a SQL Server database. When I try to create the tables using the rake db:schema:load command, it fails when trying to create the primary auto sequence id key field. It is trying to use an invalid data type of ‘serial’.

It’s failing on the first table, here is the table in my schema.rb file

  create_table "chart_configurations", id: :serial, force: :cascade do |t|
    t.string "kind", limit: 255
    t.text "display_attributes"
    t.string "primary_measurement_element", limit: 255
    t.string "primary_measurement_label", limit: 255
    t.string "function", limit: 255
  end

When I execute the rake command:

bundle exec rake db:schema:load
-- create_table("chart_configurations", {:id=>:serial, :force=>:cascade})
rake aborted!
ActiveRecord::StatementInvalid: TinyTds::Error: Column, parameter, or variable #1: Cannot find data type serial.: 
CREATE TABLE [chart_configurations] ([id] serial NOT NULL PRIMARY KEY,
[kind] nvarchar(255), [display_attributes] nvarchar(max),
[primary_measurement_element] nvarchar(255),
[primary_measurement_label] nvarchar(255), [function] nvarchar(255))

SQL Server version 2017
Ruby v 2.5.8
rails (5.2.3)
activerecord-sqlserver-adapter (5.2.1)
tiny_tds (2.1.2 x64-mingw32)

Any ideas what I can do to get my schema loaded?

Source: StackOverflow

LEAVE A COMMENT