# Test Database fails to initialize

**URL:** <https://www.ruby-forum.com/t/test-database-fails-to-initialize/135510>\
**Category:** Rails\
**Created:** [April 22, 2008, 7:28pm UTC](https://www.ruby-forum.com/t/test-database-fails-to-initialize/135510 "2008-04-22T19:28:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![capnregex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@capnregex](https://www.ruby-forum.com/u/capnregex)\
**Post date:** [April 22, 2008, 7:28pm UTC](https://www.ruby-forum.com/t/test-database-fails-to-initialize/135510/1 "2008-04-22T19:28:47Z")

</div>

Hi, yes, I’m still using rails 1.2.6, as I haven’t made the time to  
migrate.

when I try to do run tests using rake, it fails to initialize the  
database correctly…

I create the database using migrations, and I wanted to index a text  
field in mysql.  
The default  
add\_index command does not handle adding the index correctly, as mysql  
requires a length for indexing a test field, for how much of the text  
field to index.

so, in my migration I have a

Model.connection.execute(‘CREATE INDEX index\_name ON table\_name  
( field1, field2, text\_field(20) )’)

however, rails records that in the schema.rb as

add\_index “table”, [“field1”,“field2”,“text\_field”], :name =\>  
“index\_name”

which fails.

I don’t want to eliminate the index, as it gives me a considerable  
speed increase when looking for an exact match in the text\_field…

Ideas?

---

<div class="post-metadata">

**Author:** ![capnregex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@capnregex](https://www.ruby-forum.com/u/capnregex)\
**Post date:** [April 22, 2008, 7:55pm UTC](https://www.ruby-forum.com/t/test-database-fails-to-initialize/135510/2 "2008-04-22T19:55:20Z")

</div>

On 22 Apr 2008, at 18:27, CapnRegex wrote:

> I don’t want to eliminate the index, as it gives me a considerable  
> speed increase when looking for an exact match in the text\_field…

Switch from using the ruby schema dumper to the sql one (it’s an  
option in environment.rb)

---

<div class="post-metadata">

**Author:** ![capnregex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@capnregex](https://www.ruby-forum.com/u/capnregex)\
**Post date:** [April 22, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/test-database-fails-to-initialize/135510/3 "2008-04-22T20:14:12Z")

</div>

Yay, that worked, thanks…

just for the record, I added in

Rails::Initializer.run do |config|  
… stuff that was already there …  
config.active\_record.schema\_format = :sql  
end

On Apr 22, 11:54 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
