File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments