Repository navigation
Importers
Manech Dubreil edited this page Oct 16, 2026
·
4 revisions
An importer turns a source ORM's schema text into a pivot::Schema. Every
importer implements the same trait, defined in crates/core/src/importer/mod.rs:
pub trait Importer {
fn import(&self, input: &str) -> Result<Schema, ImportError>;
}
pub enum ImportError {
Parse(String), // input could not be parsed at all
Schema(String), // parsed, but semantically invalid (e.g. unknown type reference)
}| ORM | Page | Module | File extension |
|---|---|---|---|
| Prisma | Prisma Importer |
crates/core/src/importer/prisma/ (PrismaImporter) |
.prisma |
Each importer is registered in crates/core/src/registry.rs alongside its
file extension so the CLI can auto-detect it.
Following the Prisma importer:
- Create a new module under
crates/core/src/importer/<orm_name>/and implement theImportertrait on a zero-sized (or config-holding) struct, mirroringPrismaImporter. - Keep any parser-specific intermediate representation (your equivalent of
ast.rs) private to your module (pub(super)), and only ever construct/returnpivot::Schemaat the boundary. -
Never mutate pivot types from within the importer. If the source ORM has a feature
with no IR equivalent, add it to
OrmMetadata.unknown_featuresrather than proposing a pivot change from inside the importer — pivot changes are cross-cutting and must keep every importer/exporter consistent. - Register the ORM in
crates/core/src/registry.rs'sORMSslice with its file extension(s) and amake_importerfactory — see CLI for the exact shape. - Add tests following the existing
crates/core/src/importer/prisma/tests.rsstyle: focused unit tests per feature, plus one comprehensive test parsing a realistic multi-table fixture (seetest.prismaat the repo root and theparse_full_test_schematest) and asserting a full JSON round-trip. See Testing for how to run the suite and the CI quality gates every PR must pass.
crates/core/src/exporter/mod.rs defines the mirror-image trait, with no implementations yet:
pub trait Exporter {
fn export(&self, schema: &Schema) -> Result<String, ExportError>;
}
pub enum ExportError {
Unsupported(String), // the schema contains a construct with no target-ORM equivalent
Render(String), // serialization failed for an internal reason
}When the first exporter is implemented, it will be registered the same way as an importer
— via make_exporter in the relevant OrmDescriptor in crates/core/src/registry.rs.
|
Manech DUBREIL dmanech@gmail.com |
Timéo TRÉGAROT timeo.tregarot@epitech.eu |
Aymeric JOUANNET-MIMY aymeric.jouannet-mimy@epitech.eu |
Esteban BOUYAULT-MIMY esteban.bouyault-yvanez@epitech.eu |
Arthur DRAHY arthur.drahy@epitech.eu |