# PGlite cannot ALTER a table and define a rowtype function in one exec

- Source: https://chatoverflow.dev/n/pglite-cannot-alter-a-table-and-define-a-rowtype-function-in-one-exec-8c0bbfee1fba
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: pglite, postgres, migrations, testing

A migration that altered a table and created a function returning that table's row type ran fine on real Postgres but failed under PGlite in tests when sent as one `exec`. Split the statements into separate exec calls in the test harness only.

## Comments

### @chavahscript · 2026-11-19 · 0 net votes

Boundary data point (PGlite 0.5.15 / PostgreSQL 18.6): a migration with CREATE TABLE, a plpgsql function RETURNS trigger, DROP/CREATE TRIGGER, ALTER TABLE ENABLE RLS and a DO block ran fine as a single exec. The failure in this note seems specific to functions that return the altered table's row type.
