Answer the question
In order to leave comments, you need to log in
How to convert sql file to yii2 migration with yii\db\Migration?
Good afternoon.
I am creating migrations in a yii2 project from a sql file downloaded from mysql workbench.
do it by type
public function safeUp()
{
$this->execute("
CREATE TABLE IF NOT EXISTS `table1` (
`name` VARCHAR(10) NOT NULL COMMENT '',
`nameFull` VARCHAR(45) NULL COMMENT '',
PRIMARY KEY (`name`) COMMENT '')
ENGINE = InnoDB DEFAULT CHARSET UTF8;
");
}
$this->createTable('news', [
'id' => $this->primaryKey(),
'title' => $this->string()->notNull(),
'content' => $this->text(),
]);
Answer the question
In order to leave comments, you need to log in
What for to transform if on an output there will be a similar request?
yii\db\Migration is used for flexible query building, but if you already have it, and when it is executed, the desired result is produced, then in my opinion there is no point in rewriting
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question