← All changes
|
src/config/migrations/20171228151840_WpYoastIndexable.php
+35
-31
18.6
→
trunk
View file →
| @@ -36,8 +36,10 @@ | ||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Creates the indexable table. |
| 40 | + * | |
| 41 | + * @return void | |
| 40 | 42 | */ |
| 41 | 43 | private function add_table() { |
| 42 | 44 | $table_name = $this->get_table_name(); |
| 43 | 45 | |
| @@ -50,9 +52,9 @@ | ||
| 50 | 52 | 'string', |
| 51 | 53 | [ |
| 52 | 54 | 'null' => true, |
| 53 | 55 | 'limit' => 191, |
| 54 | - ] | |
| 56 | + ], | |
| 55 | 57 | ); |
| 56 | 58 | |
| 57 | 59 | // Object information. |
| 58 | 60 | $indexable_table->column( |
| @@ -61,9 +63,9 @@ | ||
| 61 | 63 | [ |
| 62 | 64 | 'unsigned' => true, |
| 63 | 65 | 'null' => true, |
| 64 | 66 | 'limit' => 11, |
| 65 | - ] | |
| 67 | + ], | |
| 66 | 68 | ); |
| 67 | 69 | $indexable_table->column( |
| 68 | 70 | 'object_type', |
| 69 | 71 | 'string', |
| @@ -69,9 +71,9 @@ | ||
| 69 | 71 | 'string', |
| 70 | 72 | [ |
| 71 | 73 | 'null' => false, |
| 72 | 74 | 'limit' => 32, |
| 73 | - ] | |
| 75 | + ], | |
| 74 | 76 | ); |
| 75 | 77 | $indexable_table->column( |
| 76 | 78 | 'object_sub_type', |
| 77 | 79 | 'string', |
| @@ -77,9 +79,9 @@ | ||
| 77 | 79 | 'string', |
| 78 | 80 | [ |
| 79 | 81 | 'null' => true, |
| 80 | 82 | 'limit' => 32, |
| 81 | - ] | |
| 83 | + ], | |
| 82 | 84 | ); |
| 83 | 85 | |
| 84 | 86 | // Ownership. |
| 85 | 87 | $indexable_table->column( |
| @@ -88,9 +90,9 @@ | ||
| 88 | 90 | [ |
| 89 | 91 | 'unsigned' => true, |
| 90 | 92 | 'null' => true, |
| 91 | 93 | 'limit' => 11, |
| 92 | - ] | |
| 94 | + ], | |
| 93 | 95 | ); |
| 94 | 96 | $indexable_table->column( |
| 95 | 97 | 'post_parent', |
| 96 | 98 | 'integer', |
| @@ -97,9 +99,9 @@ | ||
| 97 | 99 | [ |
| 98 | 100 | 'unsigned' => true, |
| 99 | 101 | 'null' => true, |
| 100 | 102 | 'limit' => 11, |
| 101 | - ] | |
| 103 | + ], | |
| 102 | 104 | ); |
| 103 | 105 | |
| 104 | 106 | // Title and description. |
| 105 | 107 | $indexable_table->column( |
| @@ -107,9 +109,9 @@ | ||
| 107 | 109 | 'string', |
| 108 | 110 | [ |
| 109 | 111 | 'null' => true, |
| 110 | 112 | 'limit' => 191, |
| 111 | - ] | |
| 113 | + ], | |
| 112 | 114 | ); |
| 113 | 115 | $indexable_table->column( 'description', 'text', [ 'null' => true ] ); |
| 114 | 116 | $indexable_table->column( |
| 115 | 117 | 'breadcrumb_title', |
| @@ -116,9 +118,9 @@ | ||
| 116 | 118 | 'string', |
| 117 | 119 | [ |
| 118 | 120 | 'null' => true, |
| 119 | 121 | 'limit' => 191, |
| 120 | - ] | |
| 122 | + ], | |
| 121 | 123 | ); |
| 122 | 124 | |
| 123 | 125 | // Post metadata: status, public, protected. |
| 124 | 126 | $indexable_table->column( |
| @@ -126,9 +128,9 @@ | ||
| 126 | 128 | 'string', |
| 127 | 129 | [ |
| 128 | 130 | 'null' => true, |
| 129 | 131 | 'limit' => 191, |
| 130 | - ] | |
| 132 | + ], | |
| 131 | 133 | ); |
| 132 | 134 | $indexable_table->column( |
| 133 | 135 | 'is_public', |
| 134 | 136 | 'boolean', |
| @@ -134,9 +136,9 @@ | ||
| 134 | 136 | 'boolean', |
| 135 | 137 | [ |
| 136 | 138 | 'null' => true, |
| 137 | 139 | 'default' => null, |
| 138 | - ] | |
| 140 | + ], | |
| 139 | 141 | ); |
| 140 | 142 | $indexable_table->column( 'is_protected', 'boolean', [ 'default' => false ] ); |
| 141 | 143 | $indexable_table->column( |
| 142 | 144 | 'has_public_posts', |
| @@ -143,9 +145,9 @@ | ||
| 143 | 145 | 'boolean', |
| 144 | 146 | [ |
| 145 | 147 | 'null' => true, |
| 146 | 148 | 'default' => null, |
| 147 | - ] | |
| 149 | + ], | |
| 148 | 150 | ); |
| 149 | 151 | |
| 150 | 152 | $indexable_table->column( |
| 151 | 153 | 'number_of_pages', |
| @@ -154,9 +156,9 @@ | ||
| 154 | 156 | 'unsigned' => true, |
| 155 | 157 | 'null' => true, |
| 156 | 158 | 'default' => null, |
| 157 | 159 | 'limit' => 11, |
| 158 | - ] | |
| 160 | + ], | |
| 159 | 161 | ); |
| 160 | 162 | |
| 161 | 163 | $indexable_table->column( 'canonical', 'mediumtext', [ 'null' => true ] ); |
| 162 | 164 | |
| @@ -166,9 +168,9 @@ | ||
| 166 | 168 | 'string', |
| 167 | 169 | [ |
| 168 | 170 | 'null' => true, |
| 169 | 171 | 'limit' => 191, |
| 170 | - ] | |
| 172 | + ], | |
| 171 | 173 | ); |
| 172 | 174 | $indexable_table->column( |
| 173 | 175 | 'primary_focus_keyword_score', |
| 174 | 176 | 'integer', |
| @@ -174,9 +176,9 @@ | ||
| 174 | 176 | 'integer', |
| 175 | 177 | [ |
| 176 | 178 | 'null' => true, |
| 177 | 179 | 'limit' => 3, |
| 178 | - ] | |
| 180 | + ], | |
| 179 | 181 | ); |
| 180 | 182 | $indexable_table->column( |
| 181 | 183 | 'readability_score', |
| 182 | 184 | 'integer', |
| @@ -182,9 +184,9 @@ | ||
| 182 | 184 | 'integer', |
| 183 | 185 | [ |
| 184 | 186 | 'null' => true, |
| 185 | 187 | 'limit' => 3, |
| 186 | - ] | |
| 188 | + ], | |
| 187 | 189 | ); |
| 188 | 190 | $indexable_table->column( 'is_cornerstone', 'boolean', [ 'default' => false ] ); |
| 189 | 191 | |
| 190 | 192 | // Robots. |
| @@ -193,9 +195,9 @@ | ||
| 193 | 195 | 'boolean', |
| 194 | 196 | [ |
| 195 | 197 | 'null' => true, |
| 196 | 198 | 'default' => false, |
| 197 | - ] | |
| 199 | + ], | |
| 198 | 200 | ); |
| 199 | 201 | $indexable_table->column( |
| 200 | 202 | 'is_robots_nofollow', |
| 201 | 203 | 'boolean', |
| @@ -201,9 +203,9 @@ | ||
| 201 | 203 | 'boolean', |
| 202 | 204 | [ |
| 203 | 205 | 'null' => true, |
| 204 | 206 | 'default' => false, |
| 205 | - ] | |
| 207 | + ], | |
| 206 | 208 | ); |
| 207 | 209 | $indexable_table->column( |
| 208 | 210 | 'is_robots_noarchive', |
| 209 | 211 | 'boolean', |
| @@ -209,9 +211,9 @@ | ||
| 209 | 211 | 'boolean', |
| 210 | 212 | [ |
| 211 | 213 | 'null' => true, |
| 212 | 214 | 'default' => false, |
| 213 | - ] | |
| 215 | + ], | |
| 214 | 216 | ); |
| 215 | 217 | $indexable_table->column( |
| 216 | 218 | 'is_robots_noimageindex', |
| 217 | 219 | 'boolean', |
| @@ -217,9 +219,9 @@ | ||
| 217 | 219 | 'boolean', |
| 218 | 220 | [ |
| 219 | 221 | 'null' => true, |
| 220 | 222 | 'default' => false, |
| 221 | - ] | |
| 223 | + ], | |
| 222 | 224 | ); |
| 223 | 225 | $indexable_table->column( |
| 224 | 226 | 'is_robots_nosnippet', |
| 225 | 227 | 'boolean', |
| @@ -225,9 +227,9 @@ | ||
| 225 | 227 | 'boolean', |
| 226 | 228 | [ |
| 227 | 229 | 'null' => true, |
| 228 | 230 | 'default' => false, |
| 229 | - ] | |
| 231 | + ], | |
| 230 | 232 | ); |
| 231 | 233 | |
| 232 | 234 | // Twitter. |
| 233 | 235 | $indexable_table->column( |
| @@ -235,9 +237,9 @@ | ||
| 235 | 237 | 'string', |
| 236 | 238 | [ |
| 237 | 239 | 'null' => true, |
| 238 | 240 | 'limit' => 191, |
| 239 | - ] | |
| 241 | + ], | |
| 240 | 242 | ); |
| 241 | 243 | $indexable_table->column( 'twitter_image', 'mediumtext', [ 'null' => true ] ); |
| 242 | 244 | $indexable_table->column( 'twitter_description', 'mediumtext', [ 'null' => true ] ); |
| 243 | 245 | $indexable_table->column( |
| @@ -245,9 +247,9 @@ | ||
| 245 | 247 | 'string', |
| 246 | 248 | [ |
| 247 | 249 | 'null' => true, |
| 248 | 250 | 'limit' => 191, |
| 249 | - ] | |
| 251 | + ], | |
| 250 | 252 | ); |
| 251 | 253 | $indexable_table->column( |
| 252 | 254 | 'twitter_image_source', |
| 253 | 255 | 'string', |
| @@ -253,9 +255,9 @@ | ||
| 253 | 255 | 'string', |
| 254 | 256 | [ |
| 255 | 257 | 'null' => true, |
| 256 | 258 | 'limit' => 191, |
| 257 | - ] | |
| 259 | + ], | |
| 258 | 260 | ); |
| 259 | 261 | |
| 260 | 262 | // Open-Graph. |
| 261 | 263 | $indexable_table->column( |
| @@ -263,9 +265,9 @@ | ||
| 263 | 265 | 'string', |
| 264 | 266 | [ |
| 265 | 267 | 'null' => true, |
| 266 | 268 | 'limit' => 191, |
| 267 | - ] | |
| 269 | + ], | |
| 268 | 270 | ); |
| 269 | 271 | $indexable_table->column( 'open_graph_description', 'mediumtext', [ 'null' => true ] ); |
| 270 | 272 | $indexable_table->column( 'open_graph_image', 'mediumtext', [ 'null' => true ] ); |
| 271 | 273 | $indexable_table->column( |
| @@ -273,9 +275,9 @@ | ||
| 273 | 275 | 'string', |
| 274 | 276 | [ |
| 275 | 277 | 'null' => true, |
| 276 | 278 | 'limit' => 191, |
| 277 | - ] | |
| 279 | + ], | |
| 278 | 280 | ); |
| 279 | 281 | $indexable_table->column( |
| 280 | 282 | 'open_graph_image_source', |
| 281 | 283 | 'string', |
| @@ -281,9 +283,9 @@ | ||
| 281 | 283 | 'string', |
| 282 | 284 | [ |
| 283 | 285 | 'null' => true, |
| 284 | 286 | 'limit' => 191, |
| 285 | - ] | |
| 287 | + ], | |
| 286 | 288 | ); |
| 287 | 289 | $indexable_table->column( 'open_graph_image_meta', 'text', [ 'null' => true ] ); |
| 288 | 290 | |
| 289 | 291 | // Link count. |
| @@ -292,9 +294,9 @@ | ||
| 292 | 294 | 'integer', |
| 293 | 295 | [ |
| 294 | 296 | 'null' => true, |
| 295 | 297 | 'limit' => 11, |
| 296 | - ] | |
| 298 | + ], | |
| 297 | 299 | ); |
| 298 | 300 | $indexable_table->column( |
| 299 | 301 | 'incoming_link_count', |
| 300 | 302 | 'integer', |
| @@ -300,9 +302,9 @@ | ||
| 300 | 302 | 'integer', |
| 301 | 303 | [ |
| 302 | 304 | 'null' => true, |
| 303 | 305 | 'limit' => 11, |
| 304 | - ] | |
| 306 | + ], | |
| 305 | 307 | ); |
| 306 | 308 | |
| 307 | 309 | // Prominent words. |
| 308 | 310 | $indexable_table->column( |
| @@ -312,9 +314,9 @@ | ||
| 312 | 314 | 'null' => true, |
| 313 | 315 | 'limit' => 11, |
| 314 | 316 | 'unsigned' => true, |
| 315 | 317 | 'default' => null, |
| 316 | - ] | |
| 318 | + ], | |
| 317 | 319 | ); |
| 318 | 320 | |
| 319 | 321 | $indexable_table->finish(); |
| 320 | 322 | |
| @@ -326,8 +328,10 @@ | ||
| 326 | 328 | /** |
| 327 | 329 | * Adds indexes to the indexable table. |
| 328 | 330 | * |
| 329 | 331 | * @param string $indexable_table_name The name of the indexable table. |
| 332 | + * | |
| 333 | + * @return void | |
| 330 | 334 | */ |
| 331 | 335 | private function add_indexes( $indexable_table_name ) { |
| 332 | 336 | $this->add_index( |
| 333 | 337 | $indexable_table_name, |
| @@ -336,9 +340,9 @@ | ||
| 336 | 340 | 'object_sub_type', |
| 337 | 341 | ], |
| 338 | 342 | [ |
| 339 | 343 | 'name' => 'object_type_and_sub_type', |
| 340 | - ] | |
| 344 | + ], | |
| 341 | 345 | ); |
| 342 | 346 | |
| 343 | 347 | $this->add_index( |
| 344 | 348 | $indexable_table_name, |
| @@ -344,9 +348,9 @@ | ||
| 344 | 348 | $indexable_table_name, |
| 345 | 349 | 'permalink_hash', |
| 346 | 350 | [ |
| 347 | 351 | 'name' => 'permalink_hash', |
| 348 | - ] | |
| 352 | + ], | |
| 349 | 353 | ); |
| 350 | 354 | } |
| 351 | 355 | |
| 352 | 356 | /** |