A
A
Anton Natarov2016-03-02 18:40:56
Yii
Anton Natarov, 2016-03-02 18:40:56

What is the best way to write base-independent migrations?

Actually the question is how best to write migrations? What would they be adaptable to different bases?
Through the Schema class

$this->createTable('{{%someTable}}', [
            'id' => Schema::TYPE_PK,
            'notes' => Schema::TYPE_TEXT,
        ], $tableOptions);

or so?
$this->createTable('{{%someTable}}', [
            'id' => $this->primaryKey(),
            'notes' => $this->text(),
        ], $tableOptions);

Are they equivalent or not?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2016-03-02
@HanDroid

Are equivalent. Just take a look at the implementation of the methods.

/**
     * Creates a boolean column.
     * @return ColumnSchemaBuilder the column instance which can be further customized.
     * @since 2.0.6
     */
    public function boolean()
    {
        return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BOOLEAN);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question