Skip to content

Commit

Permalink
Throw Error
Browse files Browse the repository at this point in the history
  • Loading branch information
kneth committed Mar 2, 2024
1 parent 161e85e commit 9db8a05
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,11 @@ export class Realm {
const { bindingConfig, schemaExtras } = Realm.transformConfig(config);
debug("open", bindingConfig);

assert(
!!config.deleteRealmIfMigrationNeeded && binding.Helpers.needsFileFormatUpgrade(bindingConfig),
"File format upgrade is needed and setting 'deleteRealmIfMigrationNeeded' to true will erase all objects. Only use 'deleteRealmIfMigrationNeeded' for non-production cases.",
);
if (!!config.deleteRealmIfMigrationNeeded && binding.Helpers.needsFileFormatUpgrade(bindingConfig)) {
throw new Error(
"File format upgrade is needed and setting 'deleteRealmIfMigrationNeeded' to true will erase all objects. Only use 'deleteRealmIfMigrationNeeded' for non-production cases.",
);
}

this.schemaExtras = schemaExtras;
fs.ensureDirectoryForFile(bindingConfig.path);
Expand Down

0 comments on commit 9db8a05

Please sign in to comment.