Rebase Rails migrations in a long running project

后端 未结 3 847
甜味超标
甜味超标 2020-12-13 06:17

In which I mean \"rebasing\" in the dictionary, rather than git definition...

I have a large, long running Rails project that has about 250 migrations, it\'s getting

3条回答
  •  粉色の甜心
    2020-12-13 06:40

    In addition to the answer provided (which well indicates how to consolidate your volume of migrations), you indicate a concern to purge data (which I assume is manually added after fixtures populate your tables); which infers you're depending on refreshing an initial data state. Some projects indeed require intensive refinement of base data, reconstruction, and re-population of tables. Ours heavily depends on repetitive execution of these operations, and I've found that if you can reduce your schema entirely to SQL execute statements, your tables will rebuild far faster than they will from Ruby syntax.

    A trivial further help in rebuilding your tables is to dedicate a separate terminal window to a single combined command statement:

    rake db:drop db:create db:schema:load db:fixtures:load

    Each time you need to rebuild and re-populate your tables, an up-arrow and return keypress will get that routine job done. If there's no conflict in SQL execute statements, and if you don't have further migrations to run while you're project is in development state, the SQL statements will execute perhaps better than twice as fast as the Ruby syntax. Our tables rebuild and re-populate in 20 seconds this way for example, whereas the Ruby syntax increases the process to well over 50 seconds. If you're waiting on that data to refresh to perform further work (especially many times), this makes a huge difference in workflow.

提交回复
热议问题