{"record":{"id":"78e783155016c551","repo":"nextauthjs/next-auth","slug":"adapter-typeorm-updating-entities","errorCode":"adapter_typeorm_updating_entities","errorMessage":"[next-auth][warn][adapter_typeorm_updating_entities]\nhttps://authjs.dev/reference/warnings#adapter_typeorm_updating_entities","messagePattern":"\\[next-auth\\]\\[warn\\]\\[adapter_typeorm_updating_entities\\]\nhttps://authjs\\.dev/reference/warnings#adapter_typeorm_updating_entities","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/adapter-typeorm/src/utils.ts","lineNumber":104,"sourceCode":"  }\n\n  return false\n}\n\nexport async function updateConnectionEntities(\n  dataSource: DataSource,\n  entities: any[]\n) {\n  if (!entitiesChanged(dataSource.entityMetadatas, entities)) return\n\n  // @ts-expect-error\n  dataSource.entityMetadatas = entities\n\n  // @ts-expect-error\n  await dataSource.buildMetadatas()\n\n  if (dataSource.options.synchronize !== false) {\n    console.warn(\n      \"[next-auth][warn][adapter_typeorm_updating_entities]\",\n      \"\\nhttps://authjs.dev/reference/warnings#adapter_typeorm_updating_entities\"\n    )\n    await dataSource.synchronize()\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":111,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-typeorm/src/utils.ts#L86-L111","documentation":"The TypeORM adapter can auto-sync schema changes to your database via dataSource.synchronize(). Because this mutates your database schema automatically (risky in production), the adapter warns loudly when it is about to run synchronize because `synchronize` was not explicitly set to false. It is a warning, not a failure — schema sync still happens.","triggerScenarios":"Instantiating the TypeORM adapter without `synchronize: false` in the DataSource options; getManager/updateConnectionEntities then builds entity metadata and runs dataSource.synchronize(), emitting this warning first.","commonSituations":"Bootstrapping a NextAuth app in development where the adapter creates/alters tables automatically; deploying to production with default options and discovering unintended schema migrations; upgrading TypeORM and entities so metadata rebuild triggers sync.","solutions":["Set `synchronize: false` in the TypeORM DataSource options and manage schema with migrations","Use `migrationsRun: true` with generated migration files instead of automatic synchronize","Keep synchronize enabled only in development and acknowledge/silence the warning there"],"exampleFix":"// before\nexport const adapter = TypeORMAdapter(connectionString)\n// after\nexport const adapter = TypeORMAdapter({\n  type: \"postgres\",\n  url: process.env.DATABASE_URL,\n  synchronize: false,\n  migrationsRun: true,\n  entities: [...models]\n})","handlingStrategy":"validation","validationCode":"if (dataSource.options.synchronize !== false) {\n  console.warn(\"TypeORM adapter will auto-sync your schema; set synchronize: false for production\")\n}","typeGuard":"function isSchemaSafe(opts: { synchronize?: boolean }): boolean {\n  return opts.synchronize === false\n}","tryCatchPattern":null,"preventionTips":["Explicitly set synchronize: false in all non-development environments","Use TypeORM migrations (migrationsRun: true) instead of auto-sync","Audit DATABASE_URL/config per environment before deploy","Expect this warning in dev and treat it as a reminder to add migrations"],"tags":["typeorm","database","schema-sync","migration","console-warning"],"backgroundTag":"typeorm-auto-schema-sync","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}