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 } }