I am using Jruby and rails 2.2.2. My problem is I have a migration that is not being correctly written to the database schema.
Here is my migration:
class CreateNotes < ActiveRecord::Migration
def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :title
t.text :body
t.timestamps
end
execute "alter table notes ADD FULLTEXT(title, body)"
end
Here is what it produces on in schema.rb
create_table "notes", :force => true do |t|
t.string "title"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "notes", ["title", "body"], :name => "title"
I have two question:
'ENGINE=MyISAM'
into the schema?add_index "notes", ["title", "body"], :name => "title"
? and how do I force migrations to leave it as an execute statement?Thanks to Christian Lescuyer for the answer. However, when I tried this nothing changed. I uncommented the config.active_record... line but, my schema has not changed. I have tried this in jruby and on ruby 1.8.6 with rails 2.2.2 and edge rails and there is not changes in the schema. Can anybody tell me what I am doing wrong?
I too expected to see a new .sql file appear after a "rake db:migrate", once I set
config.active_record.schema_format = :sql
in config/environment.rb.
Apparently that's not how it works, however. I have to do this explicitly to get a db/[development|test|production]_structure.sql file:
rake db:structure:dump
As I use foreign key constraints, I use the SQL format for migrations. In environment.rb:
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
config.active_record.schema_format = :sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With