Skip to content

Commit

Permalink
pkp/pkp-lib#9892 WIP: MariaDB driver compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Aug 5, 2024
1 parent 208d357 commit d9b7acc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions classes/migration/install/MetricsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function up(): void
$table->index(['context_id', 'submission_id'], 'msgd_context_id_submission_id');
switch (DB::getDriverName()) {
case 'mysql':
case 'mariadb':
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
Expand Down Expand Up @@ -253,6 +254,7 @@ public function up(): void
$table->index(['context_id', 'submission_id'], 'msgm_context_id_submission_id');
switch (DB::getDriverName()) {
case 'mysql':
case 'mariadb':
// See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html
// where city is defined as varchar(80)
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
Expand Down
14 changes: 10 additions & 4 deletions classes/migration/install/OJSMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ public function up(): void
});
// Add partial index (DBMS-specific)
switch (DB::getDriverName()) {
case 'mysql': DB::unprepared('CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))');
case 'mysql':
case 'mariadb':
DB::unprepared('CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))');
break;
case 'pgsql': DB::unprepared("CREATE INDEX issue_settings_name_value ON issue_settings (setting_name, setting_value) WHERE setting_name IN ('medra::registeredDoi', 'datacite::registeredDoi')");
case 'pgsql':
DB::unprepared("CREATE INDEX issue_settings_name_value ON issue_settings (setting_name, setting_value) WHERE setting_name IN ('medra::registeredDoi', 'datacite::registeredDoi')");
break;
}

Expand Down Expand Up @@ -303,9 +306,12 @@ public function up(): void
});
// Add partial index (DBMS-specific)
switch (DB::getDriverName()) {
case 'mysql': DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name(50), setting_value(150))');
case 'mysql':
case 'mariadb':
DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name(50), setting_value(150))');
break;
case 'pgsql': DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name, setting_value)');
case 'pgsql':
DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name, setting_value)');
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function up(): void
{
switch (DB::getDriverName()) {
case 'mysql':
case 'mariadb':
DB::unprepared(
"DELETE dot
FROM data_object_tombstones dot
Expand Down
2 changes: 2 additions & 0 deletions classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function up(): void
$table->dropUnique('msgd_uc_load_context_submission_c_r_c_date');
switch (DB::getDriverName()) {
case 'mysql':
case 'mariadb':
$table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date');
break;
case 'pgsql':
Expand All @@ -65,6 +66,7 @@ public function up(): void
$table->dropUnique('msgm_uc_context_submission_c_r_c_month');
switch (DB::getDriverName()) {
case 'mysql':
case 'mariadb':
$table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month');
break;
case 'pgsql':
Expand Down

0 comments on commit d9b7acc

Please sign in to comment.