1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 00:47:00 +02:00

Revamp migration structure

They are now simply files that return an array of closures, for
running the named "up" and "down" actions, respectively.

Related to #732.
This commit is contained in:
Franz Liedke
2016-02-24 22:23:49 +09:00
parent 05fe4446bf
commit 51955504aa
21 changed files with 172 additions and 277 deletions

View File

@@ -8,16 +8,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Migration;
use Flarum\Database\AbstractMigration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
class CreatePostsTable extends AbstractMigration
{
public function up()
{
$this->schema->create('posts', function (Blueprint $table) {
return [
'up' => function (Builder $schema) {
$schema->create('posts', function (Blueprint $table) {
$table->increments('id');
$table->integer('discussion_id')->unsigned();
$table->integer('number')->unsigned()->nullable();
@@ -37,12 +33,11 @@ class CreatePostsTable extends AbstractMigration
$table->engine = 'MyISAM';
});
$prefix = $this->schema->getConnection()->getTablePrefix();
$this->schema->getConnection()->statement('ALTER TABLE '.$prefix.'posts ADD FULLTEXT content (content)');
}
$prefix = $schema->getConnection()->getTablePrefix();
$schema->getConnection()->statement('ALTER TABLE '.$prefix.'posts ADD FULLTEXT content (content)');
},
public function down()
{
$this->schema->drop('posts');
'down' => function (Builder $schema) {
$schema->drop('posts');
}
}
];