Forum: Ruby on Rails Plugin w/ Migrations and/or Fixtures?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
20381b12339f505894d6cff38d4696ca?d=identicon&s=25 Steve Sloan (Guest)
on 2005-12-14 21:34
(Received via mailing list)
I'm working on a plugin which needs to add both schema and data to the
app
database, and I'm trying to figure out the best way to do it.  I'd like
to use a
  db migration to modify the schema and load the data from a YAML
fixture, but
Rails doesn't seem to support migrations for plugins.  To do so, the
schema_info
table would need to change to include a plugin name field (with 'rails'
or NULL
for the application schema version), and corresponding mod to the Rake
tasks to
also run plugin migrations.

Is there another way I can accomplish this?  Is this a feature anyone
else is
wanting/working-on?  Is there any reason why this _wouldn't_ work?

Thanks ...

-- Steve
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2005-12-14 23:35
(Received via mailing list)
You might want to take a look at rails engines - we've implemented
migrations and fixtures to some extent for plugins (since engines are
first and foremost simply plugins themselves)

- james
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2005-12-14 23:50
(Received via mailing list)
On 12/14/05, Steve Sloan <steve@finagle.org> wrote:
>
> Thanks ...
>
> -- Steve

I submitted a patch for Migration generators.  I'm not sure if it made
it into 1.0, but it's definitely in trunk/1.1.  I have an example in
the acts as authenticated generator:
http://techno-weenie.net/svn/projects/plugins/acts...


--
rick
http://techno-weenie.net
20381b12339f505894d6cff38d4696ca?d=identicon&s=25 Steve Sloan (Guest)
on 2005-12-15 20:28
(Received via mailing list)
James Adam wrote:
> You might want to take a look at rails engines - we've implemented
> migrations and fixtures to some extent for plugins (since engines are
> first and foremost simply plugins themselves)

Good idea, but this is a small plugin (no controllers or views), and
right now
I'd just as soon avoid the overhead of making it an engine.

Rick Olson wrote:
 > I submitted a patch for Migration generators.  I'm not sure if it
made
 > it into 1.0, but it's definitely in trunk/1.1.

Also a good idea, but I'm not a big fan of generators in general (RoR
code is
*small*, and I like it that way.  Why generate more?)

In my case, neither of these suggestions were entirely satisfactory
because, in
addition to the (simple) table schema, I also have a large chunk of data
that
also needs to be loaded, but which I didn't want to keep around after it
was on
the DB.

Since rake tasks are already automagically supported for plugins, I
decided this
approached best suited my situation.  I mimicked the Rails
'create_sessions_table' task, which essentially is a migration.  I then
added my
own task to fetch, unzip, parse, and load the table data on the fly.
Works like
a charm. :)

Thanks for the help ...

-- Steve
This topic is locked and can not be replied to.