Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyTds::Error: Type T_FK is not a defined system type. #844

Open
nPaul opened this issue Aug 10, 2020 · 4 comments
Open

TinyTds::Error: Type T_FK is not a defined system type. #844

nPaul opened this issue Aug 10, 2020 · 4 comments

Comments

@nPaul
Copy link

nPaul commented Aug 10, 2020

Rails version 6
multi database using

for example if run db:rollback
got error:

--trace log


** Invoke db:rollback (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:rollback
== 20200810025414 AddDescriptionToOrders: reverting ===========================
-- remove_column(:orders, :description, :string)
   -> 0.0017s
== 20200810025414 AddDescriptionToOrders: reverted (0.0026s) ==================

** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke db:load_config 
** Execute db:schema:dump
rails aborted!
ActiveRecord::StatementInvalid: TinyTds::Error: Type T_FK is not a defined system type
```.

other databases is normal dumped after db:migration and db:rollback
this error got also if run
rails db:migrate:down:primary VERSION=123123123

i think sql adapter has bug on dumping command


@nPaul
Copy link
Author

nPaul commented Aug 10, 2020

FREETDS version

tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.1.24
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.3
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: yes

@defaultzero
Copy link

I'm having the exact issue. Were you able to solve this?

@defaultzero
Copy link

defaultzero commented Jun 21, 2024

To be more helpful, this is caused by connecting to our ERP 2012 SQL Server DB.
It has many different custom column types. SiteType, being among them. All which cause the error,
TinyTds::Error: Type SiteType is not a defined system type.

It would be helpful to know how to pass custom system types to TinyTDS. Many of these are datatypes are glorified strings.

Is it possible to map, for instance, SiteType = String, somewhere, so that TinyTDS can handle?

@aidanharan
Copy link
Contributor

There is an article about using custom data types in Rails with PostgreSQL https://pganalyze.com/blog/custom-postgres-data-types-ruby-rails

The same technique might work for the SQL Server adapter but I've never tried it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants