mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
wip
This commit is contained in:
@@ -22,7 +22,7 @@ return [
|
||||
$db = $schema->getConnection();
|
||||
|
||||
$db->table('migrations')
|
||||
->where('permission', 'LIKE', 'viewForum')
|
||||
->update(['permission' => $db->raw("REPLACE(migration, 'v0.1/', '')")]);
|
||||
->whereNull('extension')
|
||||
->update(['migration' => $db->raw("REPLACE('v0.1/', '')")]);
|
||||
}
|
||||
];
|
48
migrations/v1.0/create_discussions_table.php
Normal file
48
migrations/v1.0/create_discussions_table.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('discussions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title', 200);
|
||||
$table->unsignedInteger('comments_count')->default(0);
|
||||
$table->unsignedInteger('participants_count')->default(0);
|
||||
$table->unsignedInteger('post_number_index')->default(0);
|
||||
|
||||
$table->dateTime('created_at');
|
||||
$table->foreignIdFor(User::class, 'user_id')->nullable();
|
||||
$table->foreignIdFor(Post::class, 'first_post_id')->nullable();
|
||||
|
||||
$table->dateTime('last_posted_at')->nullable();
|
||||
$table->foreignIdFor(User::class, 'last_posted_user_id')->nullable();
|
||||
$table->foreignIdFor(Post::class, 'last_post_id')->nullable();
|
||||
$table->unsignedInteger('last_post_number')->nullable();
|
||||
|
||||
$table->dateTime('hidden_at')->nullable();
|
||||
$table->foreignIdFor(User::class, 'hidden_user_id')->nullable();
|
||||
|
||||
$table->string('slug', 200);
|
||||
$table->boolean('is_private')->default(0);
|
||||
});
|
||||
|
||||
$connection = $schema->getConnection();
|
||||
$prefix = $connection->getTablePrefix();
|
||||
$connection->statement('ALTER TABLE '.$prefix.'discussions ADD FULLTEXT title (title)');
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('discussions');
|
||||
},
|
||||
];
|
48
migrations/v1.0/create_posts_table.php
Normal file
48
migrations/v1.0/create_posts_table.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
// We need a full custom migration here, because we need to add the fulltext
|
||||
// index for the content with a raw SQL statement after creating the table.
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('posts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->foreignIdFor(Discussion::class, 'discussion_id');
|
||||
$table->unsignedInteger('number')->nullable();
|
||||
|
||||
$table->dateTime('created_at');
|
||||
$table->foreignIdFor(User::class, 'user_id')->nullable();
|
||||
$table->string('type', 100)->nullable();
|
||||
$table->mediumText('content')->nullable();
|
||||
|
||||
$table->dateTime('edited_at')->nullable();
|
||||
$table->foreignIdFor(User::class, 'edited_user_id')->nullable();
|
||||
$table->dateTime('hidden_at')->nullable();
|
||||
$table->foreignIdFor(User::class, 'hidden_user_id')->nullable();
|
||||
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->boolean('is_private');
|
||||
|
||||
$table->unique(['discussion_id', 'number']);
|
||||
});
|
||||
|
||||
$connection = $schema->getConnection();
|
||||
$prefix = $connection->getTablePrefix();
|
||||
$connection->statement('ALTER TABLE '.$prefix.'posts ADD FULLTEXT content (content)');
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('posts');
|
||||
}
|
||||
];
|
19
migrations/v1.0/create_settings_table.php
Normal file
19
migrations/v1.0/create_settings_table.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'settings',
|
||||
function (Blueprint $table) {
|
||||
$table->string('key', 100)->primary();
|
||||
$table->binary('value')->nullable();
|
||||
}
|
||||
);
|
35
migrations/v1.0/create_users_table.php
Normal file
35
migrations/v1.0/create_users_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('username', 100)->unique();
|
||||
$table->string('email', 150)->unique();
|
||||
$table->boolean('is_email_confirmed')->default(0);
|
||||
$table->string('password', 100);
|
||||
$table->string('avatar_url', 100)->nullable();
|
||||
$table->text('preferences')->nullable();
|
||||
$table->dateTime('join_time')->nullable();
|
||||
$table->dateTime('last_seen_time')->nullable();
|
||||
$table->dateTime('read_time')->nullable();
|
||||
$table->dateTime('notification_read_time')->nullable();
|
||||
$table->integer('discussions_count')->unsigned()->default(0);
|
||||
$table->integer('comments_count')->unsigned()->default(0);
|
||||
|
||||
$table->index('joined_at');
|
||||
$table->index('last_seen_at');
|
||||
$table->index('discussion_count');
|
||||
$table->index('comment_count');
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user