public function up() { $this->createTable(Category::tableName(), ['id' => Schema::TYPE_PK, 'owner_id' => $this->integer(), 'status' => Schema::TYPE_SMALLINT, 'title' => Schema::TYPE_STRING, 'name' => Schema::TYPE_STRING, 'image' => Schema::TYPE_STRING, 'content' => Schema::TYPE_TEXT, 'lft' => Schema::TYPE_INTEGER, 'rgt' => Schema::TYPE_INTEGER, 'depth' => Schema::TYPE_INTEGER]); $this->createTable(CategoryToItem::tableName(), ['category_id' => Schema::TYPE_INTEGER, 'item_id' => Schema::TYPE_INTEGER]); MigrationHelper::addForeignKey(CategoryToItem::tableName(), 'category_id', Category::tableName(), 'id', 'CASCADE', 'CASCADE'); MigrationHelper::addForeignKey(CategoryToItem::tableName(), 'item_id', Item::tableName(), 'id', 'CASCADE', 'CASCADE'); }
public function up() { $table = \app\modules\poll\models\Comment::tableName(); $this->createTable($table, ['id' => $this->primaryKey(), 'user_id' => $this->integer(), 'question_id' => $this->integer(), 'created_at' => $this->integer(), 'message' => $this->text()]); MigrationHelper::addForeignKey($table, 'user_id', \app\modules\user\models\User::tableName(), 'id', 'SET NULL', 'CASCADE'); MigrationHelper::addForeignKey($table, 'question_id', \app\modules\poll\models\Question::tableName(), 'id', 'CASCADE', 'CASCADE'); }
public function up() { $table = Vote::tableName(); $this->createTable($table, ['answer_id' => $this->integer(), 'user_id' => $this->integer(), 'created_at' => $this->integer()]); MigrationHelper::addForeignKey($table, 'answer_id', Answer::tableName(), 'id', 'CASCADE', 'CASCADE'); MigrationHelper::addForeignKey($table, 'user_id', User::tableName(), 'id', 'SET NULL', 'CASCADE'); }
public function up() { $this->createTable(Question::tableName(), ['id' => $this->primaryKey(), 'user_id' => $this->integer(), 'status' => $this->smallInteger(), 'type' => $this->smallInteger(), 'relation_id' => $this->string(), 'event_object' => $this->text(), 'title' => $this->string(), 'description' => $this->text(), 'created_at' => $this->integer()]); MigrationHelper::addForeignKey(Question::tableName(), 'user_id', User::tableName(), 'id', 'SET NULL', 'CASCADE'); }
public function up() { $table = Answer::tableName(); $this->createTable($table, ['id' => $this->primaryKey(), 'question_id' => $this->integer(), 'title' => $this->string(), 'value' => $this->string()]); MigrationHelper::addForeignKey($table, 'question_id', Question::tableName(), 'id', 'CASCADE', 'CASCADE'); }