Skip to content

Using Azure

metaskills edited this page Apr 2, 2011 · 10 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 an “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 need an you to add this too.

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 https://gist.github.com/893599