for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace flipbox\hubspot\migrations;
use craft\db\Migration;
use craft\records\Element as ElementRecord;
class ObjectTable extends Migration
{
/**
* @var array
*/
public $tableAlias;
* @return string
private function getTableName(): string
return '{{%' . $this->tableAlias . '}}';
}
* @inheritdoc
public function safeUp()
$this->createTables();
$this->createIndexes();
$this->addForeignKeys();
return true;
* Creates the tables.
*
* @return void
protected function createTables()
$this->dropTableIfExists($this->getTableName());
$this->createTable(
$this->getTableName(),
[
'id' => $this->primaryKey(),
'elementId' => $this->integer(),
'hubspotId' => $this->char(48),
'dateCreated' => $this->dateTime()->notNull(),
'dateUpdated' => $this->dateTime()->notNull(),
'uid' => $this->uid()
]
);
* Creates the indexes.
protected function createIndexes()
$this->createIndex(
$this->db->getIndexName(
'elementId',
true,
true
),
'hubspotId',
false,
false
'elementId,hubspotId',
* Adds the foreign keys.
protected function addForeignKeys()
$this->addForeignKey(
$this->db->getForeignKeyName(
'elementId'
ElementRecord::tableName(),
'id',
'CASCADE',
null
public function safeDown()