Skip to content

Commit

Permalink
#2493 Back away from boolean columns (PostgreSQL vs MySQL on numeric …
Browse files Browse the repository at this point in the history
…equivalents)
  • Loading branch information
asmecher committed Aug 27, 2020
1 parent 68f603c commit 4a6178a
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 44 deletions.
24 changes: 12 additions & 12 deletions classes/migration/CommonMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public function up() {
$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->boolean('current')->default(false)->comment('1 iff the version entry being described is currently active. This permits the table to store past installation history for forensic purposes.');
$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 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(false)->comment('1 iff the row describes a lazy-load plugin; 0 otherwise');
$table->boolean('sitewide')->default(false)->comment('1 iff the row describes a site-wide plugin; 0 otherwise');
$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_pkey');
});

Expand All @@ -61,7 +61,7 @@ public function up() {
$table->bigInteger('auth_id')->autoIncrement();
$table->string('title', 60);
$table->string('plugin', 32);
$table->boolean('auth_default')->default(false);
$table->smallInteger('auth_default')->default(0);
$table->text('settings')->nullable();
});

Expand All @@ -82,12 +82,12 @@ public function up() {
$table->datetime('date_registered');
$table->datetime('date_validated')->nullable();
$table->datetime('date_last_login');
$table->boolean('must_change_password')->nullable();
$table->smallInteger('must_change_password')->nullable();
$table->bigInteger('auth_id')->nullable();
$table->string('auth_str', 255)->nullable();
$table->boolean('disabled')->default(false);
$table->smallInteger('disabled')->default(0);
$table->text('disabled_reason')->nullable();
$table->boolean('inline_help')->nullable();
$table->smallInteger('inline_help')->nullable();
$table->unique(['username'], 'users_username');
$table->unique(['email'], 'users_email');
});
Expand All @@ -114,7 +114,7 @@ public function up() {
$table->string('user_agent', 255)->nullable();
$table->bigInteger('created')->default(0);
$table->bigInteger('last_used')->default(0);
$table->boolean('remember')->default(false);
$table->smallInteger('remember')->default(0);
$table->text('data');
$table->string('domain', 255)->nullable();
$table->index(['user_id'], 'sessions_user_id');
Expand Down Expand Up @@ -173,7 +173,7 @@ public function up() {
Capsule::schema()->create('notification_mail_list', function (Blueprint $table) {
$table->bigInteger('notification_mail_list_id')->autoIncrement();
$table->string('email', 90);
$table->boolean('confirmed')->default(false);
$table->smallInteger('confirmed')->default(0);
$table->string('token', 40);
$table->bigInteger('context');
$table->unique(['email', 'context'], 'notification_mail_list_email_context');
Expand All @@ -183,8 +183,8 @@ public function up() {
Capsule::schema()->create('email_templates_default', function (Blueprint $table) {
$table->bigInteger('email_id')->autoIncrement();
$table->string('email_key', 64)->comment('Unique identifier for this email.');
$table->boolean('can_disable')->default(true);
$table->boolean('can_edit')->default(true);
$table->smallInteger('can_disable')->default(0);
$table->smallInteger('can_edit')->default(0);
$table->bigInteger('from_role_id')->nullable();
$table->bigInteger('to_role_id')->nullable();
$table->bigInteger('stage_id')->nullable();
Expand All @@ -206,7 +206,7 @@ public function up() {
$table->bigInteger('email_id')->autoIncrement();
$table->string('email_key', 64)->comment('Unique identifier for this email.');
$table->bigInteger('context_id');
$table->boolean('enabled')->default(true);
$table->smallInteger('enabled')->default(1);
$table->unique(['email_key', 'context_id'], 'email_templates_email_key');
});

Expand Down
6 changes: 3 additions & 3 deletions classes/migration/GenresMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function up() {
$table->bigInteger('genre_id')->autoIncrement();
$table->bigInteger('context_id');
$table->bigInteger('seq');
$table->boolean('enabled')->default(true);
$table->smallInteger('enabled')->default(1);

import('lib.pkp.classes.submission.Genre'); // for constant
$table->bigInteger('category')->default(GENRE_CATEGORY_DOCUMENT);

$table->boolean('dependent')->default(false);
$table->boolean('supplementary')->default(false);
$table->smallInteger('dependent')->default(0);
$table->smallInteger('supplementary')->default(0);
$table->string('entry_key', 30)->nullable();
});

Expand Down
2 changes: 1 addition & 1 deletion classes/migration/LibraryFilesMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function up() {
$table->datetime('date_uploaded');
$table->datetime('date_modified');
$table->bigInteger('submission_id');
$table->boolean('public_access')->default(false)->nullable();
$table->smallInteger('public_access')->default(0)->nullable();
$table->index(['context_id'], 'library_files_context_id');
$table->index(['submission_id'], 'library_files_submission_id');
});
Expand Down
2 changes: 1 addition & 1 deletion classes/migration/LogMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function up() {
$table->datetime('date_logged');
$table->bigInteger('event_type')->nullable();
$table->text('message')->nullable();
$table->boolean('is_translated')->nullable();
$table->smallInteger('is_translated')->nullable();
$table->index(['assoc_type', 'assoc_id'], 'event_log_assoc');
});

Expand Down
2 changes: 1 addition & 1 deletion classes/migration/MetadataMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function up() {
$table->bigInteger('context_id')->default(0);
$table->string('display_name', 255)->nullable();
$table->string('class_name', 255)->nullable();
$table->boolean('is_template')->default(false);
$table->smallInteger('is_template')->default(0);
$table->bigInteger('parent_filter_id')->default(0);
$table->bigInteger('seq')->default(0);
});
Expand Down
6 changes: 3 additions & 3 deletions classes/migration/ReviewFormsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function up() {
$table->bigInteger('assoc_type');
$table->bigInteger('assoc_id');
$table->float('seq', 8, 2)->nullable();
$table->boolean('is_active')->nullable();
$table->smallInteger('is_active')->nullable();
});

// Review form settings
Expand All @@ -48,8 +48,8 @@ public function up() {
$table->bigInteger('review_form_id');
$table->float('seq', 8, 2)->nullable();
$table->bigInteger('element_type')->nullable();
$table->boolean('required')->nullable();
$table->boolean('included')->nullable();
$table->smallInteger('required')->nullable();
$table->smallInteger('included')->nullable();
$table->index(['review_form_id'], 'review_form_elements_review_form_id');
});

Expand Down
15 changes: 9 additions & 6 deletions classes/migration/ReviewsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@ public function up() {
$table->datetime('date_due')->nullable();
$table->datetime('date_response_due')->nullable();
$table->datetime('last_modified')->nullable();
$table->boolean('reminder_was_automatic')->default(false);
$table->boolean('declined')->default(false);
$table->boolean('cancelled')->default(false);
$table->smallInteger('reminder_was_automatic')->default(0);
$table->smallInteger('declined')->default(0);
$table->smallInteger('cancelled')->default(0);
$table->bigInteger('reviewer_file_id')->nullable();
$table->datetime('date_rated')->nullable();
$table->datetime('date_reminded')->nullable();
$table->smallInteger('quality')->nullable();
$table->bigInteger('review_round_id');
$table->smallInteger('stage_id')->default(1);
$table->smallInteger('review_method')->default(1);
$table->smallInteger('stage_id');

import('lib.pkp.classes.submission.reviewAssignment.ReviewAssignment'); // for constant
$table->smallInteger('review_method')->default(SUBMISSION_REVIEW_METHOD_BLIND);

$table->smallInteger('round')->default(1);
$table->smallInteger('step')->default(1);
$table->bigInteger('review_form_id')->nullable();
$table->boolean('unconsidered')->nullable();
$table->smallInteger('unconsidered')->nullable();
$table->index(['submission_id'], 'review_assignments_submission_id');
$table->index(['reviewer_id'], 'review_assignments_reviewer_id');
$table->index(['review_form_id'], 'review_assignments_form_id');
Expand Down
12 changes: 6 additions & 6 deletions classes/migration/RolesAndUserGroupsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function up() {
$table->bigInteger('user_group_id')->autoIncrement();
$table->bigInteger('context_id');
$table->bigInteger('role_id');
$table->boolean('is_default')->default(false);
$table->boolean('show_title')->default(true);
$table->boolean('permit_self_registration')->default(false);
$table->boolean('permit_metadata_edit')->default(false);
$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');
Expand Down Expand Up @@ -73,8 +73,8 @@ public function up() {
$table->bigInteger('user_group_id');
$table->bigInteger('user_id');
$table->datetime('date_assigned');
$table->boolean('recommend_only')->default(false);
$table->boolean('can_change_metadata')->default(false);
$table->smallInteger('recommend_only')->default(0);
$table->smallInteger('can_change_metadata')->default(0);
$table->unique(['submission_id', 'user_group_id', 'user_id'], 'stage_assignment');
$table->index(['submission_id'], 'stage_assignments_submission_id');
$table->index(['user_group_id'], 'stage_assignments_user_group_id');
Expand Down
2 changes: 1 addition & 1 deletion classes/migration/SubmissionFilesMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function up() {
$table->bigInteger('file_stage');
$table->string('direct_sales_price', 255)->nullable();
$table->string('sales_type', 255)->nullable();
$table->boolean('viewable')->nullable();
$table->smallInteger('viewable')->nullable();
$table->datetime('date_uploaded');
$table->datetime('date_modified');
$table->bigInteger('uploader_user_id')->nullable();
Expand Down
15 changes: 8 additions & 7 deletions classes/migration/SubmissionsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public function up() {
$table->datetime('date_last_activity')->nullable();
$table->datetime('date_submitted')->nullable();
$table->datetime('last_modified')->nullable();
// WORKFLOW_STAGE_ID_SUBMISSION
$table->bigInteger('stage_id')->default(1);
// STATUS_QUEUED
$table->smallInteger('status')->default(1);
$table->bigInteger('stage_id')->default(WORKFLOW_STAGE_ID_SUBMISSION);

import('lib.pkp.classes.submission.PKPSubmission'); // for constant
$table->smallInteger('status')->default(STATUS_QUEUED);

$table->smallInteger('submission_progress')->default(1);
// Used in OMP only; should not be null there
$table->smallInteger('work_type')->default(0)->nullable();
Expand Down Expand Up @@ -69,7 +70,7 @@ public function up() {
Capsule::schema()->create('authors', function (Blueprint $table) {
$table->bigInteger('author_id')->autoIncrement();
$table->string('email', 90);
$table->boolean('include_in_browse')->default(true);
$table->smallInteger('include_in_browse')->default(1);
$table->bigInteger('publication_id');
$table->float('seq', 8, 2)->default(0);
$table->bigInteger('user_group_id')->nullable();
Expand Down Expand Up @@ -112,7 +113,7 @@ public function up() {
$table->text('comments')->nullable();
$table->datetime('date_posted')->nullable();
$table->datetime('date_modified')->nullable();
$table->boolean('viewable')->nullable();
$table->smallInteger('viewable')->nullable();
$table->index(['submission_id'], 'submission_comments_submission_id');
});

Expand All @@ -133,7 +134,7 @@ public function up() {
$table->bigInteger('query_id')->autoIncrement();
$table->bigInteger('assoc_type');
$table->bigInteger('assoc_id');
$table->smallInteger('stage_id')->default(1);
$table->smallInteger('stage_id');
$table->float('seq', 8, 2)->default(0);
$table->datetime('date_posted')->nullable();
$table->datetime('date_modified')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function up() {
});
Capsule::schema()->table('genres', function (Blueprint $table) {
$table->bigInteger('seq')->change();
$table->boolean('supplementary')->default(false)->change();
$table->smallInteger('supplementary')->default(0)->change();
});
Capsule::schema()->table('event_log', function (Blueprint $table) {
$table->bigInteger('assoc_type')->change();
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/reviewAssignment/ReviewAssignment.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ function setCompetingInterests($competingInterests) {

/**
* Get the workflow stage id.
* @return int
* @return int WORKFLOW_STAGE_ID_...
*/
function getStageId() {
return $this->getData('stageId');
}

/**
* Set the workflow stage id.
* @param $stageId int
* @param $stageId int WORKFLOW_STAGE_ID_...
*/
function setStageId($stageId) {
$this->setData('stageId', $stageId);
Expand Down

0 comments on commit 4a6178a

Please sign in to comment.