first commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/AnnouncementsMigration.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 AnnouncementsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema as Schema;
|
||||
|
||||
class AnnouncementsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Announcement types.
|
||||
Schema::create('announcement_types', function (Blueprint $table) {
|
||||
$table->comment('Announcement types allow for announcements to optionally be categorized.');
|
||||
$table->bigInteger('type_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'announcement_types_context_id');
|
||||
});
|
||||
|
||||
// Locale-specific announcement type data
|
||||
Schema::create('announcement_type_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about announcement types, including localized properties like their names.');
|
||||
$table->bigIncrements('announcement_type_setting_id');
|
||||
$table->bigInteger('type_id');
|
||||
$table->foreign('type_id')->references('type_id')->on('announcement_types')->onDelete('cascade');
|
||||
$table->index(['type_id'], 'announcement_type_settings_type_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['type_id', 'locale', 'setting_name'], 'announcement_type_settings_unique');
|
||||
});
|
||||
|
||||
// Announcements.
|
||||
Schema::create('announcements', function (Blueprint $table) {
|
||||
$table->comment('Announcements are messages that can be presented to users e.g. on the homepage.');
|
||||
$table->bigInteger('announcement_id')->autoIncrement();
|
||||
// NOT NULL not included for upgrade purposes
|
||||
$table->smallInteger('assoc_type')->nullable();
|
||||
$table->bigInteger('assoc_id');
|
||||
|
||||
$table->bigInteger('type_id')->nullable();
|
||||
$table->foreign('type_id')->references('type_id')->on('announcement_types')->onDelete('set null');
|
||||
$table->index(['type_id'], 'announcements_type_id');
|
||||
|
||||
$table->date('date_expire')->nullable();
|
||||
$table->datetime('date_posted');
|
||||
$table->index(['assoc_type', 'assoc_id'], 'announcements_assoc');
|
||||
});
|
||||
|
||||
// Locale-specific announcement data
|
||||
Schema::create('announcement_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about announcements, including localized properties like names and contents.');
|
||||
$table->bigIncrements('announcement_setting_id');
|
||||
$table->bigInteger('announcement_id');
|
||||
$table->foreign('announcement_id')->references('announcement_id')->on('announcements')->onDelete('cascade');
|
||||
$table->index(['announcement_id'], 'announcement_settings_announcement_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['announcement_id', 'locale', 'setting_name'], 'announcement_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('announcement_settings');
|
||||
Schema::drop('announcements');
|
||||
Schema::drop('announcement_type_settings');
|
||||
Schema::drop('announcement_types');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/CategoriesMigration.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 CategoriesMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CategoriesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->comment('Categories permit the organization of submissions into a heirarchical structure.');
|
||||
$table->bigInteger('category_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'category_context_id');
|
||||
|
||||
$table->bigInteger('parent_id')->nullable(); // Self-referential foreign key set below
|
||||
|
||||
$table->bigInteger('seq')->nullable();
|
||||
$table->string('path', 255);
|
||||
$table->text('image')->nullable();
|
||||
|
||||
$table->index(['context_id', 'parent_id'], 'category_context_parent_id');
|
||||
$table->unique(['context_id', 'path'], 'category_path');
|
||||
});
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->foreign('parent_id')->references('category_id')->on('categories')->onDelete('set null');
|
||||
$table->index(['parent_id'], 'category_parent_id');
|
||||
});
|
||||
|
||||
// Category-specific settings
|
||||
Schema::create('category_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about categories, including localized properties such as names.');
|
||||
$table->bigIncrements('category_setting_id');
|
||||
$table->bigInteger('category_id');
|
||||
$table->foreign('category_id')->references('category_id')->on('categories')->onDelete('cascade');
|
||||
$table->index(['category_id'], 'category_settings_category_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['category_id', 'locale', 'setting_name'], 'category_settings_unique');
|
||||
});
|
||||
|
||||
// Associations for categories and publications.
|
||||
Schema::create('publication_categories', function (Blueprint $table) {
|
||||
$table->comment('Associates publications (and thus submissions) with categories.');
|
||||
$table->bigIncrements('publication_category_id');
|
||||
$table->bigInteger('publication_id');
|
||||
$table->foreign('publication_id')->references('publication_id')->on('publications')->onDelete('cascade');
|
||||
$table->index(['publication_id'], 'publication_categories_publication_id');
|
||||
|
||||
$table->bigInteger('category_id');
|
||||
$table->foreign('category_id')->references('category_id')->on('categories')->onDelete('cascade');
|
||||
$table->index(['category_id'], 'publication_categories_category_id');
|
||||
|
||||
$table->unique(['publication_id', 'category_id'], 'publication_categories_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('categories');
|
||||
Schema::drop('category_settings');
|
||||
Schema::drop('publication_categories');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/CommonMigration.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 CommonMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use APP\core\Application;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CommonMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('versions', function (Blueprint $table) {
|
||||
$table->comment('Describes the installation and upgrade version history for the application and all installed plugins.');
|
||||
$table->bigIncrements('version_id');
|
||||
$table->integer('major')->default(0)->comment('Major component of version number, e.g. the 2 in OJS 2.3.8-0');
|
||||
$table->integer('minor')->default(0)->comment('Minor component of version number, e.g. the 3 in OJS 2.3.8-0');
|
||||
$table->integer('revision')->default(0)->comment('Revision component of version number, e.g. the 8 in OJS 2.3.8-0');
|
||||
$table->integer('build')->default(0)->comment('Build component of version number, e.g. the 0 in OJS 2.3.8-0');
|
||||
$table->datetime('date_installed');
|
||||
$table->smallInteger('current')->default(0)->comment('1 iff the version entry being described is currently active. This permits the table to store past installation history for forensic purposes.');
|
||||
$table->string('product_type', 30)->comment('Describes the type of product this row describes, e.g. "plugins.generic" (for a generic plugin) or "core" for the application itself')->nullable();
|
||||
$table->string('product', 30)->comment('Uniquely identifies the product this version row describes, e.g. "ojs2" for OJS 2.x, "languageToggle" for the language toggle block plugin, etc.')->nullable();
|
||||
$table->string('product_class_name', 80)->comment('Specifies the class name associated with this product, for plugins, or the empty string where not applicable.')->nullable();
|
||||
$table->smallInteger('lazy_load')->default(0)->comment('1 iff the row describes a lazy-load plugin; 0 otherwise');
|
||||
$table->smallInteger('sitewide')->default(0)->comment('1 iff the row describes a site-wide plugin; 0 otherwise');
|
||||
$table->unique(['product_type', 'product', 'major', 'minor', 'revision', 'build'], 'versions_unique');
|
||||
});
|
||||
|
||||
// Common site settings.
|
||||
Schema::create('site', function (Blueprint $table) {
|
||||
$table->comment('A singleton table describing basic information about the site.');
|
||||
$table->bigIncrements('site_id');
|
||||
$table->bigInteger('redirect')->default(0)->comment('If not 0, redirect to the specified journal/conference/... site.');
|
||||
$table->string('primary_locale', 14)->comment('Primary locale for the site.');
|
||||
$table->smallInteger('min_password_length')->default(6);
|
||||
$table->string('installed_locales', 1024)->default('en')->comment('Locales for which support has been installed.');
|
||||
$table->string('supported_locales', 1024)->comment('Locales supported by the site (for hosted journals/conferences/...).')->nullable();
|
||||
$table->string('original_style_file_name', 255)->nullable();
|
||||
});
|
||||
|
||||
// Site settings.
|
||||
Schema::create('site_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about the site, including localized properties such as its name.');
|
||||
$table->bigIncrements('site_setting_id');
|
||||
$table->string('setting_name', 255);
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->unique(['setting_name', 'locale'], 'site_settings_unique');
|
||||
});
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->comment('All registered users, including authentication data and profile data.');
|
||||
$table->bigInteger('user_id')->autoIncrement();
|
||||
$table->string('username', 32);
|
||||
$table->string('password', 255);
|
||||
$table->string('email', 255);
|
||||
$table->string('url', 2047)->nullable();
|
||||
$table->string('phone', 32)->nullable();
|
||||
$table->string('mailing_address', 255)->nullable();
|
||||
$table->string('billing_address', 255)->nullable();
|
||||
$table->string('country', 90)->nullable();
|
||||
$table->string('locales', 255)->default('[]');
|
||||
$table->text('gossip')->nullable();
|
||||
$table->datetime('date_last_email')->nullable();
|
||||
$table->datetime('date_registered');
|
||||
$table->datetime('date_validated')->nullable();
|
||||
$table->datetime('date_last_login')->nullable();
|
||||
$table->smallInteger('must_change_password')->nullable();
|
||||
$table->bigInteger('auth_id')->nullable();
|
||||
$table->string('auth_str', 255)->nullable();
|
||||
$table->smallInteger('disabled')->default(0);
|
||||
$table->text('disabled_reason')->nullable();
|
||||
$table->smallInteger('inline_help')->nullable();
|
||||
});
|
||||
|
||||
switch (DB::getDriverName()) {
|
||||
case 'mysql':
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unique(['username'], 'users_username');
|
||||
$table->unique(['email'], 'users_email');
|
||||
});
|
||||
break;
|
||||
case 'pgsql':
|
||||
DB::unprepared('CREATE UNIQUE INDEX users_username on users (LOWER(username));');
|
||||
DB::unprepared('CREATE UNIQUE INDEX users_email on users (LOWER(email));');
|
||||
break;
|
||||
}
|
||||
|
||||
Schema::create('user_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about users, including localized properties like their name and affiliation.');
|
||||
$table->bigIncrements('user_setting_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'user_settings_user_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['user_id', 'locale', 'setting_name'], 'user_settings_unique');
|
||||
$table->index(['setting_name', 'locale'], 'user_settings_locale_setting_name_index');
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->comment('Session data for logged-in users.');
|
||||
$table->string('session_id', 128);
|
||||
|
||||
$table->bigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id', 'sessions_user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'sessions_user_id');
|
||||
|
||||
$table->string('ip_address', 39);
|
||||
$table->string('user_agent', 255)->nullable();
|
||||
$table->bigInteger('created')->default(0);
|
||||
$table->bigInteger('last_used')->default(0);
|
||||
$table->smallInteger('remember')->default(0);
|
||||
$table->text('data');
|
||||
$table->string('domain', 255)->nullable();
|
||||
|
||||
$table->unique(['session_id'], 'sessions_pkey');
|
||||
});
|
||||
|
||||
Schema::create('access_keys', function (Blueprint $table) {
|
||||
$table->comment('Access keys are used to provide pseudo-login functionality for security-minimal tasks. Passkeys can be emailed directly to users, who can use them for a limited time in lieu of standard username and password.');
|
||||
$table->bigInteger('access_key_id')->autoIncrement();
|
||||
$table->string('context', 40);
|
||||
$table->string('key_hash', 40);
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'access_keys_user_id');
|
||||
|
||||
$table->bigInteger('assoc_id')->nullable();
|
||||
$table->datetime('expiry_date');
|
||||
$table->index(['key_hash', 'user_id', 'context'], 'access_keys_hash');
|
||||
});
|
||||
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->comment('User notifications created during certain operations.');
|
||||
$table->bigInteger('notification_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id')->nullable();
|
||||
$contextDao = Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'notifications_context_id');
|
||||
|
||||
$table->bigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'notifications_user_id');
|
||||
|
||||
$table->bigInteger('level');
|
||||
$table->bigInteger('type');
|
||||
$table->datetime('date_created');
|
||||
$table->datetime('date_read')->nullable();
|
||||
$table->bigInteger('assoc_type')->nullable();
|
||||
$table->bigInteger('assoc_id')->nullable();
|
||||
$table->index(['context_id', 'user_id', 'level'], 'notifications_context_id_user_id');
|
||||
$table->index(['context_id', 'level'], 'notifications_context_id_level');
|
||||
$table->index(['assoc_type', 'assoc_id'], 'notifications_assoc');
|
||||
$table->index(['user_id', 'level'], 'notifications_user_id_level');
|
||||
});
|
||||
|
||||
// Stores metadata for specific notifications
|
||||
Schema::create('notification_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about notifications, including localized properties.');
|
||||
$table->bigIncrements('notification_setting_id');
|
||||
$table->bigInteger('notification_id');
|
||||
$table->foreign('notification_id')->references('notification_id')->on('notifications')->onDelete('cascade');
|
||||
$table->index(['notification_id'], 'notification_settings_notification_id');
|
||||
|
||||
$table->string('locale', 14)->nullable();
|
||||
$table->string('setting_name', 64);
|
||||
$table->mediumText('setting_value');
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
|
||||
$table->unique(['notification_id', 'locale', 'setting_name'], 'notification_settings_unique');
|
||||
});
|
||||
|
||||
Schema::create('notification_subscription_settings', function (Blueprint $table) {
|
||||
$table->comment('Which email notifications a user has chosen to unsubscribe from.');
|
||||
$table->bigInteger('setting_id')->autoIncrement();
|
||||
$table->string('setting_name', 64);
|
||||
$table->mediumText('setting_value');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'notification_subscription_settings_user_id');
|
||||
|
||||
$table->bigInteger('context');
|
||||
$contextDao = Application::getContextDAO();
|
||||
$table->foreign('context')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context'], 'notification_subscription_settings_context');
|
||||
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
|
||||
});
|
||||
|
||||
Schema::create('email_templates_default_data', function (Blueprint $table) {
|
||||
$table->comment('Default email templates created for every installed locale.');
|
||||
$table->bigIncrements('email_templates_default_data_id');
|
||||
$table->string('email_key', 255)->comment('Unique identifier for this email.');
|
||||
$table->string('locale', 14)->default('en');
|
||||
$table->string('name', 255);
|
||||
$table->string('subject', 255);
|
||||
$table->text('body')->nullable();
|
||||
$table->unique(['email_key', 'locale'], 'email_templates_default_data_unique');
|
||||
});
|
||||
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->comment('Custom email templates created by each context, and overrides of the default templates.');
|
||||
$table->bigInteger('email_id')->autoIncrement();
|
||||
$table->string('email_key', 255)->comment('Unique identifier for this email.');
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'email_templates_context_id');
|
||||
|
||||
$table->string('alternate_to', 255)->nullable();
|
||||
$table->index(['alternate_to'], 'email_templates_alternate_to');
|
||||
|
||||
$table->unique(['email_key', 'context_id'], 'email_templates_email_key');
|
||||
});
|
||||
|
||||
Schema::create('email_templates_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about custom email templates, including localized properties such as the subject and body.');
|
||||
$table->bigIncrements('email_template_setting_id');
|
||||
$table->bigInteger('email_id');
|
||||
$table->foreign('email_id', 'email_templates_settings_email_id')->references('email_id')->on('email_templates')->onDelete('cascade');
|
||||
$table->index(['email_id'], 'email_templates_settings_email_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['email_id', 'locale', 'setting_name'], 'email_templates_settings_unique');
|
||||
});
|
||||
|
||||
// Resumption tokens for the OAI protocol interface.
|
||||
Schema::create('oai_resumption_tokens', function (Blueprint $table) {
|
||||
$table->comment('OAI resumption tokens are used to allow for pagination of large result sets into manageable pieces.');
|
||||
$table->bigIncrements('oai_resumption_token_id');
|
||||
$table->string('token', 32);
|
||||
$table->bigInteger('expire');
|
||||
$table->integer('record_offset');
|
||||
$table->text('params')->nullable();
|
||||
$table->unique(['token'], 'oai_resumption_tokens_unique');
|
||||
});
|
||||
|
||||
// Plugin settings.
|
||||
Schema::create('plugin_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about plugins, including localized properties. This table is frequently used to store plugin-specific configuration.');
|
||||
$table->bigIncrements('plugin_setting_id');
|
||||
$table->string('plugin_name', 80);
|
||||
$table->bigInteger('context_id');
|
||||
$table->string('setting_name', 80);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
|
||||
$table->index(['plugin_name'], 'plugin_settings_plugin_name');
|
||||
$table->unique(['plugin_name', 'context_id', 'setting_name'], 'plugin_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('plugin_settings');
|
||||
Schema::drop('oai_resumption_tokens');
|
||||
Schema::drop('email_templates_settings');
|
||||
Schema::drop('email_templates');
|
||||
Schema::drop('email_templates_default_data');
|
||||
Schema::drop('mailable_templates');
|
||||
Schema::drop('notification_subscription_settings');
|
||||
Schema::drop('notification_settings');
|
||||
Schema::drop('notifications');
|
||||
Schema::drop('access_keys');
|
||||
Schema::drop('sessions');
|
||||
Schema::drop('user_settings');
|
||||
Schema::drop('users');
|
||||
Schema::drop('site_settings');
|
||||
Schema::drop('site');
|
||||
Schema::drop('versions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/ControlledVocabMigration.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 ControlledVocabMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ControlledVocabMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Controlled vocabularies
|
||||
Schema::create('controlled_vocabs', function (Blueprint $table) {
|
||||
$table->comment('Every word or phrase used in a controlled vocabulary. Controlled vocabularies are used for submission metadata like keywords and subjects, reviewer interests, and wherever a similar dictionary of words or phrases is required. Each entry corresponds to a word or phrase like "cellular reproduction" and a type like "submissionKeyword".');
|
||||
$table->bigInteger('controlled_vocab_id')->autoIncrement();
|
||||
$table->string('symbolic', 64);
|
||||
$table->bigInteger('assoc_type')->default(0);
|
||||
$table->bigInteger('assoc_id')->default(0);
|
||||
$table->unique(['symbolic', 'assoc_type', 'assoc_id'], 'controlled_vocab_symbolic');
|
||||
});
|
||||
|
||||
// Controlled vocabulary entries
|
||||
Schema::create('controlled_vocab_entries', function (Blueprint $table) {
|
||||
$table->comment('The order that a word or phrase used in a controlled vocabulary should appear. For example, the order of keywords in a publication.');
|
||||
$table->bigInteger('controlled_vocab_entry_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('controlled_vocab_id');
|
||||
$table->foreign('controlled_vocab_id')->references('controlled_vocab_id')->on('controlled_vocabs')->onDelete('cascade');
|
||||
$table->index(['controlled_vocab_id'], 'controlled_vocab_entries_controlled_vocab_id');
|
||||
|
||||
$table->float('seq', 8, 2)->nullable();
|
||||
$table->index(['controlled_vocab_id', 'seq'], 'controlled_vocab_entries_cv_id');
|
||||
});
|
||||
|
||||
// Controlled vocabulary entry settings
|
||||
Schema::create('controlled_vocab_entry_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about a controlled vocabulary entry, including localized properties such as the actual word or phrase.');
|
||||
$table->bigIncrements('controlled_vocab_entry_setting_id');
|
||||
$table->bigInteger('controlled_vocab_entry_id');
|
||||
$table->foreign('controlled_vocab_entry_id', 'c_v_e_s_entry_id')->references('controlled_vocab_entry_id')->on('controlled_vocab_entries')->onDelete('cascade');
|
||||
$table->index(['controlled_vocab_entry_id'], 'c_v_e_s_entry_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
$table->unique(['controlled_vocab_entry_id', 'locale', 'setting_name'], 'c_v_e_s_pkey');
|
||||
});
|
||||
|
||||
// Reviewer Interests Associative Table
|
||||
Schema::create('user_interests', function (Blueprint $table) {
|
||||
$table->comment('Associates users with user interests (which are stored in the controlled vocabulary tables).');
|
||||
$table->bigIncrements('user_interest_id');
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'user_interests_user_id');
|
||||
|
||||
$table->bigInteger('controlled_vocab_entry_id');
|
||||
$table->foreign('controlled_vocab_entry_id')->references('controlled_vocab_entry_id')->on('controlled_vocab_entries')->onDelete('cascade');
|
||||
$table->index(['controlled_vocab_entry_id'], 'user_interests_controlled_vocab_entry_id');
|
||||
|
||||
$table->unique(['user_id', 'controlled_vocab_entry_id'], 'u_e_pkey');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('user_interests');
|
||||
Schema::drop('controlled_vocab_entry_settings');
|
||||
Schema::drop('controlled_vocab_entries');
|
||||
Schema::drop('controlled_vocabs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/DoiMigration.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2000-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class DoiMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use PKP\migration\Migration;
|
||||
|
||||
class DoiMigration extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// NB: A foreign key constraint is placed on context_id, but this is application dependent and
|
||||
// needs to be added once the context has been created.
|
||||
// It will reference the app specific column (e.g. journal_id, press_id, etc.).
|
||||
Schema::create('dois', function (Blueprint $table) {
|
||||
$table->comment('Stores all DOIs used in the system.');
|
||||
$table->bigInteger('doi_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'dois_context_id');
|
||||
|
||||
$table->string('doi');
|
||||
$table->smallInteger('status')->default(1);
|
||||
});
|
||||
|
||||
// Settings
|
||||
Schema::create('doi_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about DOIs, including the registration agency.');
|
||||
$table->bigIncrements('doi_setting_id');
|
||||
$table->bigInteger('doi_id');
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['doi_id', 'locale', 'setting_name'], 'doi_settings_unique');
|
||||
$table->index(['doi_id'], 'doi_settings_doi_id');
|
||||
$table->foreign('doi_id')->references('doi_id')->on('dois')->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('dois');
|
||||
Schema::drop('doi_settings');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/FailedJobsMigration.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 FailedJobsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class FailedJobsMigration extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Schema matches https://github.com/illuminate/queue/blob/7.x/Console/stubs/failed_jobs.stub
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->comment('A log of all failed jobs.');
|
||||
$table->bigIncrements('id');
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration install/FilesMigration.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 FilesMigration
|
||||
*
|
||||
* @brief Create the files database table
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class FilesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->comment('Records information in the database about files tracked by the system, linking them to the local filesystem.');
|
||||
$table->bigIncrements('file_id');
|
||||
$table->string('path', 255);
|
||||
$table->string('mimetype', 255);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('files');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/GenresMigration.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 GenresMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use PKP\submission\Genre;
|
||||
|
||||
class GenresMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// A context's submission file genres.
|
||||
Schema::create('genres', function (Blueprint $table) {
|
||||
$table->comment('The types of submission files configured for each context, such as Article Text, Data Set, Transcript, etc.');
|
||||
$table->bigInteger('genre_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'genres_context_id');
|
||||
|
||||
$table->bigInteger('seq');
|
||||
$table->smallInteger('enabled')->default(1);
|
||||
|
||||
$table->bigInteger('category')->default(Genre::GENRE_CATEGORY_DOCUMENT);
|
||||
|
||||
$table->smallInteger('dependent')->default(0);
|
||||
$table->smallInteger('supplementary')->default(0);
|
||||
$table->smallInteger('required')->default(0)->comment('Whether or not at least one file of this genre is required for a new submission.');
|
||||
$table->string('entry_key', 30)->nullable();
|
||||
});
|
||||
|
||||
// Genre settings
|
||||
Schema::create('genre_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about file genres, including localized properties such as the genre name.');
|
||||
$table->bigIncrements('genre_setting_id');
|
||||
$table->bigInteger('genre_id');
|
||||
$table->foreign('genre_id')->references('genre_id')->on('genres')->onDelete('cascade');
|
||||
$table->index(['genre_id'], 'genre_settings_genre_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
|
||||
|
||||
$table->unique(['genre_id', 'locale', 'setting_name'], 'genre_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('genre_settings');
|
||||
Schema::drop('genres');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/HighlightsMigration.php
|
||||
*
|
||||
* Copyright (c) 2014-2023 Simon Fraser University
|
||||
* Copyright (c) 2000-2023 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class HighlightsMigration
|
||||
*
|
||||
* @brief Describe database table structures for highlights
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema as Schema;
|
||||
|
||||
class HighlightsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('highlights', function (Blueprint $table) {
|
||||
$table->comment('Highlights are featured items that can be presented to users, for example on the homepage.');
|
||||
$table->bigInteger('highlight_id')->autoIncrement();
|
||||
$table->bigInteger('context_id')->nullable();
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'highlights_context_id');
|
||||
|
||||
$table->bigInteger('sequence');
|
||||
$table->string('url', 2047);
|
||||
});
|
||||
|
||||
Schema::create('highlight_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about highlights, including localized properties like title and description.');
|
||||
$table->bigIncrements('highlight_setting_id');
|
||||
$table->bigInteger('highlight_id');
|
||||
$table->foreign('highlight_id')->references('highlight_id')->on('highlights')->onDelete('cascade');
|
||||
$table->index(['highlight_id'], 'highlight_settings_highlight_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['highlight_id', 'locale', 'setting_name'], 'highlight_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('highlight_settings');
|
||||
Schema::drop('highlights');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/InstitutionsMigration.php
|
||||
*
|
||||
* Copyright (c) 2022 Simon Fraser University
|
||||
* Copyright (c) 2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class InstitutionsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use APP\core\Application;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema as Schema;
|
||||
|
||||
class InstitutionsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('institutions', function (Blueprint $table) {
|
||||
$table->comment('Institutions for statistics and subscriptions.');
|
||||
$table->bigInteger('institution_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = Application::getContextDAO();
|
||||
$table->foreign('context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'institutions_context_id');
|
||||
|
||||
$table->string('ror', 255)->nullable()->comment('ROR (Research Organization Registry) ID');
|
||||
$table->softDeletes('deleted_at', 0);
|
||||
});
|
||||
|
||||
Schema::create('institution_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about institutions, including localized properties like names.');
|
||||
$table->bigIncrements('institution_setting_id');
|
||||
$table->bigInteger('institution_id');
|
||||
$table->foreign('institution_id')->references('institution_id')->on('institutions')->onDelete('cascade');
|
||||
$table->index(['institution_id'], 'institution_settings_institution_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['institution_id', 'locale', 'setting_name'], 'institution_settings_unique');
|
||||
});
|
||||
|
||||
// Institution IPs and IP ranges.
|
||||
Schema::create('institution_ip', function (Blueprint $table) {
|
||||
$table->comment('Records IP address ranges and associates them with institutions.');
|
||||
$table->bigInteger('institution_ip_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('institution_id');
|
||||
$table->foreign('institution_id')->references('institution_id')->on('institutions')->onDelete('cascade');
|
||||
$table->index(['institution_id'], 'institution_ip_institution_id');
|
||||
|
||||
$table->string('ip_string', 40);
|
||||
$table->bigInteger('ip_start');
|
||||
$table->bigInteger('ip_end')->nullable();
|
||||
|
||||
$table->index(['ip_start'], 'institution_ip_start');
|
||||
$table->index(['ip_end'], 'institution_ip_end');
|
||||
});
|
||||
|
||||
if (Schema::hasTable('institutional_subscriptions') && Schema::hasColumn('institutional_subscriptions', 'institution_id')) {
|
||||
Schema::table('institutional_subscriptions', function (Blueprint $table) {
|
||||
$table->comment('Links institutional subscriptions with institutions.');
|
||||
$table->foreign('institution_id')->references('institution_id')->on('institutions');
|
||||
$table->index(['institution_id'], 'institutional_subscriptions_institution_ip');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('institutional_subscriptions', function (Blueprint $table) {
|
||||
$table->dropForeign('institution_id');
|
||||
});
|
||||
Schema::drop('institution_settings');
|
||||
Schema::drop('institution_ip');
|
||||
Schema::drop('institutions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/JobsMigration.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 JobsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class JobsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->comment('All pending or in-progress jobs.');
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
|
||||
$table->index(['queue', 'reserved_at']);
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->comment('Job batches allow jobs to be collected into groups for managed processing.');
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->text('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('jobs');
|
||||
Schema::drop('job_batches');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/LibraryFilesMigration.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 LibraryFilesMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class LibraryFilesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Library files for a context
|
||||
Schema::create('library_files', function (Blueprint $table) {
|
||||
$table->comment('Library files can be associated with the context (press/server/journal) or with individual submissions, and are typically forms, agreements, and other administrative documents that are not part of the scholarly content.');
|
||||
$table->bigInteger('file_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id', 'library_files_context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'library_files_context_id');
|
||||
|
||||
$table->string('file_name', 255);
|
||||
$table->string('original_file_name', 255);
|
||||
$table->string('file_type', 255);
|
||||
$table->bigInteger('file_size');
|
||||
$table->smallInteger('type');
|
||||
$table->datetime('date_uploaded');
|
||||
$table->datetime('date_modified');
|
||||
|
||||
$table->bigInteger('submission_id')->nullable();
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'library_files_submission_id');
|
||||
|
||||
$table->smallInteger('public_access')->default(0)->nullable();
|
||||
});
|
||||
|
||||
// Library file metadata.
|
||||
Schema::create('library_file_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about library files, including localized content such as names.');
|
||||
$table->bigIncrements('library_file_setting_id');
|
||||
$table->bigInteger('file_id');
|
||||
$table->foreign('file_id')->references('file_id')->on('library_files')->onDelete('cascade');
|
||||
$table->index(['file_id'], 'library_file_settings_file_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object|date)');
|
||||
|
||||
$table->unique(['file_id', 'locale', 'setting_name'], 'library_file_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('library_file_settings');
|
||||
Schema::drop('library_files');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/LogMigration.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 LogMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class LogMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('event_log', function (Blueprint $table) {
|
||||
$table->comment('A log of all events related to an object like a submission.');
|
||||
$table->bigInteger('log_id')->autoIncrement();
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
|
||||
$table->bigInteger('user_id')->nullable()->comment('NULL if it\'s system or automated event');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'event_log_user_id');
|
||||
|
||||
$table->datetime('date_logged');
|
||||
$table->bigInteger('event_type')->nullable();
|
||||
$table->text('message')->nullable();
|
||||
$table->boolean('is_translated')->nullable();
|
||||
$table->index(['assoc_type', 'assoc_id'], 'event_log_assoc');
|
||||
});
|
||||
|
||||
Schema::create('event_log_settings', function (Blueprint $table) {
|
||||
$table->comment('Data about an event log entry. This data is commonly used to display information about an event to a user.');
|
||||
$table->bigIncrements('event_log_setting_id');
|
||||
$table->bigInteger('log_id');
|
||||
$table->foreign('log_id', 'event_log_settings_log_id')->references('log_id')->on('event_log')->onDelete('cascade');
|
||||
$table->index(['log_id'], 'event_log_settings_log_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->unique(['log_id', 'setting_name', 'locale'], 'event_log_settings_unique');
|
||||
});
|
||||
|
||||
// Add partial index (DBMS-specific)
|
||||
switch (DB::getDriverName()) {
|
||||
case 'mysql': DB::unprepared('CREATE INDEX event_log_settings_name_value ON event_log_settings (setting_name(50), setting_value(150))');
|
||||
break;
|
||||
case 'pgsql': DB::unprepared("CREATE INDEX event_log_settings_name_value ON event_log_settings (setting_name, setting_value) WHERE setting_name IN ('fileId', 'submissionId')");
|
||||
break;
|
||||
}
|
||||
|
||||
Schema::create('email_log', function (Blueprint $table) {
|
||||
$table->comment('A record of email messages that are sent in relation to an associated entity, such as a submission.');
|
||||
$table->bigInteger('log_id')->autoIncrement();
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
$table->bigInteger('sender_id');
|
||||
$table->datetime('date_sent');
|
||||
$table->bigInteger('event_type')->nullable();
|
||||
$table->string('from_address', 255)->nullable();
|
||||
$table->text('recipients')->nullable();
|
||||
$table->text('cc_recipients')->nullable();
|
||||
$table->text('bcc_recipients')->nullable();
|
||||
$table->string('subject', 255)->nullable();
|
||||
$table->text('body')->nullable();
|
||||
$table->index(['assoc_type', 'assoc_id'], 'email_log_assoc');
|
||||
});
|
||||
|
||||
// Associations for email logs within a user.
|
||||
Schema::create('email_log_users', function (Blueprint $table) {
|
||||
$table->comment('A record of users associated with an email log entry.');
|
||||
$table->bigIncrements('email_log_user_id');
|
||||
|
||||
$table->bigInteger('email_log_id');
|
||||
$table->foreign('email_log_id')->references('log_id')->on('email_log')->onDelete('cascade');
|
||||
$table->index(['email_log_id'], 'email_log_users_email_log_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'email_log_users_user_id');
|
||||
|
||||
$table->unique(['email_log_id', 'user_id'], 'email_log_user_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('email_log_users');
|
||||
Schema::drop('email_log');
|
||||
Schema::drop('event_log_settings');
|
||||
Schema::drop('event_log');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/MetadataMigration.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 MetadataMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MetadataMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Citations
|
||||
Schema::create('citations', function (Blueprint $table) {
|
||||
$table->comment('A citation made by an associated publication.');
|
||||
$table->bigInteger('citation_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('publication_id');
|
||||
$table->foreign('publication_id', 'citations_publication')->references('publication_id')->on('publications')->onDelete('cascade');
|
||||
$table->index(['publication_id'], 'citations_publication');
|
||||
|
||||
$table->text('raw_citation');
|
||||
$table->bigInteger('seq')->default(0);
|
||||
|
||||
$table->unique(['publication_id', 'seq'], 'citations_publication_seq');
|
||||
});
|
||||
|
||||
// Citation settings
|
||||
Schema::create('citation_settings', function (Blueprint $table) {
|
||||
$table->comment('Additional data about citations, including localized content.');
|
||||
$table->bigIncrements('citation_setting_id');
|
||||
$table->bigInteger('citation_id');
|
||||
$table->foreign('citation_id', 'citation_settings_citation_id')->references('citation_id')->on('citations')->onDelete('cascade');
|
||||
$table->index(['citation_id'], 'citation_settings_citation_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['citation_id', 'locale', 'setting_name'], 'citation_settings_unique');
|
||||
});
|
||||
|
||||
// Filter groups
|
||||
Schema::create('filter_groups', function (Blueprint $table) {
|
||||
$table->comment('Filter groups are used to organized filters into named sets, which can be retrieved by the application for invocation.');
|
||||
$table->bigInteger('filter_group_id')->autoIncrement();
|
||||
$table->string('symbolic', 255)->nullable();
|
||||
$table->string('display_name', 255)->nullable();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->string('input_type', 255)->nullable();
|
||||
$table->string('output_type', 255)->nullable();
|
||||
$table->unique(['symbolic'], 'filter_groups_symbolic');
|
||||
});
|
||||
|
||||
// Configured filter instances (transformations)
|
||||
Schema::create('filters', function (Blueprint $table) {
|
||||
$table->comment('Filters represent a transformation of a supported piece of data from one form to another, such as a PHP object into an XML document.');
|
||||
$table->bigInteger('filter_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('filter_group_id')->default(0);
|
||||
$table->foreign('filter_group_id')->references('filter_group_id')->on('filter_groups')->onDelete('cascade');
|
||||
$table->index(['filter_group_id'], 'filters_filter_group_id');
|
||||
|
||||
$table->bigInteger('context_id')->default(0);
|
||||
$table->string('display_name', 255)->nullable();
|
||||
$table->string('class_name', 255)->nullable();
|
||||
$table->smallInteger('is_template')->default(0);
|
||||
$table->bigInteger('parent_filter_id')->default(0);
|
||||
$table->bigInteger('seq')->default(0);
|
||||
});
|
||||
|
||||
// Filter Settings
|
||||
Schema::create('filter_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about filters, including localized content.');
|
||||
$table->bigIncrements('filter_setting_id');
|
||||
$table->bigInteger('filter_id');
|
||||
$table->foreign('filter_id')->references('filter_id')->on('filters')->onDelete('cascade');
|
||||
$table->index(['filter_id'], 'filter_settings_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['filter_id', 'locale', 'setting_name'], 'filter_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('filter_settings');
|
||||
Schema::drop('filters');
|
||||
Schema::drop('filter_groups');
|
||||
Schema::drop('citation_settings');
|
||||
Schema::drop('citations');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/NavigationMenusMigration.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 NavigationMenusMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class NavigationMenusMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// NavigationMenus
|
||||
Schema::create('navigation_menus', function (Blueprint $table) {
|
||||
$table->comment('Navigation menus on the website are installed with the software as a default set, and can be customized.');
|
||||
$table->bigInteger('navigation_menu_id')->autoIncrement();
|
||||
$table->bigInteger('context_id');
|
||||
$table->string('area_name', 255)->default('')->nullable();
|
||||
$table->string('title', 255);
|
||||
});
|
||||
|
||||
// NavigationMenuItems
|
||||
Schema::create('navigation_menu_items', function (Blueprint $table) {
|
||||
$table->comment('Navigation menu items are single elements within a navigation menu.');
|
||||
$table->bigInteger('navigation_menu_item_id')->autoIncrement();
|
||||
$table->bigInteger('context_id');
|
||||
$table->string('path', 255)->default('')->nullable();
|
||||
$table->string('type', 255)->default('')->nullable();
|
||||
});
|
||||
|
||||
// Locale-specific navigation menu item data
|
||||
Schema::create('navigation_menu_item_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about navigation menu items, including localized content such as names.');
|
||||
$table->bigIncrements('navigation_menu_item_setting_id');
|
||||
$table->bigInteger('navigation_menu_item_id');
|
||||
$table->foreign('navigation_menu_item_id', 'navigation_menu_item_settings_navigation_menu_id')->references('navigation_menu_item_id')->on('navigation_menu_items')->onDelete('cascade');
|
||||
$table->index(['navigation_menu_item_id'], 'navigation_menu_item_settings_navigation_menu_item_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->longText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['navigation_menu_item_id', 'locale', 'setting_name'], 'navigation_menu_item_settings_unique');
|
||||
});
|
||||
|
||||
// NavigationMenuItemAssignments which assign menu items to a menu and describe nested menu structure.
|
||||
Schema::create('navigation_menu_item_assignments', function (Blueprint $table) {
|
||||
$table->comment('Links navigation menu items to navigation menus.');
|
||||
$table->bigInteger('navigation_menu_item_assignment_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('navigation_menu_id');
|
||||
$table->foreign('navigation_menu_id')->references('navigation_menu_id')->on('navigation_menus')->onDelete('cascade');
|
||||
$table->index(['navigation_menu_id'], 'navigation_menu_item_assignments_navigation_menu_id');
|
||||
|
||||
$table->bigInteger('navigation_menu_item_id');
|
||||
$table->foreign('navigation_menu_item_id')->references('navigation_menu_item_id')->on('navigation_menu_items')->onDelete('cascade');
|
||||
$table->index(['navigation_menu_item_id'], 'navigation_menu_item_assignments_navigation_menu_item_id');
|
||||
|
||||
$table->bigInteger('parent_id')->nullable();
|
||||
$table->bigInteger('seq')->default(0)->nullable();
|
||||
});
|
||||
|
||||
// Locale-specific navigation menu item assignments data
|
||||
Schema::create('navigation_menu_item_assignment_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about navigation menu item assignments to navigation menus, including localized content.');
|
||||
$table->bigIncrements('navigation_menu_item_assignment_setting_id');
|
||||
$table->bigInteger('navigation_menu_item_assignment_id');
|
||||
$table->foreign('navigation_menu_item_assignment_id', 'assignment_settings_navigation_menu_item_assignment_id')->references('navigation_menu_item_assignment_id')->on('navigation_menu_item_assignments')->onDelete('cascade');
|
||||
$table->index(['navigation_menu_item_assignment_id'], 'navigation_menu_item_assignment_settings_n_m_i_a_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['navigation_menu_item_assignment_id', 'locale', 'setting_name'], 'navigation_menu_item_assignment_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('navigation_menu_item_assignment_settings');
|
||||
Schema::drop('navigation_menu_item_assignments');
|
||||
Schema::drop('navigation_menu_item_settings');
|
||||
Schema::drop('navigation_menu_items');
|
||||
Schema::drop('navigation_menus');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/NotesMigration.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 NotesMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class NotesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notes', function (Blueprint $table) {
|
||||
$table->comment('Notes allow users to annotate associated entities, such as submissions.');
|
||||
$table->bigInteger('note_id')->autoIncrement();
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'notes_user_id');
|
||||
|
||||
$table->datetime('date_created');
|
||||
$table->datetime('date_modified')->nullable();
|
||||
$table->string('title', 255)->nullable();
|
||||
$table->text('contents')->nullable();
|
||||
|
||||
$table->index(['assoc_type', 'assoc_id'], 'notes_assoc');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('notes');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/ReviewFormsMigration.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 ReviewFormsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ReviewFormsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Review forms.
|
||||
if (!Schema::hasTable('review_forms')) {
|
||||
Schema::create('review_forms', function (Blueprint $table) {
|
||||
$table->comment('Review forms provide custom templates for peer reviews with several types of questions.');
|
||||
$table->bigInteger('review_form_id')->autoIncrement();
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
$table->float('seq', 8, 2)->nullable();
|
||||
$table->smallInteger('is_active')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
// Review form settings
|
||||
if (!Schema::hasTable('review_form_settings')) {
|
||||
Schema::create('review_form_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about review forms, including localized content such as names.');
|
||||
$table->bigIncrements('review_form_setting_id');
|
||||
$table->bigInteger('review_form_id');
|
||||
$table->foreign('review_form_id', 'review_form_settings_review_form_id')->references('review_form_id')->on('review_forms')->onDelete('cascade');
|
||||
$table->index(['review_form_id'], 'review_form_settings_review_form_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['review_form_id', 'locale', 'setting_name'], 'review_form_settings_unique');
|
||||
});
|
||||
}
|
||||
|
||||
// Review form elements.
|
||||
if (!Schema::hasTable('review_form_elements')) {
|
||||
Schema::create('review_form_elements', function (Blueprint $table) {
|
||||
$table->comment('Each review form element represents a single question on a review form.');
|
||||
$table->bigInteger('review_form_element_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('review_form_id');
|
||||
$table->foreign('review_form_id', 'review_form_elements_review_form_id')->references('review_form_id')->on('review_forms')->onDelete('cascade');
|
||||
$table->index(['review_form_id'], 'review_form_elements_review_form_id');
|
||||
|
||||
$table->float('seq', 8, 2)->nullable();
|
||||
$table->bigInteger('element_type')->nullable();
|
||||
$table->smallInteger('required')->nullable();
|
||||
$table->smallInteger('included')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
// Review form element settings
|
||||
if (!Schema::hasTable('review_form_element_settings')) {
|
||||
Schema::create('review_form_element_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about review form elements, including localized content such as question text.');
|
||||
$table->bigIncrements('review_form_element_setting_id');
|
||||
$table->bigInteger('review_form_element_id');
|
||||
$table->foreign('review_form_element_id', 'review_form_element_settings_review_form_element_id')->references('review_form_element_id')->on('review_form_elements')->onDelete('cascade');
|
||||
$table->index(['review_form_element_id'], 'review_form_element_settings_review_form_element_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6);
|
||||
|
||||
$table->unique(['review_form_element_id', 'locale', 'setting_name'], 'review_form_element_settings_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('review_form_element_settings');
|
||||
Schema::drop('review_form_elements');
|
||||
Schema::drop('review_form_settings');
|
||||
Schema::drop('review_forms');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/ReviewsMigration.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 ReviewsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ReviewsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Review rounds.
|
||||
Schema::create('review_rounds', function (Blueprint $table) {
|
||||
$table->comment('Peer review assignments are organized into multiple rounds on a submission.');
|
||||
$table->bigInteger('review_round_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions');
|
||||
$table->index(['submission_id'], 'review_rounds_submission_id');
|
||||
|
||||
$table->bigInteger('stage_id')->nullable();
|
||||
$table->smallInteger('round');
|
||||
$table->bigInteger('review_revision')->nullable();
|
||||
$table->bigInteger('status')->nullable();
|
||||
$table->unique(['submission_id', 'stage_id', 'round'], 'review_rounds_submission_id_stage_id_round_pkey');
|
||||
});
|
||||
Schema::table('edit_decisions', function (Blueprint $table) {
|
||||
$table->foreign('review_round_id')->references('review_round_id')->on('review_rounds')->onDelete('cascade');
|
||||
$table->index(['review_round_id'], 'edit_decisions_review_round_id');
|
||||
});
|
||||
|
||||
// Reviewing assignments.
|
||||
Schema::create('review_assignments', function (Blueprint $table) {
|
||||
$table->comment('Data about peer review assignments for all submissions.');
|
||||
$table->bigInteger('review_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions');
|
||||
$table->index(['submission_id'], 'review_assignments_submission_id');
|
||||
|
||||
$table->bigInteger('reviewer_id');
|
||||
$table->foreign('reviewer_id')->references('user_id')->on('users');
|
||||
$table->index(['reviewer_id'], 'review_assignments_reviewer_id');
|
||||
|
||||
$table->text('competing_interests')->nullable();
|
||||
$table->smallInteger('recommendation')->nullable();
|
||||
$table->datetime('date_assigned')->nullable();
|
||||
$table->datetime('date_notified')->nullable();
|
||||
$table->datetime('date_confirmed')->nullable();
|
||||
$table->datetime('date_completed')->nullable();
|
||||
$table->datetime('date_acknowledged')->nullable();
|
||||
$table->datetime('date_due')->nullable();
|
||||
$table->datetime('date_response_due')->nullable();
|
||||
$table->datetime('last_modified')->nullable();
|
||||
$table->smallInteger('reminder_was_automatic')->default(0);
|
||||
$table->smallInteger('declined')->default(0);
|
||||
$table->smallInteger('cancelled')->default(0);
|
||||
$table->datetime('date_rated')->nullable();
|
||||
$table->datetime('date_reminded')->nullable();
|
||||
$table->smallInteger('quality')->nullable();
|
||||
|
||||
$table->bigInteger('review_round_id');
|
||||
$table->foreign('review_round_id')->references('review_round_id')->on('review_rounds');
|
||||
$table->index(['review_round_id', 'reviewer_id'], 'review_assignment_reviewer_round');
|
||||
|
||||
$table->smallInteger('stage_id');
|
||||
|
||||
$table->smallInteger('review_method')->default(\PKP\submission\reviewAssignment\ReviewAssignment::SUBMISSION_REVIEW_METHOD_ANONYMOUS);
|
||||
|
||||
$table->smallInteger('round')->default(1);
|
||||
$table->smallInteger('step')->default(1);
|
||||
|
||||
$table->bigInteger('review_form_id')->nullable();
|
||||
$table->foreign('review_form_id')->references('review_form_id')->on('review_forms');
|
||||
$table->index(['review_form_id'], 'review_assignments_form_id');
|
||||
|
||||
$table->smallInteger('considered')->nullable();
|
||||
$table->smallInteger('request_resent')->default(0);
|
||||
|
||||
// Normally reviewer can't be assigned twice on the same review round.
|
||||
// HOWEVER, if two reviewer user accounts are subsequently merged, both will keep
|
||||
// separate review assignments but the reviewer_id will become the same!
|
||||
// (https://github.com/pkp/pkp-lib/issues/7678)
|
||||
$table->index(['reviewer_id', 'review_id'], 'review_assignments_reviewer_review');
|
||||
});
|
||||
|
||||
// Review form responses.
|
||||
if (!Schema::hasTable('review_form_responses')) {
|
||||
Schema::create('review_form_responses', function (Blueprint $table) {
|
||||
$table->comment('Each review form response records a reviewer\'s answer to a review form element associated with a peer review.');
|
||||
$table->bigIncrements('review_form_response_id');
|
||||
$table->bigInteger('review_form_element_id');
|
||||
$table->foreign('review_form_element_id')->references('review_form_element_id')->on('review_form_elements')->onDelete('cascade');
|
||||
$table->index(['review_form_element_id'], 'review_form_responses_review_form_element_id');
|
||||
|
||||
$table->bigInteger('review_id');
|
||||
$table->foreign('review_id')->references('review_id')->on('review_assignments')->onDelete('cascade');
|
||||
$table->index(['review_id'], 'review_form_responses_review_id');
|
||||
|
||||
$table->string('response_type', 6)->nullable();
|
||||
$table->text('response_value')->nullable();
|
||||
|
||||
$table->index(['review_form_element_id', 'review_id'], 'review_form_responses_unique');
|
||||
});
|
||||
}
|
||||
|
||||
// Submission Files for each review round
|
||||
Schema::create('review_round_files', function (Blueprint $table) {
|
||||
$table->comment('Records the files made available to reviewers for a round of reviews. These can be further customized on a per review basis with review_files.');
|
||||
$table->bigIncrements('review_round_file_id');
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'review_round_files_submission_id');
|
||||
|
||||
$table->bigInteger('review_round_id');
|
||||
$table->foreign('review_round_id')->references('review_round_id')->on('review_rounds')->onDelete('cascade');
|
||||
$table->index(['review_round_id'], 'review_round_files_review_round_id');
|
||||
|
||||
$table->smallInteger('stage_id');
|
||||
|
||||
$table->bigInteger('submission_file_id')->nullable(false)->unsigned();
|
||||
$table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('cascade');
|
||||
$table->index(['submission_file_id'], 'review_round_files_submission_file_id');
|
||||
|
||||
$table->unique(['submission_id', 'review_round_id', 'submission_file_id'], 'review_round_files_unique');
|
||||
});
|
||||
|
||||
// Associates reviewable submission files with reviews
|
||||
Schema::create('review_files', function (Blueprint $table) {
|
||||
$table->comment('A list of the submission files made available to each assigned reviewer.');
|
||||
$table->bigIncrements('review_file_id');
|
||||
|
||||
$table->bigInteger('review_id');
|
||||
$table->foreign('review_id')->references('review_id')->on('review_assignments')->onDelete('cascade');
|
||||
$table->index(['review_id'], 'review_files_review_id');
|
||||
|
||||
$table->bigInteger('submission_file_id')->nullable(false)->unsigned();
|
||||
$table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('cascade');
|
||||
$table->index(['submission_file_id'], 'review_files_submission_file_id');
|
||||
|
||||
$table->unique(['review_id', 'submission_file_id'], 'review_files_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('review_form_responses');
|
||||
Schema::drop('review_assignments');
|
||||
Schema::drop('review_files');
|
||||
Schema::drop('review_round_files');
|
||||
Schema::drop('review_rounds');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/RolesAndUserGroupsMigration.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 RolesAndUserGroupsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use APP\core\Application;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RolesAndUserGroupsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_groups', function (Blueprint $table) {
|
||||
$table->comment('All defined user roles in a context, such as Author, Reviewer, Section Editor and Journal Manager.');
|
||||
$table->bigInteger('user_group_id')->autoIncrement();
|
||||
$table->bigInteger('context_id');
|
||||
$table->bigInteger('role_id');
|
||||
$table->smallInteger('is_default')->default(0);
|
||||
$table->smallInteger('show_title')->default(1);
|
||||
$table->smallInteger('permit_self_registration')->default(0);
|
||||
$table->smallInteger('permit_metadata_edit')->default(0);
|
||||
$table->index(['user_group_id'], 'user_groups_user_group_id');
|
||||
$table->index(['context_id'], 'user_groups_context_id');
|
||||
$table->index(['role_id'], 'user_groups_role_id');
|
||||
});
|
||||
|
||||
Schema::create('user_group_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about user groups, including localized properties such as the name.');
|
||||
$table->bigIncrements('user_group_setting_id');
|
||||
$table->bigInteger('user_group_id');
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['user_group_id', 'locale', 'setting_name'], 'user_group_settings_unique');
|
||||
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'user_group_settings_user_group_id');
|
||||
});
|
||||
|
||||
Schema::create('user_user_groups', function (Blueprint $table) {
|
||||
$table->comment('Maps users to their assigned user_groups.');
|
||||
$table->bigIncrements('user_user_group_id');
|
||||
$table->bigInteger('user_group_id');
|
||||
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'user_user_groups_user_group_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id', 'user_user_groups_user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'user_user_groups_user_id');
|
||||
|
||||
$table->unique(['user_group_id', 'user_id'], 'user_user_groups_unique');
|
||||
});
|
||||
|
||||
Schema::create('user_group_stage', function (Blueprint $table) {
|
||||
$table->comment('Which stages of the editorial workflow the user_groups can access.');
|
||||
$table->bigIncrements('user_group_stage_id');
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = Application::getContextDAO();
|
||||
$table->foreign('context_id', 'user_group_stage_context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'user_group_stage_context_id');
|
||||
|
||||
$table->bigInteger('user_group_id');
|
||||
$table->foreign('user_group_id', 'user_group_stage_user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'user_group_stage_user_group_id');
|
||||
|
||||
$table->bigInteger('stage_id');
|
||||
$table->index(['stage_id'], 'user_group_stage_stage_id');
|
||||
|
||||
$table->unique(['context_id', 'user_group_id', 'stage_id'], 'user_group_stage_unique');
|
||||
});
|
||||
|
||||
Schema::create('stage_assignments', function (Blueprint $table) {
|
||||
$table->comment('Who can access a submission while it is in the editorial workflow. Includes all editorial and author assignments. For reviewers, see review_assignments.');
|
||||
$table->bigInteger('stage_assignment_id')->autoIncrement();
|
||||
|
||||
// The foreign key for this column is declared with the submissions table.
|
||||
$table->bigInteger('submission_id');
|
||||
|
||||
$table->bigInteger('user_group_id');
|
||||
$table->foreign('user_group_id', 'stage_assignments_user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'stage_assignments_user_group_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id', 'stage_assignments_user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'stage_assignments_user_id');
|
||||
|
||||
$table->datetime('date_assigned');
|
||||
$table->smallInteger('recommend_only')->default(0);
|
||||
$table->smallInteger('can_change_metadata')->default(0);
|
||||
|
||||
$table->unique(['submission_id', 'user_group_id', 'user_id'], 'stage_assignment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('stage_assignments');
|
||||
Schema::drop('user_group_stage');
|
||||
Schema::drop('user_user_groups');
|
||||
Schema::drop('user_group_settings');
|
||||
Schema::drop('user_groups');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/ScheduledTasksMigration.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 ScheduledTasksMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ScheduledTasksMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// The last run times of all scheduled tasks.
|
||||
Schema::create('scheduled_tasks', function (Blueprint $table) {
|
||||
$table->comment('The last time each scheduled task was run.');
|
||||
$table->bigIncrements('scheduled_task_id');
|
||||
$table->string('class_name', 255);
|
||||
$table->datetime('last_run')->nullable();
|
||||
$table->unique(['class_name'], 'scheduled_tasks_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('scheduled_tasks');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/SubmissionFilesMigration.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 SubmissionFilesMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class SubmissionFilesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('submission_files', function (Blueprint $table) {
|
||||
$table->comment('All files associated with a submission, such as those uploaded during submission, as revisions, or by copyeditors or layout editors for production.');
|
||||
$table->bigIncrements('submission_file_id');
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id', 'submission_files_submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'submission_files_submission_id');
|
||||
|
||||
$table->bigInteger('file_id')->nullable(false)->unsigned();
|
||||
$table->foreign('file_id')->references('file_id')->on('files')->onDelete('cascade');
|
||||
$table->index(['file_id'], 'submission_files_file_id');
|
||||
|
||||
// FK declared below table (circular reference)
|
||||
$table->bigInteger('source_submission_file_id')->unsigned()->nullable();
|
||||
|
||||
$table->bigInteger('genre_id')->nullable();
|
||||
$table->foreign('genre_id')->references('genre_id')->on('genres')->onDelete('set null');
|
||||
$table->index(['genre_id'], 'submission_files_genre_id');
|
||||
|
||||
$table->bigInteger('file_stage');
|
||||
$table->string('direct_sales_price', 255)->nullable();
|
||||
$table->string('sales_type', 255)->nullable();
|
||||
$table->smallInteger('viewable')->nullable();
|
||||
$table->datetime('created_at');
|
||||
$table->datetime('updated_at');
|
||||
|
||||
$table->bigInteger('uploader_user_id')->nullable();
|
||||
$table->foreign('uploader_user_id')->references('user_id')->on('users')->onDelete('set null');
|
||||
$table->index(['uploader_user_id'], 'submission_files_uploader_user_id');
|
||||
|
||||
$table->bigInteger('assoc_type')->nullable();
|
||||
$table->bigInteger('assoc_id')->nullable();
|
||||
|
||||
// pkp/pkp-lib#5804
|
||||
$table->index(['file_stage', 'assoc_type', 'assoc_id'], 'submission_files_stage_assoc');
|
||||
});
|
||||
Schema::table('submission_files', function (Blueprint $table) {
|
||||
$table->foreign('source_submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('cascade');
|
||||
$table->index(['source_submission_file_id'], 'submission_files_source_submission_file_id');
|
||||
});
|
||||
|
||||
Schema::create('submission_file_settings', function (Blueprint $table) {
|
||||
$table->comment('Localized data about submission files like published metadata.');
|
||||
$table->bigIncrements('submission_file_setting_id');
|
||||
$table->foreignId('submission_file_id');
|
||||
$table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('cascade');
|
||||
$table->index(['submission_file_id'], 'submission_file_settings_submission_file_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['submission_file_id', 'locale', 'setting_name'], 'submission_file_settings_unique');
|
||||
});
|
||||
|
||||
// Submission file revisions
|
||||
Schema::create('submission_file_revisions', function (Blueprint $table) {
|
||||
$table->comment('Revisions map submission_file entries to files on the data store.');
|
||||
$table->bigIncrements('revision_id');
|
||||
|
||||
$table->bigInteger('submission_file_id')->unsigned();
|
||||
$table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('cascade');
|
||||
$table->index(['submission_file_id'], 'submission_file_revisions_submission_file_id');
|
||||
|
||||
$table->bigInteger('file_id')->unsigned();
|
||||
$table->foreign('file_id')->references('file_id')->on('files')->onDelete('cascade');
|
||||
$table->index(['file_id'], 'submission_file_revisions_file_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('submission_file_revisions');
|
||||
Schema::drop('submission_file_settings');
|
||||
Schema::drop('submission_files');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/SubmissionsMigration.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 SubmissionsMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use PKP\submission\PKPSubmission;
|
||||
|
||||
class SubmissionsMigration extends \PKP\migration\Migration
|
||||
{
|
||||
protected int $defaultStageId = WORKFLOW_STAGE_ID_SUBMISSION;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Submissions
|
||||
Schema::create('submissions', function (Blueprint $table) {
|
||||
$table->comment('All submissions submitted to the context, including incomplete, declined and unpublished submissions.');
|
||||
$table->bigInteger('submission_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id', 'submissions_context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'submissions_context_id');
|
||||
|
||||
// NOTE: The foreign key relationship on publications is declared where that table is created.
|
||||
$table->bigInteger('current_publication_id')->nullable();
|
||||
|
||||
$table->datetime('date_last_activity')->nullable();
|
||||
$table->datetime('date_submitted')->nullable();
|
||||
$table->datetime('last_modified')->nullable();
|
||||
$table->bigInteger('stage_id')->default($this->defaultStageId);
|
||||
$table->string('locale', 14)->nullable();
|
||||
|
||||
$table->smallInteger('status')->default(PKPSubmission::STATUS_QUEUED);
|
||||
|
||||
$table->string('submission_progress', 50)->default('start');
|
||||
// Used in OMP only; should not be null there
|
||||
$table->smallInteger('work_type')->default(0)->nullable();
|
||||
});
|
||||
Schema::table('stage_assignments', function (Blueprint $table) {
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'stage_assignments_submission_id');
|
||||
});
|
||||
|
||||
// Submission metadata
|
||||
Schema::create('submission_settings', function (Blueprint $table) {
|
||||
$table->comment('Localized data about submissions');
|
||||
$table->bigIncrements('submission_setting_id');
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'submission_settings_submission_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['submission_id', 'locale', 'setting_name'], 'submission_settings_unique');
|
||||
});
|
||||
|
||||
// publication metadata
|
||||
Schema::create('publication_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about publications, including localized properties such as the title and abstract.');
|
||||
$table->bigIncrements('publication_setting_id');
|
||||
|
||||
// The foreign key relationship on this table is defined with the publications table.
|
||||
$table->bigInteger('publication_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['publication_id', 'locale', 'setting_name'], 'publication_settings_unique');
|
||||
});
|
||||
// Add partial index (DBMS-specific)
|
||||
switch (DB::getDriverName()) {
|
||||
case 'mysql': DB::unprepared('CREATE INDEX publication_settings_name_value ON publication_settings (setting_name(50), setting_value(150))');
|
||||
break;
|
||||
case 'pgsql': DB::unprepared("CREATE INDEX publication_settings_name_value ON publication_settings (setting_name, setting_value) WHERE setting_name IN ('indexingState', 'medra::registeredDoi', 'datacite::registeredDoi', 'pub-id::publisher-id')");
|
||||
break;
|
||||
}
|
||||
|
||||
// Authors for submissions.
|
||||
Schema::create('authors', function (Blueprint $table) {
|
||||
$table->comment('The authors of a publication.');
|
||||
$table->bigInteger('author_id')->autoIncrement();
|
||||
$table->string('email', 90);
|
||||
$table->smallInteger('include_in_browse')->default(1);
|
||||
|
||||
// The foreign key relationship on this table is defined with the publications table.
|
||||
$table->bigInteger('publication_id');
|
||||
|
||||
$table->float('seq', 8, 2)->default(0);
|
||||
|
||||
$table->bigInteger('user_group_id')->nullable();
|
||||
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'authors_user_group_id');
|
||||
});
|
||||
|
||||
// Language dependent author metadata.
|
||||
Schema::create('author_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about authors, including localized properties such as their name and affiliation.');
|
||||
$table->bigIncrements('author_setting_id');
|
||||
$table->bigInteger('author_id');
|
||||
$table->foreign('author_id', 'author_settings_author_id')->references('author_id')->on('authors')->onDelete('cascade');
|
||||
$table->index(['author_id'], 'author_settings_author_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
|
||||
$table->unique(['author_id', 'locale', 'setting_name'], 'author_settings_unique');
|
||||
});
|
||||
|
||||
// Editor decisions.
|
||||
Schema::create('edit_decisions', function (Blueprint $table) {
|
||||
$table->comment('Editorial decisions recorded on a submission, such as decisions to accept or decline the submission, as well as decisions to send for review, send to copyediting, request revisions, and more.');
|
||||
$table->bigInteger('edit_decision_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id', 'edit_decisions_submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'edit_decisions_submission_id');
|
||||
|
||||
// Foreign key constraint is declared with review_rounds
|
||||
$table->bigInteger('review_round_id')->nullable();
|
||||
|
||||
$table->bigInteger('stage_id')->nullable();
|
||||
$table->smallInteger('round')->nullable();
|
||||
|
||||
$table->bigInteger('editor_id');
|
||||
$table->foreign('editor_id', 'edit_decisions_editor_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['editor_id'], 'edit_decisions_editor_id');
|
||||
|
||||
$table->smallInteger('decision')->comment('A numeric constant indicating the decision that was taken. Possible values are listed in the Decision class.');
|
||||
$table->datetime('date_decided');
|
||||
});
|
||||
|
||||
// Comments posted on submissions
|
||||
Schema::create('submission_comments', function (Blueprint $table) {
|
||||
$table->comment('Comments on a submission, e.g. peer review comments');
|
||||
$table->bigInteger('comment_id')->autoIncrement();
|
||||
$table->bigInteger('comment_type')->nullable();
|
||||
$table->bigInteger('role_id');
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id', 'submission_comments_submission_id')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'submission_comments_submission_id');
|
||||
|
||||
$table->bigInteger('assoc_id');
|
||||
|
||||
$table->bigInteger('author_id');
|
||||
$table->foreign('author_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['author_id'], 'submission_comments_author_id');
|
||||
|
||||
$table->text('comment_title');
|
||||
$table->text('comments')->nullable();
|
||||
$table->datetime('date_posted')->nullable();
|
||||
$table->datetime('date_modified')->nullable();
|
||||
$table->smallInteger('viewable')->nullable();
|
||||
});
|
||||
|
||||
// Assignments of sub editors to submission groups.
|
||||
Schema::create('subeditor_submission_group', function (Blueprint $table) {
|
||||
$table->comment('Subeditor assignments to e.g. sections and categories');
|
||||
$table->bigIncrements('subeditor_submission_group_id');
|
||||
$table->bigInteger('context_id');
|
||||
$contextDao = \APP\core\Application::getContextDAO();
|
||||
$table->foreign('context_id', 'section_editors_context_id')->references($contextDao->primaryKeyColumn)->on($contextDao->tableName)->onDelete('cascade');
|
||||
$table->index(['context_id'], 'subeditor_submission_group_context_id');
|
||||
|
||||
$table->bigInteger('assoc_id');
|
||||
$table->bigInteger('assoc_type');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id', 'subeditor_submission_group_user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'subeditor_submission_group_user_id');
|
||||
|
||||
$table->bigInteger('user_group_id');
|
||||
$table->foreign('user_group_id')->references('user_group_id')->on('user_groups')->onDelete('cascade');
|
||||
$table->index(['user_group_id'], 'subeditor_submission_group_user_group_id');
|
||||
|
||||
$table->index(['assoc_id', 'assoc_type'], 'subeditor_submission_group_assoc_id');
|
||||
$table->unique(['context_id', 'assoc_id', 'assoc_type', 'user_id', 'user_group_id'], 'section_editors_unique');
|
||||
});
|
||||
|
||||
// queries posted on submission workflow
|
||||
Schema::create('queries', function (Blueprint $table) {
|
||||
$table->comment('Discussions, usually related to a submission, created by editors, authors and other editorial staff.');
|
||||
$table->bigInteger('query_id')->autoIncrement();
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
$table->smallInteger('stage_id');
|
||||
$table->float('seq', 8, 2)->default(0);
|
||||
$table->datetime('date_posted')->nullable();
|
||||
$table->datetime('date_modified')->nullable();
|
||||
$table->smallInteger('closed')->default(0);
|
||||
$table->index(['assoc_type', 'assoc_id'], 'queries_assoc_id');
|
||||
});
|
||||
|
||||
// queries posted on submission workflow
|
||||
Schema::create('query_participants', function (Blueprint $table) {
|
||||
$table->comment('The users assigned to a discussion.');
|
||||
$table->bigIncrements('query_participant_id');
|
||||
$table->bigInteger('query_id');
|
||||
$table->foreign('query_id')->references('query_id')->on('queries')->onDelete('cascade');
|
||||
$table->index(['query_id'], 'query_participants_query_id');
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'query_participants_user_id');
|
||||
|
||||
$table->unique(['query_id', 'user_id'], 'query_participants_unique');
|
||||
});
|
||||
|
||||
// List of all keywords.
|
||||
Schema::create('submission_search_keyword_list', function (Blueprint $table) {
|
||||
$table->comment('A list of all keywords used in the search index');
|
||||
$table->bigInteger('keyword_id')->autoIncrement();
|
||||
$table->string('keyword_text', 60);
|
||||
$table->unique(['keyword_text'], 'submission_search_keyword_text');
|
||||
});
|
||||
|
||||
// Indexed objects.
|
||||
Schema::create('submission_search_objects', function (Blueprint $table) {
|
||||
$table->comment('A list of all search objects indexed in the search index');
|
||||
$table->bigInteger('object_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('submission_id');
|
||||
$table->foreign('submission_id', 'submission_search_object_submission')->references('submission_id')->on('submissions')->onDelete('cascade');
|
||||
$table->index(['submission_id'], 'submission_search_objects_submission_id');
|
||||
|
||||
$table->integer('type')->comment('Type of item. E.g., abstract, fulltext, etc.');
|
||||
$table->bigInteger('assoc_id')->comment('Optional ID of an associated record (e.g., a file_id)')->nullable();
|
||||
});
|
||||
|
||||
// Keyword occurrences for each indexed object.
|
||||
Schema::create('submission_search_object_keywords', function (Blueprint $table) {
|
||||
$table->comment('Relationships between search objects and keywords in the search index');
|
||||
$table->bigIncrements('submission_search_object_keyword_id');
|
||||
$table->bigInteger('object_id');
|
||||
$table->foreign('object_id')->references('object_id')->on('submission_search_objects')->onDelete('cascade');
|
||||
$table->index(['object_id'], 'submission_search_object_keywords_object_id');
|
||||
|
||||
$table->bigInteger('keyword_id');
|
||||
$table->foreign('keyword_id', 'submission_search_object_keywords_keyword_id')->references('keyword_id')->on('submission_search_keyword_list')->onDelete('cascade');
|
||||
$table->index(['keyword_id'], 'submission_search_object_keywords_keyword_id');
|
||||
|
||||
$table->integer('pos')->comment('Word position of the keyword in the object.');
|
||||
|
||||
$table->unique(['object_id', 'pos'], 'submission_search_object_keywords_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('submission_search_object_keywords');
|
||||
Schema::drop('submission_search_objects');
|
||||
Schema::drop('submission_search_keyword_list');
|
||||
Schema::drop('query_participants');
|
||||
Schema::drop('queries');
|
||||
Schema::drop('subeditor_submission_group');
|
||||
Schema::drop('submission_comments');
|
||||
Schema::drop('edit_decisions');
|
||||
Schema::drop('author_settings');
|
||||
Schema::drop('authors');
|
||||
Schema::drop('publication_settings');
|
||||
Schema::drop('submission_settings');
|
||||
Schema::drop('submissions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/TemporaryFilesMigration.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 TemporaryFilesMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class TemporaryFilesMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Temporary file storage
|
||||
Schema::create('temporary_files', function (Blueprint $table) {
|
||||
$table->comment('Temporary files, e.g. where files are kept during an upload process before they are moved somewhere more appropriate.');
|
||||
$table->bigInteger('file_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id', 'temporary_files_user_id')->references('user_id')->on('users')->onDelete('cascade');
|
||||
$table->index(['user_id'], 'temporary_files_user_id');
|
||||
|
||||
$table->string('file_name', 90);
|
||||
$table->string('file_type', 255)->nullable();
|
||||
$table->bigInteger('file_size');
|
||||
$table->string('original_file_name', 127)->nullable();
|
||||
$table->datetime('date_uploaded');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('temporary_files');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/migration/install/TombstoneMigration.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 TombstoneMigration
|
||||
*
|
||||
* @brief Describe database table structures.
|
||||
*/
|
||||
|
||||
namespace PKP\migration\install;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class TombstoneMigration extends \PKP\migration\Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Unavailable data object tombstones.
|
||||
Schema::create('data_object_tombstones', function (Blueprint $table) {
|
||||
$table->comment('Entries for published data that has been removed. Usually used in the OAI endpoint.');
|
||||
$table->bigInteger('tombstone_id')->autoIncrement();
|
||||
$table->bigInteger('data_object_id');
|
||||
$table->datetime('date_deleted');
|
||||
$table->string('set_spec', 255);
|
||||
$table->string('set_name', 255);
|
||||
$table->string('oai_identifier', 255);
|
||||
$table->index(['data_object_id'], 'data_object_tombstones_data_object_id');
|
||||
});
|
||||
|
||||
// Data object tombstone settings.
|
||||
Schema::create('data_object_tombstone_settings', function (Blueprint $table) {
|
||||
$table->comment('More data about data object tombstones, including localized content.');
|
||||
$table->bigIncrements('tombstone_setting_id');
|
||||
$table->bigInteger('tombstone_id');
|
||||
$table->foreign('tombstone_id', 'data_object_tombstone_settings_tombstone_id')->references('tombstone_id')->on('data_object_tombstones')->onDelete('cascade');
|
||||
$table->index(['tombstone_id'], 'data_object_tombstone_settings_tombstone_id');
|
||||
|
||||
$table->string('locale', 14)->default('');
|
||||
$table->string('setting_name', 255);
|
||||
$table->mediumText('setting_value')->nullable();
|
||||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
|
||||
|
||||
$table->unique(['tombstone_id', 'locale', 'setting_name'], 'data_object_tombstone_settings_unique');
|
||||
});
|
||||
|
||||
// Objects that are part of a data object tombstone OAI set.
|
||||
Schema::create('data_object_tombstone_oai_set_objects', function (Blueprint $table) {
|
||||
$table->comment('Relationships between tombstones and other data that can be collected in OAI sets, e.g. sections.');
|
||||
$table->bigInteger('object_id')->autoIncrement();
|
||||
|
||||
$table->bigInteger('tombstone_id');
|
||||
$table->foreign('tombstone_id', 'data_object_tombstone_oai_set_objects_tombstone_id')->references('tombstone_id')->on('data_object_tombstones')->onDelete('cascade');
|
||||
$table->index(['tombstone_id'], 'data_object_tombstone_oai_set_objects_tombstone_id');
|
||||
|
||||
$table->bigInteger('assoc_type');
|
||||
$table->bigInteger('assoc_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('data_object_tombstone_oai_set_objects');
|
||||
Schema::drop('data_object_tombstone_settings');
|
||||
Schema::drop('data_object_tombstones');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user