Skip to content

Using Azure

igravity edited this page · 9 revisions

Version 3.0.12 and up of the adapter is compatible with SQL Azure.

You must use the DBLIB connection mode which uses the TinyTDS gem. Please read both the Using TinyTDS wiki page and the Using TinyTDS with Azure section of the TinyTDS README file. TL;DR, you must be using the latest FreeTDS 0.91 compiled with OpenSSL. Also, you must use “azure: true” in the database.yml.

All tables need a clustered index. This means that if you use :id => false in your schema statements for things like join tables you will get a “Tables without a clustered index are not supported…” message when inserting data. The solution is easy, just add a :primary_key field of some type, since they are automatically clustered. Or you can create your own clustered index to match your own needs. IMPORTANT, the [schema_migrations] table will a clustered index. I found this works quite well.

CREATE CLUSTERED INDEX [idx_schema_migrations_version] ON [schema_migrations] ([version])

SQL Azure has no system sp_MSforeachtable stored procedure. The adapter makes use of this when disabling referential integrity for fixture insertion. If you use Azure for a test database and run into this issue, I recommend you copy both sp_MSforeachtable and sp_MSforeach_worker from a standard SQL Server. I used
this code

Currently TinyTDS does not have a native gem for Windows that includes static libs of OpenSSL, which is required for FreeTDS to connect to Azure. It is planned that this will happen at some point. Till then, Windows users might find this Microsoft TechNet Wiki article useful Connecting to SQL Azure from Ruby Applications

Do not use `` for the username connection option! You must use the shorter `username@server` instead!

Something went wrong with that request. Please try again.