{
  "id": 20199221,
  "title": "Prisma Migrations When AI Features Touch Your Database",
  "url": "https://urgent.news/2026/11/15/prisma-migrations-when-ai-features-touch-your-database",
  "topic": "world",
  "section": "World",
  "published": "2026-11-15T16:02:42.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ganeshjoshi/prisma-migrations-when-ai-features-touch-your-database-4521"
  },
  "original_language": "en",
  "account": "AI features in your database create a unique footprint, leading to the creation of chat messages, tool calls, and user feedback. These new types of data generate a rapid increase in table growth. Migrations involving these tables can be challenging, as a single user session may write numerous rows in a message table, while a regular feature might only write one row. This discrepancy in growth rate can cause significant issues. To mitigate these issues, it is essential to model message rows as immutable, appending new rows as they come in. This approach simplifies migrations, as there are no in-place updates to manage, and backfills can run in ranges without interfering with live writes. Adding an index to a growing table can also cause problems, as default Postgres locks the table for the duration of the build. To avoid this, Prisma Migrate generates a plain CREATE INDEX, which can be edited to use the concurrent form. This allows for shorter transactions and the ability to stop the index build partway if needed. When planning the retention policy for conversation data, it is crucial to consider what will happen to the data in the long run. Deleting long conversations containing foreign key relationships can be difficult, so it is advisable to batch deletions by conversation rather than by date range. Before implementing any migration, it is essential to review the generated SQL, as a single mistake can lead to significant downtime. Reading the SQL and checking for table rewrites, index builds, and NOT NULL additions on existing columns can help ensure a safe migration.",
  "summary": "This post was created with AI assistance and reviewed for accuracy before publishing. AI features arrive with a distinctive database footprint. You need somewhere to keep conversations, the messages inside them, the tool calls each message triggered, and the feedback users leave. Individually these look like ordinary tables. Collectively they are the fastest-growing thing in your schema, because…",
  "key_points": [
    "AI features generate new data types causing rapid table growth",
    "Model message rows as immutable to simplify migrations",
    "Prisma Migrate provides concurrent index creation to avoid locks"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}