Examples of NuoDB Migrator Schema Command

Usage Examples

Generated schema can be exported to a NuoDB database through --target.* options, to a file via the --output.path parameter. If neither a target database nor a file were provided, scripts are written to the standard output stream. The following command generates NuoDB schema from a MySQL catalog and prints it to the standard output.

nuodb-migrator schema                             \
       --source.driver=com.mysql.jdbc.Driver      \
       --source.url=jdbc:mysql://localhost/test   \
       --source.username=root                     \
       --source.password=12345

The tool generates DROP and CREATE statements for target objects. Using the --script.type option, you can alter the default behavior. The following causes only DROP statements to be outputted:

nuodb-migrator schema ... --script.type=drop

You can exclude certain types of objects from the output by listing them in the --meta.data.* option. The command below instructs the migrator to not include foreign keys and auto incremented columns into generated DDL scripts:

nuodb-migrator schema ...                \
       --meta.data.foreign.key=false     \
       --meta.data.auto.increment=false
In any event, foreign keys are ignored, with no action as the default should they be included.

NuoDB Migrator uses identifier quoting and identifier normalizer policies to produce names for tables and columns. Those policies may be overridden on the command line using --identifier.quoting and --identifier.normalizer parameters:

nuodb-migrator schema ...                  \
       --identifier.quoting=minimal        \
       --identifier.normalizer=lower.case

The above line will quote only identifiers which are stop words and reserved words. All generated names will appear in a lowercase format.

--use.nuodb.types Example

For the following MySQL table:

CREATE TABLE `t1` ( "f1" CHAR(10) DEFAULT NULL,
   "f2" VARCHAR(10) DEFAULT NULL,
   "f3" TEXT);

Without the switch, nuodb-migrator schema {arguments} produces:

CREATE TABLE "t1" ("f1" CHAR(10),
    "f2" VARCHAR(10),
    "f3" CLOB);

With the switch on the CL nuodb-migrator schema {arguments} --use.nuodb.types generates:

CREATE TABLE "t1" ("f1" STRING, "f2" STRING, "f3" STRING);

--use.explicit.defaults Example

For the following MySQL table:

CREATE TABLE `t1` ("f1" SMALLINT(6) NOT NULL,
   "f2" DOUBLE NOT NULL,
   "f3" DECIMAL(10,0) NOT NULL,
   "f4" CHAR(10) NOT NULL, `f5` TEXT NOT NULL,
   "f6" ENUM('value1','value2','value3') NOT NULL);

Without explicit defaults nuodb-migrator schema {arguments} will result in:

CREATE TABLE "t1" ("f1" SMALLINT NOT NULL, "f2" DOUBLE NOT NULL,
    "f3" DECIMAL(10,0) NOT NULL,
    "f4" CHAR(10) NOT NULL, "f5" CLOB NOT NULL,
    "f6" CHAR(7) NOT NULL);

With explicit defaults transformed to their implicit equivalents / nuodb-migrator schema {arguments} --use.nuodb.types generates:

CREATE TABLE "t1" ("f1" SMALLINT NOT NULL DEFAULT '0',
    "f2" DOUBLE NOT NULL DEFAULT '0',
    "f3" DECIMAL(10,0) NOT NULL DEFAULT '0',
    "f4" CHAR(10) NOT NULL DEFAULT '',
    "f5" CLOB NOT NULL DEFAULT '',
    "f6" CHAR(7) NOT NULL DEFAULT 'value1');