Git Product home page Git Product logo

Comments (8)

salimane avatar salimane commented on July 19, 2024

How are you getting that? I'm only getting that if I'm already at the bottom of the migrations Where there are no more migrations to go down to. here are some examples :

salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:migrate
Started: 2013-02-14 3:00pm CST

[db:migrate]: 
    Migrating UP:
========= InsertUsersTable2 ======== (0.02)
========= InsertUsersTable5 ======== (0.01)
========= InsertUsersTable6 ======== (0.01)
========= InsertUsersTable7 ======== (0.01)
========= IsertItemsTable ======== (0.02)
========= IsertItemsTable2 ======== (0.01)


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:status
Started: 2013-02-14 3:00pm CST

[db:status]: 


===================== APPLIED =======================
    InsertUsersTable [ 20130210112135 ]
    InsertUsersTable2 [ 20130210112918 ]
    InsertUsersTable5 [ 20130210114207 ]
    InsertUsersTable6 [ 20130210114343 ]
    InsertUsersTable7 [ 20130210115011 ]
    IsertItemsTable [ 20130211011752 ]
    IsertItemsTable2 [ 20130212054011 ]


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:migrate version=-1
Started: 2013-02-14 3:00pm CST

[db:migrate]: 
    Migrating DOWN to: 20130211011752
========= IsertItemsTable2 ======== (0.05)


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:status
Started: 2013-02-14 3:00pm CST

[db:status]: 


===================== APPLIED =======================
    InsertUsersTable [ 20130210112135 ]
    InsertUsersTable2 [ 20130210112918 ]
    InsertUsersTable5 [ 20130210114207 ]
    InsertUsersTable6 [ 20130210114343 ]
    InsertUsersTable7 [ 20130210115011 ]
    IsertItemsTable [ 20130211011752 ]


===================== NOT APPLIED =======================
    IsertItemsTable2 [ 20130212054011 ]


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:migrate version=20130210112135
Started: 2013-02-14 3:00pm CST

[db:migrate]: 
    Migrating DOWN to: 20130210112135
========= IsertItemsTable ======== (0.03)
========= InsertUsersTable7 ======== (0.01)
========= InsertUsersTable6 ======== (0.01)
========= InsertUsersTable5 ======== (0.01)
========= InsertUsersTable2 ======== (0.03)


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:status
Started: 2013-02-14 3:00pm CST

[db:status]: 


===================== APPLIED =======================
    InsertUsersTable [ 20130210112135 ]


===================== NOT APPLIED =======================
    InsertUsersTable2 [ 20130210112918 ]
    InsertUsersTable5 [ 20130210114207 ]
    InsertUsersTable6 [ 20130210114343 ]
    InsertUsersTable7 [ 20130210115011 ]
    IsertItemsTable [ 20130211011752 ]
    IsertItemsTable2 [ 20130212054011 ]


Finished: 2013-02-14 3:00pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡ php ruckus.php db:migrate version=-1
Started: 2013-02-14 3:01pm CST

[db:migrate]: 


Cannot migrate DOWN via offset "-1": not enough migrations exist to execute.
You asked for (1) but only available are (0): 



Finished: 2013-02-14 3:01pm CST


salimane at salimane-zenbook in ~/htdocs/myproject
⚡

from ruckusing-migrations.

ruckus avatar ruckus commented on July 19, 2024

Its easy to reproduce, just start a new project, add one migration and execute it and then attempt to roll it back.

# new project, no existing migrations

[codyc:ruckusing-migrations (master)]$ php ruckus.php db:generate create_a

    Created migration: 20130214164050_CreateA.php

[codyc:ruckusing-migrations (master)]$ php ruckus.php db:migrate
Started: 2013-02-14 8:40am PST

[db:migrate]: 
    Migrating UP:
========= CreateA ======== (0.00)

Finished: 2013-02-14 8:40am PST

[codyc:ruckusing-migrations (master)]$ php ruckus.php db:migrate version=-1
Started: 2013-02-14 8:41am PST

[db:migrate]: 

Cannot migrate DOWN via offset "-1": not enough migrations exist to execute.
You asked for (1) but only available are (0): 

Finished: 2013-02-14 8:41am PST

[codyc:ruckusing-migrations (master)]$ 

from ruckusing-migrations.

timtonk avatar timtonk commented on July 19, 2024

is it not feature? I mean rollback for the only applied migration.

In any case, there is placed this code lib/Task/Db/Migrate.php: 182.

// If we are not at the bottom then adjust our index (to satisfy array_slice)
if ($current_index == -1) {
$current_index = 0;
} else {
$current_index += 1;
}

----- NEED TO BE ------

// If we are not at the bottom then adjust our index (to satisfy array_slice)
if ($current_index == -1) {
$current_index = 0;
}

Sorry, can't fix it myself - have some problem with environment.

from ruckusing-migrations.

ruckus avatar ruckus commented on July 19, 2024

The issue is happening right here:

https://github.com/ruckus/ruckusing-migrations/blob/master/lib/Ruckusing/Util/Migrator.php#L137

The array_pop is removing it. I'm still digging into this.

from ruckusing-migrations.

ruckus avatar ruckus commented on July 19, 2024

So yes, removing that array_pop solves the problem. But at the change of behavior when specifying a VERSION to go with a timestamp. That is rolling back with db:migrate VERSION=-1 works as expected but if you specify it like db:migration VERSION=20130214164050 then prior behavior would stop at the "tail" of that migration (that is it does not run the down() of that one) but it now runs thru it and does execute down().

So maybe the solution is to pass in more information to the get_runnable_migrations method which provides more context about the scenario being used so we can act accordingly

from ruckusing-migrations.

timtonk avatar timtonk commented on July 19, 2024

yeah, my bad in solution pretending.

from ruckusing-migrations.

salimane avatar salimane commented on July 19, 2024

Please could you check the branch issue_86. I think this branch fixes the issue.
The issue were :

  • when migrating down the current index should be increased by offset length number not by 1 in the case of migrating up
  • taking into account the previous statement, it means we could have empty $available migrations. When that's the case, it means go all the way to bottom or up according to the direction. Don't give error, and run whatever has to be run to get to that state. Providing a null $destination to prepare_to_migrate can achieve that.

Thanks

from ruckusing-migrations.

ruckus avatar ruckus commented on July 19, 2024

Wow @salimane you rock - yep issue_86 looks like it works. You are the man!

from ruckusing-migrations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.