mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 05:13:37 +08:00
Use new migration format
This commit is contained in:
parent
fb67393f81
commit
dd92088b5c
|
@ -8,24 +8,19 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tags\Migration;
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractMigration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
class CreateDiscussionsTagsTable extends AbstractMigration
|
return [
|
||||||
{
|
'up' => function (Builder $schema) {
|
||||||
public function up()
|
$schema->create('discussions_tags', function (Blueprint $table) {
|
||||||
{
|
|
||||||
$this->schema->create('discussions_tags', function (Blueprint $table) {
|
|
||||||
$table->integer('discussion_id')->unsigned();
|
$table->integer('discussion_id')->unsigned();
|
||||||
$table->integer('tag_id')->unsigned();
|
$table->integer('tag_id')->unsigned();
|
||||||
$table->primary(['discussion_id', 'tag_id']);
|
$table->primary(['discussion_id', 'tag_id']);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
public function down()
|
'down' => function (Builder $schema) {
|
||||||
{
|
$schema->drop('discussions_tags');
|
||||||
$this->schema->drop('discussions_tags');
|
|
||||||
}
|
}
|
||||||
}
|
];
|
||||||
|
|
|
@ -8,17 +8,13 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tags\Migration;
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractMigration;
|
|
||||||
use Flarum\Tags\Tag;
|
use Flarum\Tags\Tag;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
class CreateTagsTable extends AbstractMigration
|
return [
|
||||||
{
|
'up' => function (Builder $schema) {
|
||||||
public function up()
|
$schema->create('tags', function (Blueprint $table) {
|
||||||
{
|
|
||||||
$this->schema->create('tags', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('name', 100);
|
$table->string('name', 100);
|
||||||
$table->string('slug', 100);
|
$table->string('slug', 100);
|
||||||
|
@ -46,10 +42,9 @@ class CreateTagsTable extends AbstractMigration
|
||||||
'color' => '#888',
|
'color' => '#888',
|
||||||
'position' => '0'
|
'position' => '0'
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
|
||||||
public function down()
|
'down' => function (Builder $schema) {
|
||||||
{
|
$schema->drop('tags');
|
||||||
$this->schema->drop('tags');
|
|
||||||
}
|
}
|
||||||
}
|
];
|
||||||
|
|
|
@ -8,26 +8,21 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tags\Migration;
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractMigration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
class CreateUsersTagsTable extends AbstractMigration
|
return [
|
||||||
{
|
'up' => function (Builder $schema) {
|
||||||
public function up()
|
$schema->create('users_tags', function (Blueprint $table) {
|
||||||
{
|
|
||||||
$this->schema->create('users_tags', function (Blueprint $table) {
|
|
||||||
$table->integer('user_id')->unsigned();
|
$table->integer('user_id')->unsigned();
|
||||||
$table->integer('tag_id')->unsigned();
|
$table->integer('tag_id')->unsigned();
|
||||||
$table->dateTime('read_time')->nullable();
|
$table->dateTime('read_time')->nullable();
|
||||||
$table->boolean('is_hidden')->default(0);
|
$table->boolean('is_hidden')->default(0);
|
||||||
$table->primary(['user_id', 'tag_id']);
|
$table->primary(['user_id', 'tag_id']);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
public function down()
|
'down' => function (Builder $schema) {
|
||||||
{
|
$schema->drop('users_tags');
|
||||||
$this->schema->drop('users_tags');
|
|
||||||
}
|
}
|
||||||
}
|
];
|
||||||
|
|
|
@ -8,25 +8,20 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tags\Migration;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
|
|
||||||
use Flarum\Database\AbstractMigration;
|
return [
|
||||||
|
'up' => function (SettingsRepositoryInterface $settings) {
|
||||||
|
$settings->set('flarum-tags.max_primary_tags', '1');
|
||||||
|
$settings->set('flarum-tags.min_primary_tags', '1');
|
||||||
|
$settings->set('flarum-tags.max_secondary_tags', '3');
|
||||||
|
$settings->set('flarum-tags.min_secondary_tags', '0');
|
||||||
|
},
|
||||||
|
|
||||||
class SetDefaultSettings extends AbstractMigration
|
'down' => function (SettingsRepositoryInterface $settings) {
|
||||||
{
|
$settings->delete('flarum-tags.max_primary_tags');
|
||||||
public function up()
|
$settings->delete('flarum-tags.max_secondary_tags');
|
||||||
{
|
$settings->delete('flarum-tags.min_primary_tags');
|
||||||
$this->settings->set('flarum-tags.max_primary_tags', '1');
|
$settings->delete('flarum-tags.min_secondary_tags');
|
||||||
$this->settings->set('flarum-tags.min_primary_tags', '1');
|
|
||||||
$this->settings->set('flarum-tags.max_secondary_tags', '3');
|
|
||||||
$this->settings->set('flarum-tags.min_secondary_tags', '0');
|
|
||||||
}
|
}
|
||||||
|
];
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$this->settings->delete('flarum-tags.max_primary_tags');
|
|
||||||
$this->settings->delete('flarum-tags.max_secondary_tags');
|
|
||||||
$this->settings->delete('flarum-tags.min_primary_tags');
|
|
||||||
$this->settings->delete('flarum-tags.min_secondary_tags');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Flarum\Tags\Migration;
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractMigration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
|
||||||
class MakeSlugUnique extends AbstractMigration
|
return [
|
||||||
{
|
'up' => function (Builder $schema) {
|
||||||
public function up()
|
$schema->table('tags', function (Blueprint $table) {
|
||||||
{
|
|
||||||
$this->schema->table('tags', function (Blueprint $table) {
|
|
||||||
$table->string('slug', 100)->change();
|
$table->string('slug', 100)->change();
|
||||||
$table->unique('slug');
|
$table->unique('slug');
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
public function down()
|
'down' => function (Builder $schema) {
|
||||||
{
|
$schema->table('tags', function (Blueprint $table) {
|
||||||
$this->schema->table('tags', function (Blueprint $table) {
|
|
||||||
$table->string('slug', 255)->change();
|
$table->string('slug', 255)->change();
|
||||||
$table->dropUnique('tags_slug_unique');
|
$table->dropUnique('tags_slug_unique');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user