drizzle-team / drizzle-team/drizzle-orm
[Bug]: Expo SQLite Migrator fails with "Missing migration" despite correct MigrationConfig
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.44.0
### What version of `drizzle-kit` are you using?
0.31.1
### Other packages
_No response_
### Describe the Bug
Hi Drizzle Team,
I'm encountering a persistent issue with the drizzle-orm/expo-sqlite/migrator where it consistently throws a "Missing migration" error, even though my MigrationConfig object (containing the journal and migration SQL) appears to be perfectly formed and correctly passed to the migrate function. This occurs in an Expo Go environment.
When attempting to run Drizzle migrations using migrate from drizzle-orm/expo-sqlite/migrator, the process fails with Error: Missing migration: [migration_tag]. My debugging efforts show that the MigrationConfig object, containing both the _journal.json data and the SQL content for the migration, is correctly constructed and passed to the migrate function. The migration tag in the journal matches the key in the migrations object precisely, and the migration value is the full SQL string.
The Drizzle migrate function should successfully apply the migration(s) and the database schema should be updated. No "Missing migration" error should occur, as the MigrationConfig is correctly provided.
The migrate function throws Error: Missing migration: [migration_tag]. My extensive debugging shows that the MigrationConfig object passed to migrate does contain the correct migration tag as a key, and its value is the full SQL content string.
Here are the relevant logs :
LOG [App] Démarrage de l'initialisation de l'application...
LOG --- Démarrage de performMigrations ---
LOG Chargement de la configuration des migrations...
LOG [Migrations Loader] Démarrage du chargement des migrations via require.context...
LOG [Migrations Loader] Fichiers trouvés dans le contexte de migration: ["./0000_lonely_doctor_spectrum.sql", "./meta/_journal.json"]
LOG [Migrations Loader] Debug journal content - Type (initial): object
LOG [Migrations Loader] Debug journal content - Value (initial): {"dialect": "sqlite", "entries": [{"breakpoints": true, "idx": 0, "tag": "0000_lonely_doctor_spectrum", "version": "6", "when": 1749127930828}], "version": "7"}
LOG [Migrations Loader] Journal chargé.
LOG [Migrations Loader] Migration SQL '0000_lonely_doctor_spectrum' chargée.
LOG [Migrations Loader] Contenu SQL de '0000_lonely_doctor_spectrum': CREATE TABLE `conclusion` ( `id` text PRIMARY KEY NOT NULL,
`patient_id` text,
`conclusionFreetex...
LOG [Migrations Loader] Comparaison des tags:
LOG [Migrations Loader] Tag extrait : "0000_lonely_doctor_spectrum" (Longueur: 27)
LOG [Migrations Loader] Tag attendu : "0000_lonely_doctor_spectrum" (Longueur: 27)
LOG [Migrations Loader] Sont-ils identiques ? true
LOG [Migrations Loader] 1 migrations SQL chargées.
LOG DEBUG: Final migrationConfig passed to migrate: {
"journal": {
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1749127930828,
"tag": "0000_lonely_doctor_spectrum",
"breakpoints": true
}
]
},
"migrations": {
"0000_lonely_doctor_spectrum": "CREATE TABLE `conclusion` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`patient_id` text,\n\t`conclusionFreetext` text,\n\t`motifnon` text,\n\t`precis` text,\n\t`grievances` text,\n\t`clinicalExamPerformed_freeText` text,\n\t`exam_freeText` text,\n\t`treatmentPrescription_freeText` text,\n\t`precis2` text,\n\t`ccl3` text,\n\t`custodyAbilityFreeText` text,\n\t`choix2` text,\n\t`choix3` text,\n\t`choix4` text,\n\t`choix5` text,\n\t`choix6` text,\n\t`showcertifcomp` integer,\n\t`showtxtccl` integer,\n\t`showcompgav` integer,\n\t`priorConsent_yesNo` text,\n\t`treatmentPrescription_yesNo` text,\n\t`directDelivery_yesNo` text,\n\t`deferredDelivery_yesNo` text,\n\t`visibleRecentTraumaticLesions_yesNo` text,\n\t`clinicalExamPerformed_yesNo` text,\n\t`prescription_yesNo` text,\n\t`lesionsDescriptionCertificate_yesNo` text,\n\t`choix6YesNo` text,\n\t`selectedValue` text,\n\t`selectedValue2` text,\n\t`selectedValue3` text\n);\n--> statement-breakpoint\nCREATE TABLE `exam` (\n\t`id` text NOT NULL,\n\t`year` integer NOT NULL,\n\t`cancellation_time` text,\n\t`cancelled` integer DEFAULT 0,\n\t`cancelled_by_user` integer DEFAULT 0,\n\t`patient_id` text,\n\t`appointment_date` text,\n\tPRIMARY KEY(`id`, `year`)\n);\n--> statement-breakpoint\nCREATE TABLE `fruit` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`name` text,\n\t`color` text,\n\t`sugar` text,\n\t`shape` text\n);\n--> statement-breakpoint\nCREATE TABLE `patient` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`nom` text,\n\t`prenom` text,\n\t`sexe` text,\n\t`nomUsage` text,\n\t`addresse` text,\n\t`email` text,\n\t`telephone` text,\n\t`birth_year` integer,\n\t`lastname_crypt` text,\n\t`firststname_crypt` text,\n\t`birthdate_crypt` text\n);\n--> statement-breakpoint\nCREATE TABLE `variable` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`name` text,\n\t`input_group_id` text,\n\t`elt_julia_type_name` text,\n\t`julia_type_name` text,\n\t`julia_function_for_web_value_transformation` text,\n\t`value_type` text NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `variable_input_group` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`name` text NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `variable_value` (\n\t`id` text NOT NULL,\n\t`year` integer NOT NULL,\n\t`exam_id` text,\n\t`variable_id` text,\n\t`appointment_date` text,\n\t`value_crypt` text,\n\tPRIMARY KEY(`id`, `year`)\n);\n"
}
}
LOG Démarrage du processus de migration Drizzle Kit...
ERROR Erreur CRITIQUE lors de la migration Drizzle Kit : [Error: Missing migration: 0000_lonely_doctor_spectrum]
ERROR [App] Erreur lors de l'initialisation de l'application: [Error: Missing migration: 0000_lonely_doctor_spectrum].
Contributor guide
Assessment
This issue has not been assessed yet.