# Migrate from DMN or Drools (/docs/guides/migrate-from-dmn-and-drools)



Migrating is two jobs: the part a tool can do (DMN import), and the part that needs a person (anything
that has no DMN form). This page separates them so you can estimate the work before you start.

## Choose a path [#choose-a-path]

| You have                                                | Path                                                                                                  |
| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| DMN 1.3 models (Camunda, Trisotech, Kogito, Drools DMN) | **Import DMN**: tables and the DRD arrive as tables and a flow.                                       |
| Drools decision tables in a spreadsheet                 | Re-map the columns to the [spreadsheet format](/docs/guides/decision-tables#spreadsheets) and import. |
| Drools DRL rules, or rules in Java                      | **Rewrite** as tables, conditions and calculations. There is no DRL importer.                         |
| Rules in application code                               | Same: extract them into a decision, then call it.                                                     |

If the engine you are leaving can **export DMN** (Drools and Kogito can), do that first, even for
logic that was authored in another form: the importer tells you precisely what it could not read.

## 1. Inventory [#1-inventory]

List every decision with its inputs, outputs and consumers. Mark each as *table-shaped* (thresholds
and categories), *calculation-shaped* (formulas) or *procedural* (loops, mutation, side effects). The
first two migrate cleanly; the third needs a redesign.

## 2. Import the DMN [#2-import-the-dmn]

**Decisions → Import DMN**. Before anything is written, you get a list of what was not carried over.
Read it: a rule whose condition could not be read is imported **disabled**, never silently widened.
Details and the hit-policy map are in [DMN 1.3](/docs/guides/dmn).

## 3. Translate what did not import [#3-translate-what-did-not-import]

| In DMN / FEEL                                                   | In Decision Control                                                      |
| --------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Unary tests in a cell (`< 10`, `[1..5]`, `"A","B"`, `not("X")`) | Imported as cell conditions.                                             |
| Literal expression (`a * b`)                                    | A **Calculate** node, with the formula `a * b`.                          |
| `if … then … else`                                              | A **Condition** node, or a **Switch** for several cases.                 |
| `some x in list satisfies …`                                    | `some(list, condition)`, authored as JSON.                               |
| `for x in list return …`                                        | `map(list, expression)`, or a **For each** node when it calls something. |
| `sum`, `min`, `max`, `count`                                    | `dec_sum`, `dec_min`, `dec_max`, `len`.                                  |
| String functions (`substring`, `string length`)                 | `substr`, `len`, `cat`, `matches`.                                       |
| `date and time`, `now()`, durations                             | `now()` is injected; use `days_between` and `add_days`.                  |
| Business knowledge model (BKM)                                  | A **sub-decision**, or a reusable table.                                 |
| Boxed context                                                   | Variables set by **Calculate** nodes, in order.                          |
| `COLLECT` with an aggregator (`COLLECT SUM`)                    | **Collect** policy, then `dec_sum` over the result.                      |

The full vocabulary is in the [Expression reference](/docs/reference/expressions).

## 4. Translate Drools rules [#4-translate-drools-rules]

DRL is procedural and stateful; a decision here is a pure function of its input. The mapping that
usually works:

| Drools                                                     | Decision Control                                                                        |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| A fact type (`Applicant`)                                  | The **input model** (a JSON Schema).                                                    |
| `when` conditions                                          | Table cells, or a **Condition** node.                                                   |
| `then` that sets a field                                   | An **output** column of the table, or a **Calculate** node.                             |
| `then` that calls a service or sends a message             | An **Action** or **API call** node.                                                     |
| Salience                                                   | The **priority** column with a `PRIORITY` table, or row order with `FIRST`.             |
| Rule flow / agenda groups                                  | The flow: nodes in an order you can see.                                                |
| `insert` / `modify` that re-fires rules (forward chaining) | No equivalent. Model it as an explicit sequence of nodes, or iterate with **For each**. |
| Working-memory queries                                     | A **Lookup** node (reference data in a dataset) or a **Query** node (a database).       |

Two behaviours differ on purpose. **Nothing re-fires**: a rule runs once, in the order the flow
says. **There is no hidden state** between calls, which is what makes every run replayable.

## 5. Prove equivalence before cutting over [#5-prove-equivalence-before-cutting-over]

Do not trust the translation by inspection.

1. Export a sample of real inputs and the answers the old engine gave.
2. Load them as a [dataset](/docs/guides/datasets) or [test cases](/docs/guides/test-cases) with the
   old answer as the expected output.
3. Run them. Every difference is either a translation error or a bug the old system had; decide which.
4. Run a [backtest](/docs/guides/backtesting) on a wider history, and read the cases that differ.
5. Check the **coverage warnings** on each table: gaps and overlaps the old engine may have resolved
   by accident.

## 6. Cut over safely [#6-cut-over-safely]

Publish the migrated decision and call it from a **non-production environment** first
([Environments](/docs/concepts/environments)). Switch consumers one at a time by changing only the
endpoint and the API key. Keep the old engine answering until the comparison has been quiet for as
long as your risk owner requires; then retire it. Rolling back is pointing the consumer back.

## Common surprises [#common-surprises]

* **Numbers.** Arithmetic here is exact decimal. If the old system used binary floating point, a
  borderline value can now land on the other side of a threshold. That is the new answer being
  right, but it is a behaviour change: find it in the comparison.
* **Missing data.** A missing field is `null` and compares false; some engines throw. Decide the
  intended behaviour and write it as an explicit rule.
* **Hit policy.** DMN `UNIQUE` becomes first-match, so overlapping rules that DMN would have rejected
  now pick the first. The coverage analysis flags the overlap: resolve it.
* **Time.** Anything that read the system clock must use `now()`, which is the execution time.
