public function up()
 {
     if (!$this->existsTable('services')) {
         $this->createTable('services', ['title' => ['type' => 'string'], 'text' => ['type' => 'text']], [['columns' => ['title']]]);
     }
     if (!$this->existsTable('trainers')) {
         $this->createTable('trainers', ['name' => ['type' => 'string'], 'text' => ['type' => 'text']], [['columns' => ['name']]]);
     }
     if (!$this->existsTable('students')) {
         $this->createTable('students', ['name' => ['type' => 'string'], 'text' => ['type' => 'text'], '__trainer_id' => ['type' => 'link'], '__service_id' => ['type' => 'link']], [['columns' => ['name']]]);
     }
     if (!$this->existsTable('org')) {
         $this->createTable('org', ['title_short' => ['type' => 'string'], 'title' => ['type' => 'string'], 'address' => ['type' => 'string'], 'email' => ['type' => 'string'], 'phone' => ['type' => 'string'], 'text' => ['type' => 'text'], 'direct_name' => ['type' => 'string'], 'direct_about' => ['type' => 'text']], [['columns' => ['title']]]);
     }
     $org = new Org();
     $org->save();
     if (!$this->existsTable('services_to_trainers')) {
         $this->createTable('services_to_trainers', ['__trainer_id' => ['type' => 'link'], '__service_id' => ['type' => 'link']]);
     }
     if (!$this->existsTable('services_to_students')) {
         $this->createTable('services_to_students', ['__student_id' => ['type' => 'link'], '__service_id' => ['type' => 'link']]);
     }
     if (!$this->existsTable('students_to_trainers')) {
         $this->createTable('students_to_trainers', ['__trainer_id' => ['type' => 'link'], '__student_id' => ['type' => 'link']]);
     }
     if (!$this->existsTable('blogs')) {
         $this->createTable('blogs', ['name' => ['type' => 'string'], 'text' => ['type' => 'text'], 'published' => ['type' => 'datetime'], '__trainer_id' => ['type' => 'link']], [['columns' => ['name']]]);
     }
     if (!$this->existsTable('reviews')) {
         $this->createTable('reviews', ['text' => ['type' => 'text'], 'published' => ['type' => 'datetime']]);
     }
 }
Example #2
0
 public function actionOrg()
 {
     $this->data->item = Org::findByPK(1);
 }