Rails better way to have migration

Hi All,

I have question with rails migration file.

Seems In rails for each and every table migration file will be generate with timestamp followed by table name.

But I have moved all the migration file to a single file, and deleted all the migrations.

what is the best way of practice,

Having single migration for each table or else a single migration file for the whole application.

Thanks in advance…

as long as you develop - one file per migration

once you ‘wrap’ it up - a single file is ok

but why change it in the first place?

I may be adding few things later to database table, But Know I am in initial stage has only 10 table …

What is the Best practices?

best practise is to leave it alone -

rails generate scaffold some_class some_field_name some_other_field_name ……

rails db:migrate

that’s it

:slight_smile:

The best practice with rails is almost always to do it the way rails wants you to. So one file per migration. What is the point of doing the extra work of combining them into one file?

Colin

Why does he want to do that? What is the point of doing extra work? Do you not have enough work without doing extra work?

Are any more good reasons required?

Colin

Hi Colin,

But my team meet preferring to keep it as a single file.

Some argument where going between us, I can’t able to convenience him to keep separate for all tables. Can I provide any links or url to get clear understanding for him…

Thanks in advance…

Yes, I need some good reason to explain.

The way I see it - your next guy needs to explain why he would like to add to the work load!

He actually think about lot of files :frowning:

Ask him which is most important, a few extra files (which makes no difference to the operation of the site) or you spending extra time rationalising them. If he prefers you to waste your time and he is the boss then you must do as he says.

By the way please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message, thanks.

Colin

> He actually think about lot of files :frowning:

Ask him which is most important, a few extra files (which makes no difference to the operation of the site) or you spending extra time rationalising them. If he prefers you to waste your time and he is the boss then you must do as he says.

By the way please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message, thanks.

Colin

​Thanks Colin.

Gopinath​ ​

Then "he" apparently has too much time on his hands.

Aside from the good points already made, retaining the individual migrations offers useful "tree-ring" documentation of the evolution of the app over time.

Meanwhile, tell "him" to worry about actually important things, like whether your app has 100% test coverage :slight_smile:

Good luck,

It sounds like “he” is unaware of schema.db! This is the consolidated schema of all the migrations which have run - the single view of the world that your colleague is asking for.