How do i rollback timestamp migrations. I'm using phalcon 3.3 and devtools 3.2.12 I have recently started off with phalcon for a pet project. coming from laravel, migration in phalcon isnt intuitive. Reasons
- version based migrations as a default isn't ideal in a team environment as version collisions might occur. e.g each team member might have a version 1 on their respective locals prior to commit etc.
- If I'm using a timestamp based migration, it means I need to fetch the entire timestamp/migration name string from db or file. while useful in certain case scenarios. its definitely not the easiest approach all the time. a simple rollback by steps and direction(up/down) seems more intuitive as a default.
now here goes my issue after tinkering for hours.. with no fruiton.. the docs are way too outdated. I was going to mention a 3rd issue with migration requiring options each time to use a timestamp based migration but I eventually stumbled on the config option in the code to set the defaults for that. Yes, another hours of wasted time. Now, i created one timestamp based migration. configured my ups and downs:
<?php
use Phalcon\Db\Column;
use Phalcon\Db\Index;
use Phalcon\Db\Reference;
use Phalcon\Mvc\Model\Migration;
/**
* Class FirewallMigration_1520187375551836
*/
class FirewallMigration_1520187375551836 extends Migration
{
/**
* Define the table structure
*
* @throws
* @return void
*/
public function morph()
{
$this->morphTable('firewall', [
'columns' => [
new Column('id', [
'type' => Column::TYPE_INTEGER,
'size' => 10,
'unsigned' => true,
'notNull' => true,
'autoIncrement' => true,
'first' => true,
]),
new Column('source', [
'type' => Column::TYPE_VARCHAR,
'size' => 10,
'notNull' => true,
]),
]);
}
/**
* Run the migrations
*
* @return void
*/
public function up()
{
// expected to morph on new migrations only -> hopeefully right with this.. not documented anywhere
}
/**
* Reverse the migrations
*
* @return void
*/
public function down()
{
print_r('i ran');
self::$_connection->dropTable('firewall');
}
}
running migrations for the first time.. this works fine.. but i'm trying to rollback this migration and now i'm stuck. no simple migrate up/down command. plus if I supply the current timestamp.. I just get a migrations are up to date message... what a drag.. in summary, how do I rollback to version 0? Please community where do I go from here.. hence no one is talking about this I can only assume I'm missing something.