mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Implemented webhooks database structure and console command register webhooks
This commit is contained in:
		
							
								
								
									
										28
									
								
								console/migrations/m180706_230451_webhooks.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								console/migrations/m180706_230451_webhooks.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
<?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}}');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user