[typo] kaboom?

Piers Cawley pdcawley at bofh.org.uk
Fri Oct 7 00:03:50 EDT 2005

Hal Fulton <hal9000 at hypermetrics.com> writes:

> Hi, all...
> I've done something stupid apparently. Kudos to anyone who
> can help fix.
> Here's how it went:
> 1. I saved off my database.yml and did an update. Apparently
> I failed to notice that some files had conflicts. (Why they
> would, I don't know. I hadn't changed any of them manually.)
> 2. I restarted the server and went to admin.
> 3. It told me I needed to migrate -- 18 to 23, if I recall.
> 4, So I hit the button. Got "Rails App Error"
> 5. Went and looked at log. Oh, damn. Syntax error on a line
> that says "<<< mine" or something. Believe it was the file
> app/controllers/xml_controller.rb
> 6. Fixed it manually -- think I got it right. But I should
> have realized I had a partial migration in an undefined
> state.
> 7. Restarted server. Now it tells me 21 to 23. Still app
> error though.
> 8. Tried migrate at command line. This happens:
>     [root at www typo]# rake migrate RAILS_ENV=production
>     (in /root/typo)
>     Extending Content table
>     Converting trackbacks
>     rake aborted!
>     Couldn't find Article without an ID
>     ./Rakefile:218
> Help??

Well, one of those migrations should have blown up with a deliberate exception
and warned you to take a full database backup, which I hope you have.

First things first, do a 

select value from settings where name = 'sp_article_auto_close'

If that's not zero you'll need to roll back to your backed up database because
you'll have lost comments on any old articles. Then you can either set it to
zero, or apply the patch from http://typo.leetsoft.com/trac/ticket/435.

The particular error you have seems to imply that, at some point you've deleted
an article which had trackbacks, which didn't get deleted as dependents
(something we should possibly fix in the model declarations).


  select * from trackbacks where article_id = null or article_id = 0;

That should show you the problematic trackbacks, which you can either delete or
reattach to an appropriate article. If you've restored from backups, now's the
time to simply run the migrations again, if you haven't had to, carry on.

Delete the partially converted trackbacks with:

  delete from contents where type = 'Trackback'

Fire up ./script/console and do:

      article_id, blog_name, title, excerpt, url, ip,
      created_at, updated_at, guid
    FROM trackbacks
  }).each do |tb|

Which is what the migration would do anyway. Then increment the version in the
schema_info table to 22, drop the old trackbacks table and do

  rake migrate

to finish the migration.


Piers Cawley <pdcawley at bofh.org.uk>

More information about the Typo-list mailing list