Prompt file imported from NextStep-Software-Solutions-Inc/clinicez-arch2 (
.github/prompts/drizzle-migration.prompt.md). Copyright stays with the author.
You are adding a new Drizzle ORM table or column to the Clinic EZ Patient App schema at apps/patient-app/.
Steps
-
Read existing schema — Read all files in
apps/patient-app/db/schema/to understand current table patterns, naming conventions, and column types in use. -
Define the table/column — Create or update the appropriate file in
apps/patient-app/db/schema/. Follow these rules:- Use
sqliteTablefromdrizzle-orm/sqlite-core. - Column naming:
camelCasein TypeScript,snake_casein the DB (columnName: text('column_name')). - Always include
createdAtandupdatedAttimestamp columns on new tables. - Use
integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true })for surrogate keys. - For foreign keys to
patients, usepatientId: integer('patient_id').references(() => patients.id).
- Use
-
Export from index — Add the new table (and its inferred types) to
apps/patient-app/db/schema/index.ts:export * from './newTable'; export type NewTable = typeof newTable.$inferSelect; export type NewNewTable = typeof newTable.$inferInsert; -
SyncQueue consideration — If the new table stores data that must sync to a clinic backend, confirm with the user whether mutations to this table should be enqueued in
syncQueue. If yes, show the enqueue pattern using the existingsyncQueueschema as a reference. -
Remind about migration — After all edits, output this reminder:
Run the following in
apps/patient-app/to generate the migration:bun run db:generateThen restart the Expo dev server so the new migration is applied on next app launch.
Constraints
- DO NOT edit any file inside
apps/patient-app/drizzle/— those are auto-generated. - DO NOT write manual TypeScript interfaces for DB row types — always use
$inferSelect/$inferInsert. - Stay inside
apps/patient-app/.
