*/
public function safeUp()
{
- $this->createTable(self::TABLE_NAME, [
- 'id' => $this->bigPrimaryKey(),
- 'store_id' => $this->integer()->notNull(),
- 'product_guid' => $this->string()->notNull()->comment('product guid'),
- 'price' => $this->float()->notNull()->comment('price'),
- 'date_from' => $this->date()->notNull()->comment('Дата начала'),
- 'date_to' => $this->date()->defaultValue('2100-01-01')->notNull()->comment('Дата окончания'),
- 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Дата создания записи'),
- 'updated_at' => $this->datetime()->null()->comment('Дата внесения записи'),
- ]);
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (!isset($tableSchema)) {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->bigPrimaryKey(),
+ 'store_id' => $this->integer()->notNull(),
+ 'product_guid' => $this->string()->notNull()->comment('product guid'),
+ 'price' => $this->float()->notNull()->comment('price'),
+ 'date_from' => $this->date()->notNull()->comment('Дата начала'),
+ 'date_to' => $this->date()->defaultValue('2100-01-01')->notNull()->comment('Дата окончания'),
+ 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Дата создания записи'),
+ 'updated_at' => $this->datetime()->null()->comment('Дата внесения записи'),
+ ]);
+ }
}
/**
*/
public function safeDown()
{
- $this->dropTable(self::TABLE_NAME);
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+ if (isset($tableSchema)) {
+ $this->dropTable(self::TABLE_NAME);
+ }
}
}