Skip to content

Commit

Permalink
#2493 Use smallInteger or boolean instead of tinyInt (laravel/framewo…
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Aug 27, 2020
1 parent 2b25831 commit e1de408
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 52 deletions.
26 changes: 13 additions & 13 deletions classes/migration/CommonMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ 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->tinyInteger('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->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->tinyInteger('lazy_load')->default(0)->comment('1 iff the row describes a lazy-load plugin; 0 otherwise');
$table->tinyInteger('sitewide')->default(0)->comment('1 iff the row describes a site-wide plugin; 0 otherwise');
$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->tinyInteger('min_password_length')->default(6);
$table->smallInteger('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();
Expand All @@ -61,7 +61,7 @@ public function up() {
$table->bigInteger('auth_id')->autoIncrement();
$table->string('title', 60);
$table->string('plugin', 32);
$table->tinyInteger('auth_default')->default(0);
$table->boolean('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->tinyInteger('must_change_password')->nullable();
$table->boolean('must_change_password')->nullable();
$table->bigInteger('auth_id')->nullable();
$table->string('auth_str', 255)->nullable();
$table->tinyInteger('disabled')->default(0);
$table->boolean('disabled')->default(0);
$table->text('disabled_reason')->nullable();
$table->tinyInteger('inline_help')->nullable();
$table->boolean('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->tinyInteger('remember')->default(0);
$table->boolean('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->tinyInteger('confirmed')->default(0);
$table->boolean('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->tinyInteger('can_disable')->default(1);
$table->tinyInteger('can_edit')->default(1);
$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->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->tinyInteger('enabled')->default(1);
$table->boolean('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,10 +27,10 @@ public function up() {
$table->bigInteger('genre_id')->autoIncrement();
$table->bigInteger('context_id');
$table->bigInteger('seq');
$table->tinyInteger('enabled')->default(1);
$table->boolean('enabled')->default(1);
$table->bigInteger('category')->default(1);
$table->tinyInteger('dependent')->default(0);
$table->tinyInteger('supplementary')->default(0);
$table->boolean('dependent')->default(0);
$table->boolean('supplementary')->default(0);
$table->string('entry_key', 30)->nullable();
});

Expand Down
4 changes: 2 additions & 2 deletions classes/migration/LibraryFilesMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function up() {
$table->string('original_file_name', 255);
$table->string('file_type', 255);
$table->bigInteger('file_size');
$table->tinyInteger('type');
$table->smallInteger('type');
$table->datetime('date_uploaded');
$table->datetime('date_modified');
$table->bigInteger('submission_id');
$table->tinyInteger('public_access')->default(0)->nullable();
$table->boolean('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->tinyInteger('is_translated')->nullable();
$table->boolean('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->tinyInteger('is_template')->default(0);
$table->boolean('is_template')->default(0);
$table->bigInteger('parent_filter_id')->default(0);
$table->bigInteger('seq')->default(0);
});
Expand Down
2 changes: 1 addition & 1 deletion classes/migration/MetricsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function up() {
$table->bigInteger('assoc_id');
$table->string('day', 8)->nullable();
$table->string('month', 6)->nullable();
$table->tinyInteger('file_type')->nullable();
$table->smallInteger('file_type')->nullable();
$table->string('country_id', 2)->nullable();
$table->string('region', 2)->nullable();
$table->string('city', 255)->nullable();
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->tinyInteger('is_active')->nullable();
$table->boolean('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->tinyInteger('required')->nullable();
$table->tinyInteger('included')->nullable();
$table->boolean('required')->nullable();
$table->boolean('included')->nullable();
$table->index(['review_form_id'], 'review_form_elements_review_form_id');
});

Expand Down
24 changes: 12 additions & 12 deletions classes/migration/ReviewsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function up() {
$table->bigInteger('submission_id');
$table->bigInteger('reviewer_id');
$table->text('competing_interests')->nullable();
$table->tinyInteger('recommendation')->nullable();
$table->smallInteger('recommendation')->nullable();
$table->datetime('date_assigned')->nullable();
$table->datetime('date_notified')->nullable();
$table->datetime('date_confirmed')->nullable();
Expand All @@ -37,20 +37,20 @@ public function up() {
$table->datetime('date_due')->nullable();
$table->datetime('date_response_due')->nullable();
$table->datetime('last_modified')->nullable();
$table->tinyInteger('reminder_was_automatic')->default(0);
$table->tinyInteger('declined')->default(0);
$table->tinyInteger('cancelled')->default(0);
$table->boolean('reminder_was_automatic')->default(0);
$table->boolean('declined')->default(0);
$table->boolean('cancelled')->default(0);
$table->bigInteger('reviewer_file_id')->nullable();
$table->datetime('date_rated')->nullable();
$table->datetime('date_reminded')->nullable();
$table->tinyInteger('quality')->nullable();
$table->smallInteger('quality')->nullable();
$table->bigInteger('review_round_id');
$table->tinyInteger('stage_id')->default(1);
$table->tinyInteger('review_method')->default(1);
$table->tinyInteger('round')->default(1);
$table->tinyInteger('step')->default(1);
$table->smallInteger('stage_id')->default(1);
$table->smallInteger('review_method')->default(1);
$table->smallInteger('round')->default(1);
$table->smallInteger('step')->default(1);
$table->bigInteger('review_form_id')->nullable();
$table->tinyInteger('unconsidered')->nullable();
$table->boolean('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 All @@ -62,7 +62,7 @@ public function up() {
$table->bigInteger('review_round_id')->autoIncrement();
$table->bigInteger('submission_id');
$table->bigInteger('stage_id')->nullable();
$table->tinyInteger('round');
$table->smallInteger('round');
$table->bigInteger('review_revision')->nullable();
$table->bigInteger('status')->nullable();
$table->index(['submission_id'], 'review_rounds_submission_id');
Expand All @@ -73,7 +73,7 @@ public function up() {
Capsule::schema()->create('review_round_files', function (Blueprint $table) {
$table->bigInteger('submission_id');
$table->bigInteger('review_round_id');
$table->tinyInteger('stage_id');
$table->smallInteger('stage_id');
$table->bigInteger('file_id');
$table->bigInteger('revision')->default(1);
$table->index(['submission_id'], 'review_round_files_submission_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->tinyInteger('is_default')->default(0);
$table->tinyInteger('show_title')->default(1);
$table->tinyInteger('permit_self_registration')->default(0);
$table->tinyInteger('permit_metadata_edit')->default(0);
$table->boolean('is_default')->default(0);
$table->boolean('show_title')->default(1);
$table->boolean('permit_self_registration')->default(0);
$table->boolean('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->tinyInteger('recommend_only')->default(0);
$table->tinyInteger('can_change_metadata')->default(0);
$table->boolean('recommend_only')->default(0);
$table->boolean('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->tinyInteger('viewable')->nullable();
$table->boolean('viewable')->nullable();
$table->datetime('date_uploaded');
$table->datetime('date_modified');
$table->bigInteger('uploader_user_id')->nullable();
Expand Down
16 changes: 8 additions & 8 deletions classes/migration/SubmissionsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function up() {
// WORKFLOW_STAGE_ID_SUBMISSION
$table->bigInteger('stage_id')->default(1);
// STATUS_QUEUED
$table->tinyInteger('status')->default(1);
$table->tinyInteger('submission_progress')->default(1);
$table->smallInteger('status')->default(1);
$table->smallInteger('submission_progress')->default(1);
// Used in OMP only; should not be null there
$table->tinyInteger('work_type')->default(0)->nullable();
$table->smallInteger('work_type')->default(0)->nullable();
$table->index(['context_id'], 'submissions_context_id');
});

Expand Down Expand Up @@ -69,7 +69,7 @@ public function up() {
Capsule::schema()->create('authors', function (Blueprint $table) {
$table->bigInteger('author_id')->autoIncrement();
$table->string('email', 90);
$table->tinyInteger('include_in_browse')->default(1);
$table->boolean('include_in_browse')->default(1);
$table->bigInteger('publication_id');
$table->float('seq', 8, 2)->default(0);
$table->bigInteger('user_group_id')->nullable();
Expand All @@ -92,9 +92,9 @@ public function up() {
$table->bigInteger('submission_id');
$table->bigInteger('review_round_id');
$table->bigInteger('stage_id')->nullable();
$table->tinyInteger('round');
$table->smallInteger('round');
$table->bigInteger('editor_id');
$table->tinyInteger('decision');
$table->smallInteger('decision');
$table->datetime('date_decided');
$table->index(['submission_id'], 'edit_decisions_submission_id');
$table->index(['editor_id'], 'edit_decisions_editor_id');
Expand All @@ -112,7 +112,7 @@ public function up() {
$table->text('comments')->nullable();
$table->datetime('date_posted')->nullable();
$table->datetime('date_modified')->nullable();
$table->tinyInteger('viewable')->nullable();
$table->boolean('viewable')->nullable();
$table->index(['submission_id'], 'submission_comments_submission_id');
});

Expand All @@ -133,7 +133,7 @@ public function up() {
$table->bigInteger('query_id')->autoIncrement();
$table->bigInteger('assoc_type');
$table->bigInteger('assoc_id');
$table->tinyInteger('stage_id')->default(1);
$table->smallInteger('stage_id')->default(1);
$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 @@ -63,7 +63,7 @@ public function up() {
});
Capsule::schema()->table('genres', function (Blueprint $table) {
$table->bigInteger('seq')->change();
$table->tinyInteger('supplementary')->default(0)->change();
$table->boolean('supplementary')->default(0)->change();
});
Capsule::schema()->table('event_log', function (Blueprint $table) {
$table->bigInteger('assoc_type')->change();
Expand Down
3 changes: 3 additions & 0 deletions tools/xmlSchemaToMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function up() {\n";
$allowDefault = false;
break;
case 'I1':
// This may be a boolean or a numeric constant!
// MySQL complains (https://github.com/laravel/framework/issues/8840)
// but it's better to review and fix manually rather than rely on this.
echo "\$table->tinyInteger('" . $tableChild->getAttribute('name') . "')";
break;
case 'I2':
Expand Down

0 comments on commit e1de408

Please sign in to comment.