Remove old Tag commands, refactor migration etc

This commit is contained in:
James Brooks
2019-07-12 11:08:25 +01:00
parent 32a3adb43c
commit 3ac7492858
17 changed files with 5 additions and 680 deletions

View File

@@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/
use CachetHQ\Cachet\Models\Taggable;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
@@ -24,15 +23,16 @@ class MigrateComponentTagTable extends Migration
*/
public function up()
{
// Start by migrating the data into the new taggables field.
DB::table('component_tag')->get()->each(function ($tag) {
Taggable::create([
$tags = DB::table('component_tag')->get()->map(function ($tag) {
return [
'tag_id' => $tag->tag_id,
'taggable_type' => 'components',
'taggable_id' => $tag->component_id,
]);
];
});
DB::table('taggables')->insert($tags);
Schema::dropIfExists('component_tag');
}