Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Create a new ES6 file in your plugin’s CSE directory. If your plugin’s name is de.acme.projectx then cmsbs-conf/cse/plugins/de.acme.projectxtutorial/callback/DbSchemaUpdate.es6mjs would be a good choice:

Codeblock
languagejs
/// <reference path="../../../.vscode.js"/>

const SQL = UM.config.sql;

export default class DbSchemaMigration extends PluginSchemaMigration {
    schemaUpdate_0_1(scr) {
        // Create column for primary attribute "new_attribute":
        this.primaryAddColumn(scr, UM.config.getAttribute('new_attribute'));

        // Alter primary attribute's column according to the current settings from *.attributes file:
        this.primaryModifyColumn(scr, UM.config.getAttribute('altered_attribute'));

        // Create column for new table attribute's column:
        this.tableAddColumn(scr, UM.config.getAttribute('table_attribute->new_column'));

        // Alter table attribute's column according to the current settings from *.attributes file:
        this.tableModifyColumn(scr, UM.config.getAttribute('table_attribute->altered_column'));
        
        // Issue SQL statement to create an INDEX:
        this.primaryAddIndex(scr, UM.config.getAttribute('new_attribute'));

        // Issue SQL statement to mass-update some user entries:
        const update1 = new SqlQuery(`UPDATE ${SQL.qualifyTable('users')} SET p_entrytype='user' WHERE p_entrytype IS NULL`);
        scr.add(update1);
        
        // Issue SQL statement to mass-update some user entries:
        const update2 = new SqlQuery(`UPDATE ${SQL.qualifyTable('users')} SET p_entrytype='customer' WHERE p_entrytype='user'`);
        scr.add(update2);
    }
}

// Don't forget to export the class to the respective namespace:
de.acme.projectxtutorial.DbSchemaMigration = DbSchemaMigration;

...