* {@inheritdoc}
*/
const TABLE_NAME = "city_store";
+ const COLUMN_NAME = "cluster_id";
/**
* {@inheritdoc}
*/
public function safeUp()
{
- $this->dropColumn(self::TABLE_NAME, 'cluster_id');
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (isset($tableSchema->columns[self::COLUMN_NAME])) {
+ $this->dropColumn(self::TABLE_NAME, self::COLUMN_NAME);
+ }
}
/**
{
- $this->addColumn(self::TABLE_NAME, 'cluster_id', $this->integer()->null()->after('administrator_id'));
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
- $this->update(self::TABLE_NAME, ['cluster_id' => null]);
+ if (!isset($tableSchema->columns[self::COLUMN_NAME])) {
+ $this->addColumn(self::TABLE_NAME, self::COLUMN_NAME, $this->integer()->null()->after('administrator_id'));
+ $this->update(self::TABLE_NAME, [self::COLUMN_NAME => null]);
+ }
}