Skip to content

graflo.migrate.emitters.neo4j

Neo4j migration emitter.

Attributes

SUPPORTED_OPS = {OperationType.ADD_VERTEX, OperationType.ADD_EDGE, OperationType.ADD_VERTEX_FIELD, OperationType.ADD_EDGE_FIELD, OperationType.ADD_VERTEX_INDEX, OperationType.ADD_EDGE_INDEX} module-attribute

Classes

Neo4jEmitter

Bases: BaseEmitter

Safe v1 Neo4j executor: additive operations only.

Source code in graflo/migrate/emitters/neo4j.py
class Neo4jEmitter(BaseEmitter):
    """Safe v1 Neo4j executor: additive operations only."""

    @property
    def backend_name(self) -> str:
        return "neo4j"

    def supports(self, operation: MigrationOperation) -> bool:
        return operation.op_type in SUPPORTED_OPS

    def dry_run_message(
        self, operation: MigrationOperation, *, target_schema: Schema
    ) -> str:
        _ = target_schema
        return f"[neo4j] would apply {operation.op_type} on {operation.target}"

    def execute(
        self,
        conn: Connection,
        operation: MigrationOperation,
        *,
        target_schema: Schema,
    ) -> str:
        if not self.supports(operation):
            raise ValueError(
                f"Operation not supported by neo4j v1 emitter: {operation.op_type}"
            )
        self._ensure_schema(conn, target_schema)
        return f"[neo4j] applied {operation.op_type} on {operation.target}"

Attributes

backend_name property

Methods:

dry_run_message(operation, *, target_schema)
Source code in graflo/migrate/emitters/neo4j.py
def dry_run_message(
    self, operation: MigrationOperation, *, target_schema: Schema
) -> str:
    _ = target_schema
    return f"[neo4j] would apply {operation.op_type} on {operation.target}"
execute(conn, operation, *, target_schema)
Source code in graflo/migrate/emitters/neo4j.py
def execute(
    self,
    conn: Connection,
    operation: MigrationOperation,
    *,
    target_schema: Schema,
) -> str:
    if not self.supports(operation):
        raise ValueError(
            f"Operation not supported by neo4j v1 emitter: {operation.op_type}"
        )
    self._ensure_schema(conn, target_schema)
    return f"[neo4j] applied {operation.op_type} on {operation.target}"
supports(operation)
Source code in graflo/migrate/emitters/neo4j.py
def supports(self, operation: MigrationOperation) -> bool:
    return operation.op_type in SUPPORTED_OPS