Created the following Ruby Migration program 001_create_aropenitems.rb
class CreateAropenitems < ActiveRecord::Migration
def self.up
create_table :aropenitem do |t|
t.int :cust_no
t.date :doc_date
t.integer :doc_no
t.string :doc_type, :limit => 1
t.integer :apply_to_no
t.date :doc_due_date
t.decimal :amt1, :precision => 9, :scale => 2
t.decimal :amt2, :precision => 9, :scale => 2
t.string :ref, :limit => 30
t.int :slsmn1
t.int :slsmn2
t.int :slsmn3
t.decimal :amt3, :precision => 7, :scale => 2
t.int :city_county_tax
end
add_index(:aropenitem, [:cust_no, :doc_date, :doc_no, :doc_type],
:unique => true, :name => ‘cust_doc’)
add_index(:aropenitem, [:apply_to_no, :cust_no], :name =>
‘apply_to’)
add_index(:aropenitem, :city_county_tax, :name => ‘texas_tax’)
end
def self.down
drop_table :aropenitems
end
When I run rake I get the following trace:
lenyel@lenyel-laptop:~/bruskerb$ rake --trace
(in /home/lenyel/bruskerb)
** Invoke default (first_time)
** Invoke migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute migrate
== CreateAropenitems: migrating
– create_table(:aropenitem)
-> 0.1718s
– add_index(:aropenitem, [:cust_no, :doc_date, :doc_no, :doc_type],
{:unique=>true, :name=>“cust_doc”})
rake aborted!
An error has occurred, all later migrations canceled:
Mysql::Error: Key column ‘cust_no’ doesn’t exist in table: CREATE UNIQUE
INDEX cust_doc
ON aropenitem
(cust_no
, doc_date
, doc_no
,
doc_type
)
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in
`log’
Don’t understand why I would be getting thie error.
MySQL version 5.1.37
activerecord 2.3.5
mysql 2.8.1
Thanks
Len