mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 17:55:33 +08:00
restarted the branch using the already created migrations
This commit is contained in:
parent
77bb82bda4
commit
2bd5e3bcc5
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('access_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('id', 'token');
|
||||
$table->renameColumn('lifetime', 'lifetime_seconds');
|
||||
$table->renameColumn('last_activity', 'last_activity_at');
|
||||
$table->dateTime('created_at');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('access_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('lifetime_seconds', 'lifetime');
|
||||
$table->renameColumn('last_activity_at', 'last_activity');
|
||||
$table->dropColumn('created_at');
|
||||
$table->renameColumn('token', 'id');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('access_tokens', function (Blueprint $table) {
|
||||
$table->dateTime('last_activity_at')->change();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('access_tokens', function (Blueprint $table) {
|
||||
$table->integer('last_activity_at')->change();
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('api_keys', function (Blueprint $table) {
|
||||
$table->renameColumn('id', 'key');
|
||||
$table->dropPrimary(['id', 'key']);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('api_keys', function (Blueprint $table) {
|
||||
$table->renameColumn('key', 'id');
|
||||
$table->primary('id');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('api_keys', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('allowed_ips')->nullable();
|
||||
$table->string('scopes')->nullable();
|
||||
$table->integer('user_id')->unsigned()->nullable();
|
||||
$table->dateTime('created_at');
|
||||
$table->dateTime('last_activity_at')->nullable();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('api_keys', function (Blueprint $table) {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn('id', 'allowed_ips', 'user_id', 'scopes', 'created_at');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::renameTable('auth_tokens', 'registration_tokens');
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('registration_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('id', 'token');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('registration_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('token', 'id');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->renameColumn('comments_count', 'comment_count');
|
||||
$table->renameColumn('participants_count', 'participant_count');
|
||||
$table->renameColumn('number_index', 'post_number_index');
|
||||
$table->renameColumn('start_time', 'created_at');
|
||||
$table->renameColumn('start_user_id', 'user_id');
|
||||
$table->renameColumn('start_post_id', 'first_post_id');
|
||||
$table->renameColumn('last_time', 'last_posted_at');
|
||||
$table->renameColumn('last_user_id', 'last_posted_user_id');
|
||||
$table->renameColumn('hide_time', 'hidden_at');
|
||||
$table->renameColumn('hide_user_id', 'hidden_user_id');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->renameColumn('comment_count', 'comments_count');
|
||||
$table->renameColumn('participant_count', 'participants_count');
|
||||
$table->renameColumn('post_number_index', 'number_index');
|
||||
$table->renameColumn('created_at', 'start_time');
|
||||
$table->renameColumn('user_id', 'start_user_id');
|
||||
$table->renameColumn('first_post_id', 'start_post_id');
|
||||
$table->renameColumn('last_posted_at', 'last_time');
|
||||
$table->renameColumn('last_posted_user_id', 'last_user_id');
|
||||
$table->renameColumn('hidden_at', 'hide_time');
|
||||
$table->renameColumn('hidden_user_id', 'hide_user_id');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->rename('users_discussions', 'discussions_users');
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->rename('discussions_users', 'users_discussions');
|
||||
}
|
||||
];
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('discussions_users', function (Blueprint $table) {
|
||||
$table->renameColumn('read_time', 'last_read_at');
|
||||
$table->renameColumn('read_number', 'last_read_post_number');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('discussions_users', function (Blueprint $table) {
|
||||
$table->renameColumn('last_read_at', 'read_time');
|
||||
$table->renameColumn('last_read_post_number', 'read_number');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('email_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('id', 'token');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('email_tokens', function (Blueprint $table) {
|
||||
$table->renameColumn('token', 'id');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::renameTable('permissions', 'groups_permissions');
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::renameTable('users_groups', 'group_user');
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('notifications_from', function (Blueprint $table) {
|
||||
$table->integer('id')->unsigned();
|
||||
$table->integer('from_user_id')->unsigned();
|
||||
|
||||
$table->foreign('id')->references('id')->on('notifications')->onDelete('cascade');
|
||||
$table->foreign('from_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
$schema->getConnection()->table('notifications')->chunkById(100, function ($notifications) use ($schema) {
|
||||
foreach ($notifications as $notification) {
|
||||
$insert = [
|
||||
'id' => $notification->id,
|
||||
'from_user_id' => $notification->sender_id
|
||||
];
|
||||
|
||||
$schema->getConnection()->table('notifications_from')->updateOrInsert($insert, $insert);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('notifications_from');
|
||||
}
|
||||
];
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('notifications', function (Blueprint $table) {
|
||||
$table->dropColumn('sender_id', 'subject_type');
|
||||
|
||||
$table->renameColumn('time', 'created_at');
|
||||
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
});
|
||||
|
||||
$schema->getConnection()->table('notifications')
|
||||
->where('is_read', 1)
|
||||
->update(['read_at' => time()]);
|
||||
|
||||
$schema->getConnection()->table('notifications')
|
||||
->where('is_deleted', 1)
|
||||
->update(['deleted_at' => time()]);
|
||||
|
||||
$schema->table('notifications', function (Blueprint $table) {
|
||||
$table->dropColumn('is_read');
|
||||
$table->dropColumn('is_deleted');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('notifications', function (Blueprint $table) {
|
||||
$table->integer('sender_id')->unsigned()->nullable();
|
||||
$table->string('subject_type', 200)->nullable();
|
||||
|
||||
$table->renameColumn('created_at', 'time');
|
||||
|
||||
$table->boolean('is_read');
|
||||
$table->boolean('is_deleted');
|
||||
});
|
||||
|
||||
$schema->getConnection()->table('notifications')
|
||||
->whereNotNull('read_at')
|
||||
->update(['is_read' => 1]);
|
||||
$schema->getConnection()->table('notifications')
|
||||
->whereNotNull('deleted_at')
|
||||
->update(['is_deleted' => 1]);
|
||||
|
||||
$schema->table('notifications', function (Blueprint $table) {
|
||||
$table->dropColumn('read_at');
|
||||
$table->dropColumn('deleted_at');
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::renameColumn('password_tokens', 'id', 'token');
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->renameColumn('time', 'created_at');
|
||||
$table->renameColumn('edit_time', 'edited_at');
|
||||
$table->renameColumn('hide_time', 'hidden_at');
|
||||
|
||||
$table->renameColumn('edit_user_id', 'edited_user_id');
|
||||
$table->renameColumn('hide_user_id', 'hidden_user_id');
|
||||
|
||||
$table->longText('content')->change();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->renameColumn('created_at', 'time');
|
||||
$table->renameColumn('edited_at', 'edit_time');
|
||||
$table->renameColumn('hidden_at', 'hide_time');
|
||||
|
||||
$table->renameColumn('edited_user_id', 'edit_user_id');
|
||||
$table->renameColumn('edited_user_id', 'hidden_user_id');
|
||||
});
|
||||
|
||||
$prefix = $schema->getConnection()->getTablePrefix();
|
||||
$schema->getConnection()->statement('ALTER TABLE '.$prefix.'posts MODIFY content FULLTEXT');
|
||||
}
|
||||
];
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$prefix = $schema->getConnection()->getTablePrefix();
|
||||
// $schema->getConnection()->statement('ALTER TABLE '.$prefix.'settings MODIFY "value" LONGBLOB');
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
// $table->longText('value')->nullable()->change();
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('posts_users', function (Blueprint $table) {
|
||||
$table->integer('post_id')->unsigned();
|
||||
$table->integer('user_id')->unsigned();
|
||||
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('posts_users');
|
||||
}
|
||||
];
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('is_activated', 'is_email_confirmed');
|
||||
$table->renameColumn('join_time', 'joined_at');
|
||||
$table->renameColumn('last_seen_time', 'last_seen_at');
|
||||
$table->renameColumn('discussions_count', 'discussion_count');
|
||||
$table->renameColumn('comments_count', 'comment_count');
|
||||
$table->renameColumn('read_time', 'marked_all_as_read_at');
|
||||
$table->renameColumn('notifications_read_time', 'read_notifications_at');
|
||||
$table->renameColumn('avatar_path', 'avatar_url');
|
||||
$table->dropColumn('bio', 'preferences');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('is_email_confirmed', 'is_activated');
|
||||
$table->renameColumn('joined_at', 'join_time');
|
||||
$table->renameColumn('last_seen_at', 'last_seen_time');
|
||||
$table->renameColumn('discussion_count', 'discussions_count');
|
||||
$table->renameColumn('comment_count', 'comments_count');
|
||||
$table->renameColumn('marked_all_as_read_at', 'read_time');
|
||||
$table->renameColumn('read_notifications_at', 'notifications_read_time');
|
||||
$table->renameColumn('avatar_url', 'avatar_path');
|
||||
$table->text('bio')->nullable();
|
||||
$table->binary('preferences')->nullable();
|
||||
});
|
||||
}
|
||||
];
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('users_users', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('other_user_id')->unsigned();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('posts')->onDelete('cascade');
|
||||
$table->foreign('other_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('users_users');
|
||||
}
|
||||
];
|
Loading…
Reference in New Issue
Block a user