mirror of
https://github.com/flarum/core.git
synced 2025-08-07 08:56:38 +02:00
Update migrations, create default tag/settings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Flarum\Migrations\Migration;
|
||||
|
||||
class CreateDiscussionsTagsTable extends Migration
|
||||
{
|
||||
@@ -12,7 +12,7 @@ class CreateDiscussionsTagsTable extends Migration
|
||||
*/
|
||||
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('tag_id')->unsigned();
|
||||
$table->primary(['discussion_id', 'tag_id']);
|
||||
@@ -26,6 +26,6 @@ class CreateDiscussionsTagsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('discussions_tags');
|
||||
$this->schema->drop('discussions_tags');
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Flarum\Migrations\Migration;
|
||||
use Flarum\Tags\Tag;
|
||||
|
||||
class CreateTagsTable extends Migration
|
||||
{
|
||||
@@ -12,7 +13,7 @@ class CreateTagsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tags', function (Blueprint $table) {
|
||||
$this->schema->create('tags', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 100);
|
||||
$table->string('slug', 100);
|
||||
@@ -31,8 +32,15 @@ class CreateTagsTable extends Migration
|
||||
$table->integer('discussions_count')->unsigned()->default(0);
|
||||
$table->integer('last_time')->unsigned()->nullable();
|
||||
$table->integer('last_discussion_id')->unsigned()->nullable();
|
||||
|
||||
});
|
||||
|
||||
Tag::unguard();
|
||||
Tag::insert([
|
||||
'name' => 'General',
|
||||
'slug' => 'general',
|
||||
'color' => '#888',
|
||||
'position' => '0'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,6 +50,6 @@ class CreateTagsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('tags');
|
||||
$this->schema->drop('tags');
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Flarum\Migrations\Migration;
|
||||
|
||||
class CreateUsersTagsTable extends Migration
|
||||
{
|
||||
@@ -12,7 +12,7 @@ class CreateUsersTagsTable extends Migration
|
||||
*/
|
||||
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('tag_id')->unsigned();
|
||||
$table->dateTime('read_time')->nullable();
|
||||
@@ -28,6 +28,6 @@ class CreateUsersTagsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('users_tags');
|
||||
$this->schema->drop('users_tags');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Flarum\Migrations\Migration;
|
||||
use Flarum\Core\Settings\SettingsRepository;
|
||||
|
||||
class SetDefaultSettings extends Migration
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
public function __construct(SettingsRepository $settings, Builder $builder)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
|
||||
parent::__construct($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->settings->set('tags.max_primary_tags', '1');
|
||||
$this->settings->set('tags.min_primary_tags', '1');
|
||||
$this->settings->set('tags.max_secondary_tags', '3');
|
||||
$this->settings->set('tags.min_secondary_tags', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->settings->delete('tags.max_primary_tags');
|
||||
$this->settings->delete('tags.max_secondary_tags');
|
||||
$this->settings->delete('tags.min_primary_tags');
|
||||
$this->settings->delete('tags.min_secondary_tags');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user