forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp#2493 Convert xmlSchema descriptors to migrations
- Loading branch information
Showing
20 changed files
with
1,612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/AnnouncementsMigration.inc.php | ||
* | ||
* Copyright (c) 2014-2020 Simon Fraser University | ||
* Copyright (c) 2000-2020 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class AnnouncementsMigration | ||
* @brief Describe database table structures. | ||
*/ | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Builder; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
class AnnouncementsMigration extends Migration { | ||
/** | ||
* Run the migrations. | ||
* @return void | ||
*/ | ||
public function up() { | ||
// Announcement types. | ||
Capsule::schema()->create('announcement_types', function (Blueprint $table) { | ||
$table->bigInteger('type_id')->autoIncrement(); | ||
$table->unique(['type_id']); | ||
// NOT NULL not included for upgrade purposes | ||
$table->smallInteger('assoc_type')->nullable(); | ||
$table->bigInteger('assoc_id'); | ||
$table->index(['assoc_type', 'assoc_id'], 'announcement_types_assoc'); | ||
}); | ||
|
||
// Locale-specific announcement type data | ||
Capsule::schema()->create('announcement_type_settings', function (Blueprint $table) { | ||
$table->bigInteger('type_id'); | ||
$table->string('locale', 14)->default(''); | ||
$table->string('setting_name', 255); | ||
$table->text('setting_value')->nullable(); | ||
$table->string('setting_type', 6); | ||
$table->index(['type_id'], 'announcement_type_settings_type_id'); | ||
$table->unique(['type_id', 'locale', 'setting_name'], 'announcement_type_settings_pkey'); | ||
}); | ||
|
||
// Announcements. | ||
Capsule::schema()->create('announcements', function (Blueprint $table) { | ||
$table->bigInteger('announcement_id')->autoIncrement(); | ||
$table->unique(['announcement_id']); | ||
// NOT NULL not included for upgrade purposes | ||
$table->smallInteger('assoc_type')->nullable(); | ||
$table->bigInteger('assoc_id'); | ||
$table->bigInteger('type_id')->nullable(); | ||
$table->timestamp('date_expire')->nullable(); | ||
$table->timestamp('date_posted'); | ||
$table->index(['assoc_type', 'assoc_id'], 'announcements_assoc'); | ||
}); | ||
|
||
// Locale-specific announcement data | ||
Capsule::schema()->create('announcement_settings', function (Blueprint $table) { | ||
$table->bigInteger('announcement_id'); | ||
$table->string('locale', 14)->default(''); | ||
$table->string('setting_name', 255); | ||
$table->text('setting_value')->nullable(); | ||
$table->string('setting_type', 6); | ||
$table->index(['announcement_id'], 'announcement_settings_announcement_id'); | ||
$table->unique(['announcement_id', 'locale', 'setting_name'], 'announcement_settings_pkey'); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/CategoriesMigration.inc.php | ||
* | ||
* Copyright (c) 2014-2020 Simon Fraser University | ||
* Copyright (c) 2000-2020 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class CategoriesMigration | ||
* @brief Describe database table structures. | ||
*/ | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Builder; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
class CategoriesMigration extends Migration { | ||
/** | ||
* Run the migrations. | ||
* @return void | ||
*/ | ||
public function up() { | ||
// Permits the organization of content into categories. | ||
Capsule::schema()->create('categories', function (Blueprint $table) { | ||
$table->bigInteger('category_id')->autoIncrement(); | ||
$table->unique(['category_id']); | ||
$table->bigInteger('context_id'); | ||
$table->bigInteger('parent_id'); | ||
$table->bigInteger('seq')->nullable(); | ||
$table->string('path', 255); | ||
$table->text('image')->nullable(); | ||
$table->index(['context_id', 'parent_id'], 'category_context_id'); | ||
$table->unique(['context_id', 'path'], 'category_path'); | ||
}); | ||
|
||
// Category-specific settings | ||
Capsule::schema()->create('category_settings', function (Blueprint $table) { | ||
$table->bigInteger('category_id'); | ||
$table->string('locale', 14)->default(''); | ||
$table->string('setting_name', 255); | ||
$table->text('setting_value')->nullable(); | ||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)'); | ||
$table->unique(['category_id', 'locale', 'setting_name'], 'category_settings_pkey'); | ||
}); | ||
|
||
// Associations for categories and publications. | ||
Capsule::schema()->create('publication_categories', function (Blueprint $table) { | ||
$table->bigInteger('publication_id'); | ||
$table->bigInteger('category_id'); | ||
$table->unique(['publication_id', 'category_id'], 'publication_categories_id'); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/CommonMigration.inc.php | ||
* | ||
* Copyright (c) 2014-2020 Simon Fraser University | ||
* Copyright (c) 2000-2020 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class CommonMigration | ||
* @brief Describe database table structures. | ||
*/ | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Builder; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
class CommonMigration extends Migration { | ||
/** | ||
* Run the migrations. | ||
* @return void | ||
*/ | ||
public function up() { | ||
// Describes the installation and upgrade version history for the application and all installed plugins. | ||
Capsule::schema()->create('versions', function (Blueprint $table) { | ||
$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->timestamp('date_installed'); | ||
$table->boolean('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 itelf')->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->boolean('lazy_load')->default('0')->comment('1 iff the row describes a lazy-load plugin; 0 otherwise'); | ||
$table->boolean('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_pkey'); | ||
}); | ||
|
||
// Common site settings. | ||
Capsule::schema()->create('site', function (Blueprint $table) { | ||
$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->boolean('min_password_length')->default('6'); | ||
$table->string('installed_locales', 1024)->default('en_US')->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. | ||
Capsule::schema()->create('site_settings', function (Blueprint $table) { | ||
$table->string('setting_name', 255); | ||
$table->string('locale', 14)->default(''); | ||
$table->text('setting_value')->nullable(); | ||
$table->unique(['setting_name', 'locale'], 'site_settings_pkey'); | ||
}); | ||
|
||
// User authentication sources. | ||
Capsule::schema()->create('auth_sources', function (Blueprint $table) { | ||
$table->bigInteger('auth_id')->autoIncrement(); | ||
$table->unique(['auth_id']); | ||
$table->string('title', 60); | ||
$table->string('plugin', 32); | ||
$table->boolean('auth_default')->default('0'); | ||
$table->text('settings')->nullable(); | ||
}); | ||
|
||
// User authentication credentials and profile data. | ||
Capsule::schema()->create('users', function (Blueprint $table) { | ||
$table->bigInteger('user_id')->autoIncrement(); | ||
$table->unique(['user_id']); | ||
$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)->nullable(); | ||
$table->text('gossip')->nullable(); | ||
$table->timestamp('date_last_email')->nullable(); | ||
$table->timestamp('date_registered'); | ||
$table->timestamp('date_validated')->nullable(); | ||
$table->timestamp('date_last_login'); | ||
$table->boolean('must_change_password')->nullable(); | ||
$table->bigInteger('auth_id')->nullable(); | ||
$table->string('auth_str', 255)->nullable(); | ||
$table->boolean('disabled')->default('0'); | ||
$table->text('disabled_reason')->nullable(); | ||
$table->boolean('inline_help')->nullable(); | ||
$table->unique(['username'], 'users_username'); | ||
$table->unique(['email'], 'users_email'); | ||
}); | ||
|
||
// Locale-specific user data | ||
Capsule::schema()->create('user_settings', function (Blueprint $table) { | ||
$table->bigInteger('user_id'); | ||
$table->string('locale', 14)->default(''); | ||
$table->string('setting_name', 255); | ||
// Not null not specified for sake of upgrade. | ||
$table->bigInteger('assoc_type')->default('0')->nullable(); | ||
// Not null not specified for sake of upgrade. | ||
$table->bigInteger('assoc_id')->default('0')->nullable(); | ||
$table->text('setting_value')->nullable(); | ||
$table->string('setting_type', 6); | ||
$table->index(['user_id'], 'user_settings_user_id'); | ||
$table->unique(['user_id', 'locale', 'setting_name', 'assoc_type', 'assoc_id'], 'user_settings_pkey'); | ||
}); | ||
|
||
// Browser/user sessions and session data. | ||
Capsule::schema()->create('sessions', function (Blueprint $table) { | ||
$table->string('session_id', 128); | ||
$table->bigInteger('user_id')->nullable(); | ||
$table->string('ip_address', 39); | ||
$table->string('user_agent', 255)->nullable(); | ||
$table->bigInteger('created')->default('0'); | ||
$table->bigInteger('last_used')->default('0'); | ||
$table->boolean('remember')->default('0'); | ||
$table->text('data')->default(''); | ||
$table->string('domain', 255)->nullable(); | ||
$table->index(['user_id'], 'sessions_user_id'); | ||
$table->unique(['session_id'], 'sessions_pkey'); | ||
}); | ||
|
||
// 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. | ||
Capsule::schema()->create('access_keys', function (Blueprint $table) { | ||
$table->bigInteger('access_key_id')->autoIncrement(); | ||
$table->unique(['access_key_id']); | ||
$table->string('context', 40); | ||
$table->string('key_hash', 40); | ||
$table->bigInteger('user_id'); | ||
$table->bigInteger('assoc_id')->nullable(); | ||
$table->timestamp('expiry_date'); | ||
$table->index(['key_hash', 'user_id', 'context'], 'access_keys_hash'); | ||
}); | ||
|
||
// Stores notifications for users as created by the system after certain operations. | ||
Capsule::schema()->create('notifications', function (Blueprint $table) { | ||
$table->bigInteger('notification_id')->autoIncrement(); | ||
$table->unique(['notification_id']); | ||
$table->bigInteger('context_id'); | ||
$table->bigInteger('user_id')->nullable(); | ||
$table->bigInteger('level'); | ||
$table->bigInteger('type'); | ||
$table->timestamp('date_created'); | ||
$table->timestamp('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'); | ||
$table->index(['assoc_type', 'assoc_id'], 'notifications_assoc'); | ||
$table->index(['user_id', 'level'], 'notifications_user_id_level'); | ||
}); | ||
|
||
// Stores metadata for specific notifications | ||
Capsule::schema()->create('notification_settings', function (Blueprint $table) { | ||
$table->bigInteger('notification_id'); | ||
$table->string('locale', 14)->nullable(); | ||
$table->string('setting_name', 64); | ||
$table->text('setting_value'); | ||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)'); | ||
$table->unique(['notification_id', 'locale', 'setting_name'], 'notification_settings_pkey'); | ||
}); | ||
|
||
// Stores user preferences on what notifications should be blocked and/or emailed to them | ||
Capsule::schema()->create('notification_subscription_settings', function (Blueprint $table) { | ||
$table->bigInteger('setting_id')->autoIncrement(); | ||
$table->unique(['setting_id']); | ||
$table->string('setting_name', 64); | ||
$table->text('setting_value'); | ||
$table->bigInteger('user_id'); | ||
$table->bigInteger('context'); | ||
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)'); | ||
}); | ||
|
||
// Stores subscriptions to the notification mailing list | ||
Capsule::schema()->create('notification_mail_list', function (Blueprint $table) { | ||
$table->bigInteger('notification_mail_list_id')->autoIncrement(); | ||
$table->unique(['notification_mail_list_id']); | ||
$table->string('email', 90); | ||
$table->boolean('confirmed')->default('0'); | ||
$table->string('token', 40); | ||
$table->bigInteger('context'); | ||
$table->unique(['email', 'context'], 'notification_mail_list_email_context'); | ||
}); | ||
|
||
// Default email templates. | ||
Capsule::schema()->create('email_templates_default', function (Blueprint $table) { | ||
$table->bigInteger('email_id')->autoIncrement(); | ||
$table->unique(['email_id']); | ||
$table->string('email_key', 64)->comment('Unique identifier for this email.'); | ||
$table->boolean('can_disable')->default('1'); | ||
$table->boolean('can_edit')->default('1'); | ||
$table->bigInteger('from_role_id')->nullable(); | ||
$table->bigInteger('to_role_id')->nullable(); | ||
$table->index(['email_key'], 'email_templates_default_email_key'); | ||
}); | ||
|
||
// Default data for email templates. | ||
Capsule::schema()->create('email_templates_default_data', function (Blueprint $table) { | ||
$table->string('email_key', 64)->comment('Unique identifier for this email.'); | ||
$table->string('locale', 14)->default('en_US'); | ||
$table->string('subject', 120); | ||
$table->text('body')->nullable(); | ||
$table->text('description')->nullable(); | ||
$table->unique(['email_key', 'locale'], 'email_templates_default_data_pkey'); | ||
}); | ||
|
||
// Templates for emails. | ||
Capsule::schema()->create('email_templates', function (Blueprint $table) { | ||
$table->bigInteger('email_id')->autoIncrement(); | ||
$table->unique(['email_id']); | ||
$table->string('email_key', 64)->comment('Unique identifier for this email.'); | ||
// Not null not specified for sake of upgrade. | ||
$table->bigInteger('context_id')->default('0')->nullable(); | ||
$table->boolean('enabled')->default('1'); | ||
$table->unique(['email_key', 'context_id'], 'email_templates_email_key'); | ||
}); | ||
|
||
Capsule::schema()->create('email_templates_settings', function (Blueprint $table) { | ||
$table->bigInteger('email_id'); | ||
$table->string('locale', 14)->default(''); | ||
$table->string('setting_name', 255); | ||
$table->text('setting_value')->nullable(); | ||
$table->index(['email_id'], 'email_settings_email_id'); | ||
$table->unique(['email_id', 'locale', 'setting_name'], 'email_settings_pkey'); | ||
}); | ||
|
||
// Resumption tokens for the OAI protocol interface. | ||
Capsule::schema()->create('oai_resumption_tokens', function (Blueprint $table) { | ||
$table->string('token', 32); | ||
$table->bigInteger('expire'); | ||
$table->integer('record_offset'); | ||
$table->text('params')->nullable(); | ||
$table->unique(['token'], 'oai_resumption_tokens_pkey'); | ||
}); | ||
|
||
// Plugin settings. | ||
Capsule::schema()->create('plugin_settings', function (Blueprint $table) { | ||
$table->string('plugin_name', 80); | ||
$table->bigInteger('context_id'); | ||
$table->string('setting_name', 80); | ||
$table->text('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_pkey'); | ||
}); | ||
|
||
} | ||
} |
Oops, something went wrong.