Hello,

Here's my version of your migration file: http://gist.github.com/313327

Changed t.int to t.integer as i dont think rails understand int as in
integer (maybe i'm wrong here). Although changed table name to
aropenitems so it's in plural all over migration file.

At least now this migration completes sucessfully...

On Feb 24, 6:37 am, Len Sumnler <[email protected]> wrote:
> 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:
>
> len...@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
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to