Skip to content

Commit

Permalink
pkp#10571 Add migration to install process
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Nov 13, 2024
1 parent ff6ada5 commit e0ac04f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* @file classes/migration/install/EmailTemplateUserGroupAccessMigration.php
*
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class HighlightsMigration
*
* @brief Describe database table structures for email template user group access
*/

namespace PKP\migration\install;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class EmailTemplateUserGroupAccessMigration
{
/**
* Run the migrations.
*/
public function up(): void
{
$contextDao = \APP\core\Application::getContextDAO();
Schema::create('email_template_user_group_access', function (Blueprint $table) use ($contextDao) {
$table->bigInteger('email_template_user_group_access_id')->autoIncrement()->comment('Primary key');
$table->string('email_key', 255)->comment("The email template's unique key");
$table->bigInteger('context_id')->comment('Identifier for the context for which the user group assignment occurs.');
$table->bigInteger('user_group_id')->nullable()->comment('The user group ID.');

$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade')->onDelete('cascade');
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::drop('email_template_user_group_access');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PKP\emailTemplate\EmailTemplateAccessGroup;
use PKP\migration\Migration;

class I10403_g extends Migration
class I10403_EmailTemplateUserGroupAccess extends Migration
{
/**
* Run the migrations.
Expand All @@ -18,13 +18,13 @@ public function up(): void
{
$contextDao = \APP\core\Application::getContextDAO();
Schema::create('email_template_user_group_access', function (Blueprint $table) use ($contextDao) {
$table->bigInteger('email_template_user_group_access_id')->autoIncrement();
$table->string('email_key', 255);
$table->bigInteger('context_id');
$table->bigInteger('user_group_id')->nullable();
$table->bigInteger('email_template_user_group_access_id')->autoIncrement()->comment('Primary key');
$table->string('email_key', 255)->comment("The email template's unique key.");
$table->bigInteger('context_id')->comment('Identifier for the context for which the user group assignment occurs.');
$table->bigInteger('user_group_id')->nullable()->comment('The user group ID.');

$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade')->onDelete('cascade');
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade')->onDelete('cascade');
});

$contextIds = array_map(fn (Context $context) => $context->getId(), $contextDao->getAll()->toArray());
Expand Down

0 comments on commit e0ac04f

Please sign in to comment.