annotate vendor/plugins/engines/generators/plugin_migration/USAGE @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 Description:
Chris@0 2 The plugin migration generator assists in working with schema additions
Chris@0 3 required by plugins. Instead of running migrations from plugins directly,
Chris@0 4 the generator creates a regular Rails migration which will be responsible
Chris@0 5 for migrating the plugins from their current version to the latest version
Chris@0 6 installed.
Chris@0 7
Chris@0 8 This is important because the set of application migrations remains an
Chris@0 9 accurate record of the state of the database, even as plugins are installed
Chris@0 10 and removed during the development process.
Chris@0 11
Chris@0 12 Example:
Chris@0 13 ./script/generate plugin_migration [<plugin_name> <another_plugin_name> ...]
Chris@0 14
Chris@0 15 This will generate:
Chris@0 16
Chris@0 17 RAILS_ROOT
Chris@0 18 |- db
Chris@0 19 |-migrate
Chris@0 20 |- xxx_plugin_migrations.rb
Chris@0 21
Chris@0 22 which contains the migrations for the given plugin(s).
Chris@0 23
Chris@0 24
Chris@0 25 Advanced Usage:
Chris@0 26
Chris@0 27 There may be situations where you need *complete* control over the migrations
Chris@0 28 of plugins in your application, migrating a certainly plugin down to X, and
Chris@0 29 another plugin up to Y, where neither X or Y are the latest migrations for those
Chris@0 30 plugins.
Chris@0 31
Chris@0 32 For those unfortunate few, I have two pieces of advice:
Chris@0 33
Chris@0 34 1. Why? This is a code smell [http://c2.com/xp/CodeSmell.html].
Chris@0 35
Chris@0 36 2. Well, OK. Don't panic. You can completely control plugin migrations by
Chris@0 37 creating your own migrations. To manually migrate a plugin to a specific
Chris@0 38 version, simply use
Chris@0 39
Chris@0 40 Engines.plugins[:your_plugin_name].migrate(version)
Chris@0 41
Chris@0 42 where version is the integer of the migration this plugin should end
Chris@0 43 up at.
Chris@0 44
Chris@0 45 With great power comes great responsibility. Use this wisely.