Something went wrong. Try again.
Element Exporter makes exporting data from your Craft CMS website easy and repeatable, with events for custom data parsing and elements.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758<?php
namespace studioespresso\exporter\migrations;
use Craft;use craft\db\Migration;use craft\db\Table;use studioespresso\exporter\records\ExportRecord;
class Install extends Migration{ /** * @inheritdoc */ public function safeUp(): bool { if ($this->createTables()) { $this->addForeignKeys();
// Refresh the db schema caches Craft::$app->getDb()->schema->refresh(); }
return true; }
protected function createTables(): bool { if (!$this->db->tableExists(ExportRecord::tableName())) { $this->createTable(ExportRecord::tableName(), [ 'id' => $this->integer()->notNull(), 'name' => $this->string()->notNull(), 'elementType' => $this->string()->notNull(), 'settings' => $this->longText(), 'attributes' => $this->longText(), 'fields' => $this->longText(), 'runSettings' => $this->longText(), 'dateCreated' => $this->dateTime()->notNull(), 'dateUpdated' => $this->dateTime()->notNull(), 'uid' => $this->uid(), 'PRIMARY KEY([[id]])', ]); } return true; }
protected function addForeignKeys(): void { $this->addForeignKey(null, ExportRecord::tableName(), 'id', Table::ELEMENTS, 'id', 'CASCADE'); }
public function safeDown() { $this->dropTableIfExists(ExportRecord::tableName()); parent::safeDown(); // TODO: Change the autogenerated stub }}