Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submodule migrations #9

Open
Petah opened this issue Nov 8, 2011 · 6 comments
Open

Submodule migrations #9

Petah opened this issue Nov 8, 2011 · 6 comments

Comments

@Petah
Copy link
Contributor

Petah commented Nov 8, 2011

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
Copy link
Owner

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
Copy link
Contributor

reenl commented Aug 2, 2013

[deleted]

@davedevelopment
Copy link
Owner

@reenl was that meant for a different issue?

@reenl
Copy link
Contributor

reenl commented Aug 2, 2013

Sorry see #45

@eman1986
Copy link
Contributor

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants