davedevelopment / phpmig

Simple migrations system for php
Other
568 stars 92 forks source link

Submodule migrations #9

Open Petah opened 13 years ago

Petah commented 13 years ago

This is more of a feature idea.

My projects are made up of a bunch of modules. It would be good if each module could keep its own migrations, but run them as part of an application.

For example I have this directory structure:

    project
    ¦   phpmig.php
    +---migrations
    +---modules
    ¦   +---cms
    ¦   ¦   +---migrations
    ¦   +---email
    ¦       +---migrations
    +---public
        ¦   index.php
        +---images
                etc...

Running phpmig on the project directory should run all migrations, including ones in sub modules.

There would be of course problems with the current logging format and DI containers. The logging of migrations that have been run would need to be stored in the project log file/DB. And each sub module would have to have a compatible DI object for accessing the database.

The log file (I haven't used DB logging) could be adapted like so:

    20111100133144
    20111100721245
    modules/cms/2011110054613
    modules/cms/2011110014658
    modules/email/2011110016455

I'm happy to implement this, what are you thoughts?

davedevelopment commented 13 years ago

I've kinda started something along these lines, my thoughts were that if you wanted a separate log for each migration sets, you'd have to provide phpmig with an adapter and an array of migrations for each set:


<?php 
$container['phpmig.sets']['cms'] = array(
    'adapter' => new Phpmig_Adapter_Flat_File(__DIR__ . '/modules/cms/migrations/.migrations.log'),
    'migrations' => glob(__DIR__ . '/modules/cms/migrations/*.php'),
);

That way, each database can have their own migrations table etc.

If you're not bothered about having separate logging, I'd just use the globbing e.g. glob(DIR . '/modules//migrations/.php'). In the unlikely event you have a name clash, I'd just change the timestamp on one of the migrations

reenl commented 11 years ago

[deleted]

davedevelopment commented 11 years ago

@reenl was that meant for a different issue?

reenl commented 11 years ago

Sorry see #45

eman1986 commented 8 years ago

how do you setup that phpmig.sets item, I keep getting Identifier "phpmig.sets" is not defined. when I do it the way described on this post.

eman1986 commented 8 years ago

seems to be a bug, I forked your code and looking to fix it