{
  "id": 8012574,
  "title": "Four Ways to Seed a Postgres Database, and What Each Does When the Schema Moves",
  "url": "https://urgent.news/2026/09/17/four-ways-to-seed-a-postgres-database-and-what-each-does-when-the",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-17T06:26:31.000Z",
  "source": {
    "name": "HackerNoon",
    "slug": "hackernoon",
    "url": "https://hackernoon.com/four-ways-to-seed-a-postgres-database-and-what-each-does-when-the-schema-moves?source=rss"
  },
  "original_language": "en",
  "account": "Here are four ways to seed a PostgreSQL database and how each method behaves when the schema changes:\n\n1. Raw SQL: Raw SQL statements survive more schema changes compared to other methods. They report fewer errors but require human intervention to cover all possible changes. Positional inserts work well with raw SQL as they automatically fill in missing columns with default values.\n\n2. Positional Inserts: Positional inserts are robust when it comes to schema changes. When a column is added or a column's name changes, positional inserts simply fill in the missing columns with default values or ignore the changes altogether. This approach is convenient but lacks visibility into the actual schema changes happening.\n\n3. Named-Column Inserts: Named-column inserts provide better visibility into schema changes compared to positional inserts. When a column is renamed or its type changes, named-column inserts fail with explicit error messages pointing out the specific column that caused the issue. This approach is helpful during development and testing but may be less convenient for production migrations.\n\n4. Enums and Constraints: Enums and constraints are sensitive to schema changes. When a column's type changes to an enum, and existing rows contain values that are not part of the new enum set, the conversion fails. Similarly, adding a foreign key constraint to a table with existing rows that have no matching values in the referenced table also leads to failures. These failures occur immediately after the schema change, making them easier to identify but potentially requiring more effort to address the underlying data issues.",
  "summary": "Why a Postgres migration breaks a seed script: four exact DDL changes, the errors they throw, and which seeding approach survives each one. Tested on PG 17.",
  "key_points": [],
  "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."
}