Database Migrations

We use database migrations when necessary to alter the database schema or data as part of an update. This ensures that the changes are applied (and if necessary, reverted) consistently across all environments and removes the possibility of manual error.

Migrations are executed automatically by Meteor as part of the deployment process, you just need to ensure your migrations are named correctly and committed to the appropriate location in your project.

You can generate a new, empty migration class file using the meteor tool:

php meteor.phar migration:generate

This will create a new migration file using the current date and time stamp in the upgrades/migrations directory.

Fill in the up() and down() methods with the operations required to upgrade and revert your change.

In the example below, we add a new table CustomDataTable.

namespace DoctrineMigrations;

use Doctrine\DBAL\Migrations\AbstractMigration,

class Version20191107080401 extends AbstractMigration
    public function up(Schema $schema)
        $this->addSql('CREATE TABLE CustomDataTable (id INT AUTO_INCREMENT NOT NULL, data VARCHAR(100)')

    public function down(Schema $schema)
        $this->addSql('DROP TABLE CustomDataTable);

You can read more about migrations and the methods availabe in the Doctrine Migration Classes documentation.

results matching ""

    No results matching ""