Skip to content

Commit

Permalink
modify project lang field to be varchar(3) (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeig authored May 11, 2023
1 parent 62cccea commit 8ac2172
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions db/migrations/20230511122352_goteo_project_lang_size.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

use Goteo\Core\Model;

/**
* Migration Task class.
*/
class GoteoProjectLangSize
{
public function preUp()
{
// add the pre-migration code here
}

public function postUp()
{
// add the post-migration code here
}

public function preDown()
{
$sql = "
UPDATE goteo.project SET lang = LEFT(lang, 2);
";

Model::query($sql);
}

public function postDown()
{
// add the post-migration code here
}

/**
* Return the SQL statements for the Up migration
*
* @return string The SQL string to execute for the Up migration.
*/
public function getUpSQL()
{
return "
ALTER TABLE project MODIFY COLUMN lang VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'es' NULL;
";
}

/**
* Return the SQL statements for the Down migration
*
* @return string The SQL string to execute for the Down migration.
*/
public function getDownSQL()
{
return "
ALTER TABLE project MODIFY COLUMN lang VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'es' NULL;
";
}

}

0 comments on commit 8ac2172

Please sign in to comment.