Tag migration

11 votes

17526 views

Isolating Seed Data

Rails 2.3.4 provides db:seed task that is the best way to insert seed data for set up a new application.

implemented

Comments

by ihower
ihower

16 votes

31367 views

Always add DB index

Always add index for foreign key, columns that need to be sorted, lookup fields and columns that are used in a GROUP BY. This can improve the performance for sql query. If you're not sure which column need to index , I recommend to use http://github.com/eladmeidar/rails_indexes, which provide rake tasks to find missing indexes.

implemented

Comments

by ihower
ihower

37 votes

8297 views

Double-check your migrations

When you generate a new migration, try it forwards and backwards to ensure it has no errors

Comments

jaimeiniesta

16 votes

11513 views

Use say and say_with_time in migrations to make a useful migration log

Use say_with_time and say in migrations will produce a more readable output in migrations. And if use correctly it could be a helpful friend when something goes wrong because normally it is stored in the deploy log

implemented

Comments

Guillermo

3 votes

20152 views

Optimize db migration

rails migration provides a convenient way to alter database structure, you can easily add, change and drop column to a existing table, but when the data in existing table are huge, it will take a long time to alter existing table, you should try to merge/optimize the db alter sql statements.

Comments

flyerhzm