createTable( '{{%artbox_comment}}', [ 'id' => $this->primaryKey(), 'text' => $this->text() ->notNull(), 'customer_id' => $this->integer(), 'username' => $this->string(), 'email' => $this->string(), 'created_at' => $this->integer() ->notNull(), 'updated_at' => $this->integer() ->notNull(), 'deleted_at' => $this->integer(), 'status' => $this->integer() ->notNull() ->defaultValue(1), 'parent_id' => $this->integer(), 'related_id' => $this->integer(), 'ip' => $this->string() ->notNull(), 'info' => $this->text(), 'entity' => $this->string() ->notNull() ->defaultValue(''), 'entity_id' => $this->integer() ->notNull() ->defaultValue(1), ] ); $this->addForeignKey( 'parent_id_artbox_comment', '{{%artbox_comment}}', 'parent_id', 'artbox_comment', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( 'related_id_artbox_comment', '{{%artbox_comment}}', 'related_id', 'artbox_comment', 'id', 'CASCADE', 'CASCADE' ); $this->createTable( '{{%artbox_like}}', [ 'id' => $this->primaryKey(), 'artbox_comment_id' => $this->integer() ->notNull(), 'customer_id' => $this->integer(), 'created_at' => $this->integer() ->notNull(), 'is_like' => $this->integer() ->notNull() ->defaultValue(1), ] ); $this->addForeignKey( 'artbox_comment_id_artbox_comment', '{{%artbox_like}}', 'artbox_comment_id', 'artbox_comment', 'id', 'CASCADE', 'CASCADE' ); $this->createIndex( 'artbox_like_unique', '{{%artbox_like}}', [ 'artbox_comment_id', 'customer_id', 'is_like', ], true ); } public function down() { $this->dropForeignKey('parent_id_artbox_comment', '{{%artbox_comment}}'); $this->dropForeignKey('related_id_artbox_comment', '{{%artbox_comment}}'); $this->dropForeignKey('artbox_comment_id_artbox_comment', '{{%artbox_like}}'); $this->dropIndex('artbox_like_unique', '{{%artbox_like}}'); $this->dropTable('{{%artbox_comment}}'); $this->dropTable('{{%artbox_like}}'); } }