toCommand method

  1. @override
MigrationCommand toCommand({
  1. bool shouldDrop = false,
})

Generated Dart code to include in a migrations file.

Implementation

@override
MigrationCommand toCommand({bool shouldDrop = false}) {
  if (shouldDrop) {
    return DropColumn(name, onTable: tableName!);
  }

  if (isForeignKey) {
    return InsertForeignKey(
      tableName!,
      foreignTableName!,
      foreignKeyColumn: name,
      onDeleteCascade: onDeleteCascade,
      onDeleteSetDefault: onDeleteSetDefault,
    );
  }

  return InsertColumn(
    name,
    columnType,
    onTable: tableName!,
    defaultValue: defaultValue,
    autoincrement: autoincrement,
    nullable: nullable,
    unique: unique,
  );
}