开发者

Can i cp migration files from one ror project to another?

I just tried to cp those migration files from my former projects to my present project so that i won't generate the similar db structure again. but after i 开发者_开发技巧tried "rake db:migrate" and edit some controllers it shows that it can not find those models even if it was migrated successfully. so i rolled back and tried to recreate those files and did copy-paste staff and it finally works.

can anyone explain why to me? thanks.


Instead of just copying over the migration *.rb files, I would suggest that you go through them manually and combine them.

Just copy/pasting everything is a bad idea.


Migrations only create tables, not models. To create models, you need to copy files from app/models/ directory too. And copying migrations should work, they're just files with timestamp (it doesn't matter it timestamp is from before project was created, it just has to be unique) which maps to create table/alter table/... commands of your database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜