# Unit tests fail with sqlite3 and rails 1.1

**URL:** <https://www.ruby-forum.com/t/unit-tests-fail-with-sqlite3-and-rails-1-1/60217>\
**Category:** Rails\
**Created:** [May 11, 2006, 7:40am UTC](https://www.ruby-forum.com/t/unit-tests-fail-with-sqlite3-and-rails-1-1/60217 "2006-05-11T07:40:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [May 11, 2006, 7:40am UTC](https://www.ruby-forum.com/t/unit-tests-fail-with-sqlite3-and-rails-1-1/60217/1 "2006-05-11T07:40:18Z")

</div>

Hello all,

I’m kinda going through a rocky upgrade to rails 1.1 and I can’t find  
much on google about this. When I run my tests I get this:

$ rake  
(in /home/www/art2)  
/usr/bin/ruby -Ilib:test  
“/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake\_test\_loader.rb”  
“test/functional/panoramas\_controller\_test.rb”  
“test/functional/links\_controller\_test.rb”  
“test/functional/articles\_controller\_test.rb”  
“test/functional/categories\_controller\_test.rb”  
“test/functional/rss\_controller\_test.rb”  
“test/functional/photos\_controller\_test.rb”  
Loaded suite  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake\_test\_loader  
Started  
…  
Finished in 0.833814 seconds.

42 tests, 160 assertions, 0 failures, 0 errors  
rake aborted!  
Test failures

(See full trace by running task with --trace)

Obviously this error message makes a lot of sense to me because it  
says 0 failures, 0 errors, then two lines down it says there’s test  
failures. Oddly, it’s only doing functional tests, no unit tests. So I  
run it again with --trace like it says and it tells me a whole lot of  
nothing particularly useful (it’s showing the trace for the functional  
tests, which work fine. it’s still just skipping and ignoring the unit  
tests). So, I google around and find this trickery to force it to run  
the unit tests:

$ rake test:units --trace  
(in /home/www/art2)  
\*\* Invoke test:units (first\_time)  
\*\* Invoke db:test:prepare (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:test:prepare  
\*\* Invoke db:test:clone (first\_time)  
\*\* Invoke db:schema:dump (first\_time)  
\*\* Invoke environment  
\*\* Execute db:schema:dump  
\*\* Execute db:test:clone  
\*\* Invoke db:schema:load (first\_time)  
\*\* Invoke environment  
\*\* Execute db:schema:load  
rake aborted!  
SQLite3::SQLException: object name reserved for internal use:  
sqlite\_autoindex\_categories\_1: CREATE UNIQUE INDEX  
sqlite\_autoindex\_categories\_1 ON categories (name)  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/abstract\_adapter.rb:120:in  
`log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/sqlite_adapter.rb:137:in`execute’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/sqlite\_adapter.rb:335:in  
`catch_schema_changes' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/sqlite_adapter.rb:137:in`execute’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/abstract/schema\_statements.rb:196:in  
`add_index' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:272:in`method\_missing’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:256:in  
`say_with_time' /usr/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:256:in  
`say_with_time' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:270:in`method\_missing’  
./db/schema.rb:14  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/schema.rb:43:in  
`define' ./db/schema.rb:5 /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in`load’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:31  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:72 /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in`invoke’  
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in`invoke’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:139  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in`invoke\_prerequisites’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in`invoke\_prerequisites’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in`run’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7  
/usr/bin/rake:18

The important part of that error message, of course, being this:

\*\* Execute db:schema:load  
rake aborted!  
SQLite3::SQLException: object name reserved for internal use:  
sqlite\_autoindex\_categories\_1: CREATE UNIQUE INDEX  
sqlite\_autoindex\_categories\_1 ON categories (name)

I’ve googled around for this and I can NOT find any information at  
all. Simply googling sqlite\_autoindex\_categories\_1 gives absolutely  
nothing.

So, what am I missing here? I’m using Ubuntu, and one problem I had  
was that Ubuntu only had ruby 1.8.3, where the new rails demanded  
1.8.4, so I completely uninstalled all ubuntu ruby packages and  
compiled & installed ruby from source. is there some package I’m  
missing then? I know one thing that tripped me up was having to  
reinstall rubygems, the sqlite3 driver, & etc so maybe there’s some  
other dependency that I’m missing? Otherwise I have no idea what’s  
going on, aside from some vague notion that rails’ unit tests are  
doing something that sqlite3 doesn’t like at all.

Otherwise, my site seems to be running fine, but I say “seems” because  
it’s not running the unit tests so I don’t know for sure if it’s  
running fine or not. I’m not comfortable pushing this to production  
until the tests run!

Thanks.

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [May 13, 2006, 8:46am UTC](https://www.ruby-forum.com/t/unit-tests-fail-with-sqlite3-and-rails-1-1/60217/2 "2006-05-13T08:46:12Z")

</div>

On 5/10/06, Rob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \*\* Execute db:schema:load  
> rake aborted!  
> SQLite3::SQLException: object name reserved for internal use:  
> sqlite\_autoindex\_categories\_1: CREATE UNIQUE INDEX  
> sqlite\_autoindex\_categories\_1 ON categories (name)

Anybody?

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [May 13, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/unit-tests-fail-with-sqlite3-and-rails-1-1/60217/3 "2006-05-13T19:15:37Z")

</div>

On 5/13/06, Rob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 5/10/06, Rob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > \*\* Execute db:schema:load  
> > rake aborted!  
> > SQLite3::SQLException: object name reserved for internal use:  
> > sqlite\_autoindex\_categories\_1: CREATE UNIQUE INDEX  
> > sqlite\_autoindex\_categories\_1 ON categories (name)
> 
> Anybody?

Alright, I played around with this some more, and I finally got it  
“working” by brute force.

The problem is due to rails trying to create the unique index where  
sqlite3 (I’m assuming) already does that on it’s own, so essentailly  
rails was trying to create an index that was already automatically  
created.

My “fix” was to go through the entire database and remove all the  
unique indexes, figuring that rails will handle the unique constraint  
_anyway_, that it doesn’t need to be in the db as well. Now the tests  
pass and everything is looking good.
