Skip to content

Commit

Permalink
update to rename deprecated language/country tables and media columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hinanaya committed Jun 17, 2024
1 parent 4d5f015 commit a7fe0c7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions updates/20240617.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

class OBUpdate20240617 extends OBUpdate
{
public function items()
{
$updates = [];
$updates[] = 'Modify deprecated media column names to avoid confusion.';
$updates[] = 'Rename old countries and languages tables to avoid confusion.';

return $updates;
}

public function run()
{
// Modify deprecated media column names to avoid confusion.
$this->db->query("ALTER TABLE media CHANGE country_id _deprecated_country_id INT UNSIGNED AFTER thumbnail_version;");
if ($this->db->error()) {
echo 'Failed to update country_id column in media table.';
return false;
}

$this->db->query("ALTER TABLE media CHANGE language_id _deprecated_language_id INT UNSIGNED AFTER _deprecated_country_id;");
if ($this->db->error()) {
echo 'Failed to update language_id column in media table.';
return false;
}

// Rename old countries and languages tables to avoid confusion.
$this->db->query("RENAME TABLE media_countries TO _deprecated_media_countries;");
if ($this->db->error()) {
echo 'Failed to rename media_countries table.';
return false;
}

$this->db->query("RENAME TABLE media_languages TO _deprecated_media_languages;");
if ($this->db->error()) {
echo 'Failed to rename media_languages table.';
return false;
}

return true;
}
}

0 comments on commit a7fe0c7

Please sign in to comment.