public function safeUp()
 {
     $this->addForeignKey('fk_book_author', Book::tableName(), 'author_id', Author::tableName(), 'id');
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(Author::className(), ['id' => 'author_id'])->from(['author' => Author::tableName()]);
 }
 public function down()
 {
     echo "m151129_133024_author_table_create cannot be reverted.\n";
     $this->dropTable(\app\models\Author::tableName());
 }
 public function init()
 {
     $this->tableName = Author::tableName();
     parent::init();
 }