Added general comment stubs
[ssproject1617.git] / testcms-final-anon / upgrade / migrations.php
1 <?php
2
3 /*
4 0.4 --> 0.5
5 */
6 $migration = new Migrations;
7
8 if(Schema::has('users', 'email') === false) {
9 $sql = "alter table `users` add `email` varchar( 140 ) not null after `password`";
10 $migration->query($sql);
11 }
12
13 if(Schema::has('posts', 'comments') === false) {
14 $sql = "alter table `posts` add `comments` tinyint( 1 ) not null";
15 $migration->query($sql);
16 }
17
18 if(Schema::has('posts', 'custom_fields') === false) {
19 $sql = "alter table `posts` add `custom_fields` text not null after `js`";
20 $migration->query($sql);
21 }
22
23 $sql = "create table if not exists `comments` (
24 `id` int(6) not null auto_increment,
25 `post` int(6) not null,
26 `status` enum('pending','published','spam') not null,
27 `date` int(11) not null,
28 `name` varchar(140) not null,
29 `email` varchar(140) not null,
30 `text` text not null,
31 primary key (`id`),
32 key `post` (`post`),
33 key `status` (`status`)
34 ) engine=myisam charset=utf8 collate=utf8_general_ci";
35 $migration->query($sql);
36
37 // rename show_posts
38 $sql = "update `meta` set `value` = 'posts_page' where `value` = 'show_posts'";
39 $migration->query($sql);
40
41 // make posts_page the home page
42 if(Schema::has('meta', 'key', 'home_page') === false) {
43 $posts_page = Db::query("select `value` from meta where `key` = 'show_posts'")->fetchColumn();
44
45 $sql = "insert into `meta` (`key`, `value`) values ('home_page', '" . $posts_page . "')";
46 $migration->query($sql);
47 }
48
49 // [BUGFIX] make sure the password field is big enough
50 $sql = "alter table `users` change `password` `password` text character set utf8 COLLATE utf8_general_ci not null";
51 $migration->query($sql);
52
53 // apply changes
54 $migration->apply();
55
56 // update config
57 Config::set('application.admin_folder', 'admin');
58 Config::set('application.key', random(32));
59
60 /*
61 0.5 --> 0.6
62 */
63 $migration = new Migrations;
64
65 $sql = "create table if not exists `sessions` (
66 `id` char( 32 ) not null ,
67 `date` datetime not null ,
68 `ip` varchar( 15 ) not null ,
69 `ua` varchar( 140 ) not null ,
70 `data` text not null
71 ) engine=innodb charset=utf8 collate=utf8_general_ci;";
72 $migration->query($sql);
73
74 // comments auto published option
75 if(Schema::has('meta', 'key', 'auto_published_comments') === false) {
76 $sql = "insert into `meta` (`key`, `value`) values ('auto_published_comments', '0')";
77 $migration->query($sql);
78 }
79
80 // pagination
81 if(Schema::has('meta', 'key', 'posts_per_page') === false) {
82 $sql = "insert into `meta` (`key`, `value`) values ('posts_per_page', '10')";
83 $migration->query($sql);
84 }
85
86 // apply changes
87 $migration->apply();
88
89 // update config
90 Config::set('session.name', 'testcms');
91 Config::set('session.expire', 3600);
92 Config::set('session.path', '/');
93 Config::set('session.domain', '');
94
95 Config::set('error.ignore', array(E_NOTICE, E_USER_NOTICE, E_DEPRECATED, E_USER_DEPRECATED));
96 Config::set('error.detail', true);
97 Config::set('error.log', false);