On Tue, Oct 25, 2011 at 2:23 PM, fadwa ferodia <[email protected]> wrote:

> Hi,
> I have an application using ruby on rails 3 (rubystack). I'm on windows
> vista
> I want to update the database and here is what I get after typing rake
> db:seed --trace
>
> (in C:/Users/dell/BitNami RubyStack Development projects/server)
> ** Invoke db:seed (first_time)
> ** Invoke db:abort_if_pending_migrations (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute db:abort_if_pending_migrations
> You have 10 pending migrations:
>  20110204225837 CreateApps
>  20110205005643 CreateRatings
>  20110205154017 CreateVestalVersions
>  20110205165712 CreateVisuals
>  20110205165923 AddAttachmentImageToVisual
>  20110206210830 CreateTargets
>  20110206210905 CreateAppTargets
>  20110209223713 CreatePermissions
>  20110209223746 CreateAppPermissions
>  20110209224341 CreateComments
> Run "rake db:migrate" to update your database then try again.
>
> so as it seems that I have to migrate I type rake db:migrate --trace and
> this is what I get :
> (in C:/Users/dell/BitNami RubyStack Development projects/server)
> ** Invoke db:migrate (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute db:migrate
> ==  CreateApps: migrating
> =====================================================
> -- create_table(:apps)
> rake aborted!
> An error has occurred, all later migrations canceled:
>
> Mysql2::Error: Table 'apps' already exists: CREATE TABLE `apps` (`id`
> int(11) DE
> FAULT NULL auto_increment PRIMARY KEY, `creator` varchar(255),
> `packageName` var
> char(255), `title` varchar(255), `description` text, `appId`
> varchar(255), `cate
> gory` varchar(255), `recentChanges` text, `email` varchar(255), `phone`
> varchar(
> 255), `website` varchar(255), `version` varchar(255), `versionCode`
> int(11), `ap
> pType` varchar(255), `promoText` text, `promoVideo` varchar(255),
> `screenshotCou
> nt` int(11), `price` varchar(255), `priceCurrency` varchar(255),
> `installSize` v
> archar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
>
> C:/rails/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/conn
> ection_adapters/abstract_adapter.rb:202:in `rescue in log'...
>
>
> I don't understand what's wrong. What should I do ?
>

These are fairly old migrations (Feb 2011).

Maybe they had been run before in your database (and created the
table apps). Could you confirm that ?

You can check that the table 'apps' is there with going into your mysql
database and executing

  show tables;

At the time (Feb 2011 ?) that will have left entries in the table
"schema_migrations".

You can check the _current_ status with going into your
database (with $ mysql  command) and executing:

   SELECT * FROM schema_migrations;

I presume those older migrations 201102... are currently not in the
schema_migrations list.

Maybe (??) someone has executed rake db:migration:down or
reverted the migrations in some other way and maybe that
step did not properly drop the table.

Could you print the content of the migration

$ cat db/migrate/20110204225837_create_apps.rb

In that case you could end-up with an inconsistency. The
table (apps) is still in the database, but the database thinks
the migration was never executed or was reverted.

This is only a possible scenario, not sure this is the actual
case in your system.

As a reference, this is how it should work if successful:

<code>
peterv@ASUS:~/data/temp/fancy$ cat db/migrate/20111025163743_create_apps.rb
class CreateApps < ActiveRecord::Migration
  def change
    create_table :apps do |t|

      t.timestamps
    end
  end
end

peterv@ASUS:~/data/temp/fancy$ rake db:migrate
==  CreateApps: migrating
=====================================================
-- create_table(:apps)
NOTICE:  CREATE TABLE will create implicit sequence "apps_id_seq" for serial
column "apps.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "apps_pkey"
for table "apps"
   -> 0.0099s
==  CreateApps: migrated (0.0100s)
============================================

peterv@ASUS:~/data/temp/fancy$ psql fancy_development
psql (8.4.9)
Type "help" for help.

fancy_development=# select * from schema_migrations;
    version
----------------
 20111025163743
(1 row)

fancy_development=# \d
               List of relations
 Schema |       Name        |   Type   | Owner
--------+-------------------+----------+--------
 public | apps              | table    | peterv
 public | apps_id_seq       | sequence | peterv
 public | schema_migrations | table    | peterv
(3 rows)

</code>

HTH,

Peter

-- 
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