Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates deprecated Old Tupi (tpw) to Tupinambá (tpn) #3158

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions config/Migrations/20250125_OldTupiCodeRename
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Migrations\AbstractMigration;

class OldTupiCodeRename extends AbstractMigration
{
private $langColumns = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory you want to add the new column

'audios' => ['sentence_lang'],

let’s say, for the sake of completeness. But in practice it’s not really necessary because we don’t have any audio in Old Tupi.

'contributions' => ['sentence_lang', 'translation_lang'],
'contributions_stats' => ['lang'],
'languages' => ['code'],
'last_contributions' => ['sentence_lang', 'translation_lang'],
'reindex_flags' => ['lang'],
'sentence_comments' => ['lang'],
'sentences' => ['lang'],
'sentences_translations' => ['sentence_lang', 'translation_lang'],
'users_languages' => ['language_code'],
'vocabulary' => ['lang'],
];

private $oldCode = 'tpw';
private $newCode = 'tpn';

private function updateCode($from, $to) {
foreach ($this->langColumns as $table => $columns) {
foreach ($columns as $column) {
$this->getQueryBuilder()
->update($table)
->set($column, $to)
->where([$column => $from])
->execute();
}
}
}

public function up() {
$this->updateCode($this->oldCode, $this->newCode);
}

public function down() {
$this->updateCode($this->newCode, $this->oldCode);
}
}