# Rake Migrate failing - but can't find syntax errors

**URL:** <https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252>\
**Category:** Rails\
**Created:** [June 7, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252 "2007-06-07T21:22:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 7, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/1 "2007-06-07T21:22:05Z")

</div>

Hello,

I’m following a guide on creating a migration, but the migrate is  
failing due to the following errors:

Line 7: Unexpected ‘\n’ expecting tCOLON2 or ‘{’ or ‘.’  
Line 14: $END expecting KEND

But I can’t find any mistakes.

Any help appreciated.

I use sometimes notepad and sometimes crimson editor for my programming  
development. If there’s a better editor that would not cause these  
problems (as they don’t seem to be typing erors) I’d appreciate the  
help.

I pasted this straight from Crimson Editor:

class CreatePosts \< ActiveRecord::Migration  
def self.up  
create\_table :posts do |t|  
t.column :title, :string  
t.column :body, :text  
t.column :created\_at, :string  
t.lock\_version, :integer  
end  
end

def self.down  
drop\_table :posts  
end  
end

H.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 7, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/2 "2007-06-07T21:34:26Z")

</div>

This looks strange =\> t.lock\_version, :integer

Is the comma needed?

I’m learning too and have never used t.lock\_version.

-Mel

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 8, 2007, 12:48am UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/3 "2007-06-08T00:48:35Z")

</div>

Ok, good news but at the same time bad news.

Good news is that it’s working. I removed the lock\_version statement  
after loading the file into a windows version of emacs, and also just  
removed anything after the last end statement (even though I couldn’t  
find anything) and now it migrates fine.

Bad news, I don’t know why the lock\_version was having that effect, I  
found the statement through google that was supposed to be, well a  
locking mechanism to ensure the same database item couldnt be edited at  
the same time by two users. I can only suppose it didn’t work. Why I  
don’t know.

I hate these types of errors, particularly the $END and KEND as I don’t  
know what they mean. I don’t have any other editors than notepad,  
Editpad Pro and Crimson Editor, and iit seems that even these put hidden  
characters in that mess things up. Any recommendations for a no  
nonsense editor would be welcome. I do need something that is  
accessible though as I’m partially sighted, so something easy to use.

H.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 8, 2007, 2:13am UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/4 "2007-06-08T02:13:59Z")

</div>

On Jun 7, 2007, at 6:48 PM, Hussein P. wrote:

> I hate these types of errors, particularly the $END and KEND as I  
> don’t  
> know what they mean. I don’t have any other editors than notepad,  
> Editpad Pro and Crimson Editor, and iit seems that even these put  
> hidden  
> characters in that mess things up. Any recommendations for a no  
> nonsense editor would be welcome. I do need something that is  
> accessible though as I’m partially sighted, so something easy to use.
> 
> H.

These are tokens from the parser: kSOMETHING usually means that a  
token that looks like something is involved, in this case kEND is the  
“end” of some block/loop/if construct. The $ (or $END) often means  
the end of the file. They’re not literally “$END” or “kEND” in the  
source so your editor will do just fine.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 8, 2007, 4:42pm UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/5 "2007-06-08T16:42:37Z")

</div>

Thanks Chris for clearing that up - at least for me.

–Mel

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [June 8, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/rake-migrate-failing-but-cant-find-syntax-errors/106252/6 "2007-06-08T16:34:39Z")

</div>

> t.lock\_version, :integer

This is definitely the problem. I believe you meant:

t.column lock\_version, :integer

However, please don’t add this without actually understanding optimistic  
locking. It won’t automatically take care of everything involved with  
making sure two people aren’t editing a record at the same time - it  
just causes an ActiveRecord::StaleObjectError when trying to save the  
record if it has changed since the user loaded it. Your application  
still has to handle that error.

For more information:  
[http://api.rubyonrails.com/classes/ActiveRecord/Locking/Optimistic.html](http://api.rubyonrails.com/classes/ActiveRecord/Locking/Optimistic.html)  
[http://wiki.rubyonrails.org/rails/pages/MagicFieldNames](http://wiki.rubyonrails.org/rails/pages/MagicFieldNames)  
[http://www.ruby-forum.com/topic/61754](http://www.ruby-forum.com/topic/61754)
