Rails 的plugin_migrations支持多数据库迁移

此插件为Rails应用程序提供了一种管理插件迁移的方法。通过创建一个名为plugin_schema_info的新表来跟踪每个插件的迁移状态,并允许用户通过新的rake任务进行插件迁移和加载插件的测试数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

plugin_migrations

plugin_migrations adds support for plugin-based migrations.

Resources

Announcement

Wiki

API

Development

Source

Description

In addition to the normal schema_info table that Rails created in your database to keep track of the current migration version, this plugin adds a new table called plugin_schema_info:

  plugin_schema_info
  ------------------
  plugin_name (string)
  version (integer)

Plugin migrations expects the migrations to be located in a similar directory structure as that of your Rails application. That is, it would look in /db/migrate in your plugin’s folder.

Usage

The plugin can be used via the new rake tasks that have been added. The plugins which are migrated are based on what is stored in +Rails.plugins+. For more information on this attributes, see the loaded_plugins[http://wiki.pluginaweek.org/Loaded_plugins] plugin.

db:migrate:plugins

Running db:migrate:plugins will run the migrations for every plugin that is loaded. You can also specify exactly which plugin you want to migrate.

Examples:

Assuming the following directory structure:

  vendor/
  vendor/plugins/
  vendor/plugins/acts_as_bunny/
  vendor/plugins/acts_as_as_chicken/

  rake db:migrate:plugins # Migrates both acts_as_bunny and acts_as_chicken
  rake db:migrate:plugins PLUGIN=acts_as_bunny
  rake db:migrate:plugins PLUGIN=acts_as_bunny VERSION=2

db:fixtures:load:plugins

Running db:fixtures:load:plugins will load the fixtures for every plugin that is loaded. You can also specify exactly which plugin you want to load fixtures for.

Examples:

Assuming the following directory structure:

  vendor/
  vendor/plugins/
  vendor/plugins/acts_as_bunny/
  vendor/plugins/acts_as_as_chicken/

  rake db:fixtures:load:plugins # Loads fixtures for both acts_as_bunny and acts_as_chicken
  rake db:fixtures:load:plugins PLUGIN=acts_as_bunny
  rake db:fixtures:load:plugins PLUGIN=acts_as_bunny FIXTURES=bunnies
  rake db:fixtures:load:plugins PLUGIN=acts_as_bunny FIXTURES=bunnies,rabbits

Testing

Before you can run any tests, the following gems must be installed:

Dependencies

This plugin dependencies on the presence of the following plugins:

References

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值