Created
April 12, 2012 04:03
-
-
Save deJaVisions/2364526 to your computer and use it in GitHub Desktop.
rake db:migrate chokes on multi-line scope with custom sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:drop | |
| phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:create | |
| phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:migrate --trace | |
| ** Invoke db:migrate (first_time) | |
| ** Invoke environment (first_time) | |
| ** Execute environment | |
| rake aborted! | |
| SQLite3::SQLException: no such table: materials: SELECT * from materials | |
| WHERE title NOT LIKE '%antique%' | |
| ORDER BY created_at DESC | |
| *** finally, later i figured out that this multi-line scope in my model was causing rake db:migrate to choke, because if i commented it out, the migrate works fine: | |
| scope :newly_crafted_without_antiques, | |
| self.find_by_sql("SELECT * from materials | |
| WHERE title NOT LIKE '%antique%' | |
| ORDER BY created_at DESC") | |
| *** even later, i found out i didn't need the custom sql after all (thanx epochwolf on irc #ror) and could use active record still with sqlite3 using this: | |
| scope :newly_crafted_without_antiques, | |
| where("title NOT LIKE '%antique%'").order("created_at DESC") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment