mirror of
https://github.com/elyby/accounts.git
synced 2024-11-26 16:52:02 +05:30
29 lines
960 B
PHP
29 lines
960 B
PHP
<?php
|
|
|
|
use console\db\Migration;
|
|
|
|
class m180706_230451_webhooks extends Migration {
|
|
|
|
public function safeUp() {
|
|
$this->createTable('{{%webhooks}}', [
|
|
'id' => $this->primaryKey(11)->unsigned(),
|
|
'url' => $this->string()->notNull(),
|
|
'secret' => $this->string(),
|
|
'created_at' => $this->integer(11)->unsigned()->notNull(),
|
|
]);
|
|
|
|
$this->createTable('{{%webhooks_events}}', [
|
|
'webhook_id' => $this->db->getTableSchema('{{%webhooks}}')->getColumn('id')->dbType . ' NOT NULL',
|
|
'event_type' => $this->string()->notNull(),
|
|
$this->primary('webhook_id', 'event_type'),
|
|
]);
|
|
$this->addForeignKey('FK_webhook_event_to_webhook', '{{%webhooks_events}}', 'webhook_id', 'webhooks', 'id', 'CASCADE', 'CASCADE');
|
|
}
|
|
|
|
public function safeDown() {
|
|
$this->dropTable('{{%webhooks_events}}');
|
|
$this->dropTable('{{%webhooks}}');
|
|
}
|
|
|
|
}
|