@@ -48,6 +48,7 @@ public function hookInstall()
4848 `modified_by_user_id` int(10) unsigned NOT NULL,
4949 `created_by_user_id` int(10) unsigned NOT NULL,
5050 `is_published` tinyint(1) NOT NULL,
51+ `is_searchable` tinyint(1) NOT NULL,
5152 `title` tinytext COLLATE utf8_unicode_ci NOT NULL,
5253 `slug` tinytext COLLATE utf8_unicode_ci NOT NULL,
5354 `text` mediumtext COLLATE utf8_unicode_ci,
@@ -67,12 +68,13 @@ public function hookInstall()
6768 KEY `parent_id` (`parent_id`)
6869 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci " ;
6970 $ db ->query ($ sql );
70-
71+
7172 // Save an example page.
7273 $ page = new SimplePagesPage ;
7374 $ page ->modified_by_user_id = current_user ()->id ;
7475 $ page ->created_by_user_id = current_user ()->id ;
7576 $ page ->is_published = 1 ;
77+ $ page ->is_searchable = 1 ;
7678 $ page ->parent_id = 0 ;
7779 $ page ->title = 'About ' ;
7880 $ page ->slug = 'about ' ;
@@ -154,6 +156,22 @@ public function hookUpgrade($args)
154156 if ($ oldVersion < '3.0.2 ' ) {
155157 $ db ->query ("ALTER TABLE ` $ db ->SimplePagesPage ` MODIFY `text` MEDIUMTEXT COLLATE utf8_unicode_ci " );
156158 }
159+
160+ if ($ oldVersion < '3.0.4 ' ) {
161+ // Check if "is_searchable" exists, because the patch is rebased.
162+ $ sql = "SHOW columns FROM ` $ db ->SimplePagesPage ` WHERE `Field` = 'is_searchable'; " ;
163+ $ result = $ db ->query ($ sql )->fetchAll ();
164+ if (empty ($ result )) {
165+ $ sql = "
166+ ALTER TABLE ` $ db ->SimplePagesPage `
167+ ADD `is_searchable` tinyint(1) NOT NULL AFTER `is_published`
168+ " ;
169+ $ db ->query ($ sql );
170+ // Set all existing pages as searchable.
171+ $ sql = "UPDATE ` $ db ->SimplePagesPage ` SET `is_searchable` = '1'; " ;
172+ $ db ->query ($ sql );
173+ }
174+ }
157175 }
158176
159177 /**
0 commit comments