Moor and Drift
Moor has been renamed to
drift. The reason for this is that, in some parts of the world, moor may be used as a derogatory term. I have not been aware of this when starting this project, but we believe that the current name does not reflect the inclusivity of the Dart and Flutter communities. Despite the associated effort, I'm convinced that renaming the project is the right decision. Thank you for your understanding!
5.0.0, the current
moor_generator packages will continue to work - no urgent action is necessary. All features and fixes to the new
drift packages will be mirrored in
moor as well. At the next breaking release, the
moor set of packages will be discontinued in favor of
This page describes how to migrate from the old
moor package to the new
drift package. This process can be automated, and we hope that the migration is a matter of minutes for you. In case of issues with the tool, this page also describes how to manually migrate to the new
To make the name change as easy as possible for you, drift comes with an automatic migration tool for your project. It will analyze your source files and perform all changes that come with this migration.
To use the migration tool, please first make sure that you're using
4.6.0 or later, for instance by updating your dependency on it:
dev_dependencies: moor_generator: ^4.6.0
Next, please make sure that your project does not contain analysis errors, as this could make the migration tool less effective. Also, please create a backup of your project's files before running the migration tool. It will override parts of your sources without further confirmation. When using git, it is sufficient to ensure that you have a clean state.
To apply the migration, run
dart run moor_generator migrate in your project's directory. When using Flutter, run
flutter pub run moor_generator migrate instead. The migration tool with transform your pubspec,
build.yaml files and Dart source files. It will also rename
.moor files to
.drift and patch imports as needed.
After running the migration, please verify the changes to ensure that they match what you expect. Also, you may have to
- Format your sources again: Run
dart format .or
flutter format .
- Re-run the build: Run
dart run build_runner buildor
flutter pub run build_runner build --delete-conflicting-outputs, respectively.
- Manually fix the changed order of imports caused by the migration.
Congratulations, your project is now using drift!
If you run into any issues with the automatic migration tool, please open an issue.
To migrate from
drift, you may have to update:
- Your pubspec
- Dart imports
- Dart code, to reflect new API names
build.yamlconfiguration files, if any
The following sections will describe each of the steps.
First, replace the
moor dependency with
dependencies: drift: ^1.0.1 dev_dependencies: drift_dev: ^1.0.2
pub get to get the new packages.
Changing Dart imports
This table compares the old imports from
moor and the new imports for
|Moor import||Drift import|
Changing Dart code
This table compares old moor-specific API names and new names as provided by
|Moor name||Drift name|
(Optional: Rename moor files)
For consistency, you can rename your
.moor files to
.drift. The drift generator will continue to accept
.moor files though.
If you opt for a rename, also update your imports and
include: parameters in database and DAO classes.
When configuring moor builders for options, you have to update your
build.yaml files to reflect the new builder keys:
|Moor builder key||Drift builder key|