Skip to content

Commit

Permalink
pkp#7486 Clean up of ViewDAO with related migration and files
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir authored and asmecher committed Feb 14, 2023
1 parent 5c95b22 commit 6b8153d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 157 deletions.
1 change: 0 additions & 1 deletion classes/core/PKPApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ public function getDAOMap()
'TemporaryInstitutionsDAO' => 'PKP\statistics\TemporaryInstitutionsDAO',
'UserStageAssignmentDAO' => 'PKP\user\UserStageAssignmentDAO',
'VersionDAO' => 'PKP\site\VersionDAO',
'ViewsDAO' => 'PKP\views\ViewsDAO',
'WorkflowStageDAO' => 'PKP\workflow\WorkflowStageDAO',
'XMLDAO' => 'PKP\db\XMLDAO',
];
Expand Down
4 changes: 0 additions & 4 deletions classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ public function up(): void
$table->foreign('publication_id')->references('publication_id')->on('publications')->onDelete('cascade');
$table->index(['publication_id'], 'publication_categories_publication_id');
});
Schema::table('item_views', function (Blueprint $table) {
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
$table->index(['user_id'], 'item_views_user_id');
});
Schema::table('genres', function (Blueprint $table) {
$table->foreign('context_id')->references($this->getContextKeyField())->on($this->getContextTable())->onDelete('cascade');
$table->index(['context_id'], 'genres_context_id');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
<?php

/**
* @file classes/migration/install/ViewsMigration.php
* @file classes/migration/upgrade/v3_4_0/I7486_RemoveItemViewsTable.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ViewsMigration
* @brief Describe database table structures.
* @class I7486_RemoveItemViewsTable
*/

namespace PKP\migration\install;
namespace PKP\migration\upgrade\v3_4_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use PKP\migration\Migration;

class ViewsMigration extends \PKP\migration\Migration
class I7486_RemoveItemViewsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Tracking of views for various types of objects such as files, reviews, etc
Schema::drop('item_views');
}

/**
* Reverse the migration.
*/
public function down(): void
{
Schema::create('item_views', function (Blueprint $table) {
$table->bigInteger('assoc_type');
$table->bigInteger('assoc_id');
Expand All @@ -36,12 +43,4 @@ public function up(): void
$table->unique(['assoc_type', 'assoc_id', 'user_id'], 'item_views_pkey');
});
}

/**
* Reverse the migration.
*/
public function down(): void
{
Schema::drop('item_views');
}
}
3 changes: 0 additions & 3 deletions classes/migration/upgrade/v3_4_0/PreflightCheckMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public function up(): void
DB::table('publication_categories')->where('publication_id', '=', $publicationId)->delete();
}

// Clean out orphaned views entries
DB::table('item_views AS v')->leftJoin('users AS u', 'v.user_id', '=', 'u.user_id')->whereNull('u.user_id')->whereNotNull('v.user_id')->delete();

// Clean orphaned genre data
$orphanedIds = DB::table('genres AS g')->leftJoin($this->getContextTable() . ' AS c', 'g.context_id', '=', 'c.' . $this->getContextKeyField())->whereNull('c.' . $this->getContextKeyField())->distinct()->pluck('g.genre_id');
foreach ($orphanedIds as $genreId) {
Expand Down
97 changes: 0 additions & 97 deletions classes/views/ViewsDAO.php

This file was deleted.

38 changes: 0 additions & 38 deletions xml/schema/views.xml

This file was deleted.

0 comments on commit 6b8153d

Please sign in to comment.