tachybase_todo/docs/tr-TR/development/server/migration.md
altaytahsin ad4929e48b
Turkish language created for Docs. Belgeler için türkçe dil desteği ()
* Turkish language created for Docs. Belgeler için türkçe dil desteği oluşturuldu.

* Turkish docs fix
2022-12-23 09:42:44 +08:00

1.2 KiB

Database Migration

There may be some incompatible changes during the plugin update iteration, these incompatible upgrade scripts can be handled by writing migration files.

How to add a migration file?

export class MyPlugin extends Plugin {
  load() {
    // Load a single Migration file
    this.db.addMigration();
    // Load multiple Migration files
    this.db.addMigrations();
  }
}

API reference.

When to execute?

## When the app is upgraded, migrator.up() and db.sync() are executed
yarn nocobase upgrade
# Trigger migration separately
yarn nocobase migrator up

When do I need to write a migration file?

It is usually used to update the system configuration stored in the database during the upgrade process. If it is just a collection configuration change, you don't need to configure migration, just execute yarn nocobase db:sync to synchronize to the database.

Migration file

import { Migration } from '@nocobase/server';

export default class CustomMigration extends Migration {
  async up() {
    // 
  }

  async down() {
    // 
  }
}