-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify project lang field to be varchar(3) (#544)
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
"; | ||
} | ||
|
||
} |