Skip to content

Commit

Permalink
Namespace migrations to avoid potential conflicts
Browse files Browse the repository at this point in the history
Core migrations are under the Flarum\Migrations\Core namespace.
Extension migrations must be under the
Flarum\Migrations\{ExtensionName} namespace.

closes #422
  • Loading branch information
tobyzerner committed Sep 16, 2015
1 parent 633f84b commit 7fb582e
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 18 deletions.
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_access_tokens_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_api_keys_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_config_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_discussions_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_email_tokens_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_groups_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_notifications_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_permissions_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_posts_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_users_groups_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_02_24_000000_create_users_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
3 changes: 2 additions & 1 deletion migrations/2015_09_15_000000_create_auth_tokens_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of Flarum.
*
Expand All @@ -9,6 +8,8 @@
* file that was distributed with this source code.
*/

namespace Flarum\Migrations\Core;

use Flarum\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
10 changes: 6 additions & 4 deletions src/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function runUp($file, $extension)
// First we will resolve a "real" instance of the migration class from this
// migration file name. Once we have the instances we can run the actual
// command such as "up" or "down", or we can just simulate the action.
$migration = $this->resolve($file);
$migration = $this->resolve($file, $extension);

$migration->up();

Expand Down Expand Up @@ -181,7 +181,7 @@ protected function runDown($file, $extension = null)
// First we will get the file name of the migration so we can resolve out an
// instance of the migration. Once we get an instance we can either run a
// pretend execution of the migration or we can run the real migration.
$instance = $this->resolve($file);
$instance = $this->resolve($file, $extension);

$instance->down();

Expand Down Expand Up @@ -242,11 +242,13 @@ public function requireFiles($path, array $files)
* @param string $file
* @return object
*/
public function resolve($file)
public function resolve($file, $extension = null)
{
$file = implode('_', array_slice(explode('_', $file), 4));

$class = Str::studly($file);
$class = 'Flarum\\Migrations\\' . ($extension ? Str::studly($extension) : 'Core') . '\\';

$class .= Str::studly($file);

return app()->make($class);
}
Expand Down

0 comments on commit 7fb582e

Please sign in to comment.