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