Skip to content

Commit 8ac2172

Browse files
authored
modify project lang field to be varchar(3) (#544)
1 parent 62cccea commit 8ac2172

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
use Goteo\Core\Model;
4+
5+
/**
6+
* Migration Task class.
7+
*/
8+
class GoteoProjectLangSize
9+
{
10+
public function preUp()
11+
{
12+
// add the pre-migration code here
13+
}
14+
15+
public function postUp()
16+
{
17+
// add the post-migration code here
18+
}
19+
20+
public function preDown()
21+
{
22+
$sql = "
23+
UPDATE goteo.project SET lang = LEFT(lang, 2);
24+
";
25+
26+
Model::query($sql);
27+
}
28+
29+
public function postDown()
30+
{
31+
// add the post-migration code here
32+
}
33+
34+
/**
35+
* Return the SQL statements for the Up migration
36+
*
37+
* @return string The SQL string to execute for the Up migration.
38+
*/
39+
public function getUpSQL()
40+
{
41+
return "
42+
ALTER TABLE project MODIFY COLUMN lang VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'es' NULL;
43+
";
44+
}
45+
46+
/**
47+
* Return the SQL statements for the Down migration
48+
*
49+
* @return string The SQL string to execute for the Down migration.
50+
*/
51+
public function getDownSQL()
52+
{
53+
return "
54+
ALTER TABLE project MODIFY COLUMN lang VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'es' NULL;
55+
";
56+
}
57+
58+
}

0 commit comments

Comments
 (0)