table('slides'); $columns = [ // file name inside the poll's upload directory (null = no image) 'image' => ['string', ['null' => true, 'default' => null, 'limit' => 40]], // alternative text, '' = purely decorative image 'image_alt' => ['string', ['null' => true, 'default' => null, 'limit' => 255]], // top | side | full (null = default of the slide type) 'image_layout' => ['string', ['null' => true, 'default' => null, 'limit' => 8]], 'image_width' => ['integer', ['null' => true, 'default' => null]], 'image_height' => ['integer', ['null' => true, 'default' => null]], ]; $changed = false; foreach ($columns as $name => [$type, $options]) { if (!$table->hasColumn($name)) { $table->addColumn($name, $type, $options); $changed = true; } } if ($changed) { $table->update(); } } /** * @return void */ public function down(): void { $table = $this->table('slides'); foreach (['image', 'image_alt', 'image_layout', 'image_width', 'image_height'] as $name) { if ($table->hasColumn($name)) { $table->removeColumn($name); } } $table->update(); } }