H
H
Hfnas2019-07-16 00:38:10
Zend Framework
Hfnas, 2019-07-16 00:38:10

Data migrations in zendframework?

How are data migrations carried out (insertions/updating values ​​in a table)?
And is it relevant to do them?

public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs

        $table = $schema->createTable('albums');
        $table->addColumn('id', 'integer', ['autoincrement'=>true]);
        $table->addColumn('artist', 'text', ['notnull'=>true]);
        $table->addColumn('title', 'text', ['notnull'=>true]);
        $table->setPrimaryKey(['id']);
        $table->addOption('engine' , 'InnoDB');
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kafkiansky, 2019-07-16
@Hfnas

Imagine you are upgrading production and you have 10 new tables. You will not create them by hand. In addition, it is convenient to manipulate migrations: you can run one specific one, roll back one specific one.
how data migrations are carried out (inserts / updates values ​​in the table)
In general, these are pre-generated scripts, exact casts of tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question