New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prisma v4 breaks support for empty dbgenerated()
- invalid migration created with no schema change
#14799
Comments
I can confirm that on commit I can unfortunately also confirm that upgrading to the newest Prisma version then leads to
|
We are also running into this error which has been a big dealbreaker for us, as it was a perfect stop-gap before computed fields are officially supported in Prisma. |
Due to CI issues, the version of prisma-engines that was released in 4.3.0 is a bit older and does not contain this fix, sadly. So it is merged on main, it will be on 4.4.0 dev versions and in the 4.4.0 release, but it won't be in 4.3.0. |
@tomhoule Hi, could you please let us know the expected release date for version 4.4.0? I just faced with this one and it blocked me. As I understood there are only workarounds: use version lower than 4.x.x or wait for release 4.4.0 version, am I right? |
4.4.0 is scheduled for next Tuesday (Sept. 27). And yes this is a bad regression. There is another workaround: picking a dev release version on npm. They are built on a rolling basis so the fix is already in. |
@1Vlod the other workaround is to edit the failing migration file to remove the offending lines and reapply using |
now enjoying the fix in 4.4.0 - thanks @tomhoule 🙏 |
@andyjy @tomhoule This seems to still not be working for me (tried Prisma schema: model Event {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
start DateTime
end DateTime
fts Unsupported("tsvector")? @default(dbgenerated())
@@index([fts], type: Gin)
@@map("event")
} Modified SQL migration: ALTER TABLE "event" ADD COLUMN "fts" tsvector GENERATED ALWAYS AS (
to_tsvector('english',
id::text -- add the cuid to the vector
|| ' ' || COALESCE("name", '') -- concat more fields (or empty string if null)
)
) STORED;
CREATE INDEX event_fts_idx ON "event" using gin (fts); -- generate the index Prisma migrate then generates and tries to run this migration: -- AlterTable
ALTER TABLE "event" ALTER COLUMN "fts" DROP DEFAULT; Which will fail since the column is generated |
@jkcorrea you might find it useful to fork my minimum reproducible example repo and verify whether you still get this error if you swap out my example schema for yours: https://github.com/andyjy/prisma-dbgenerated-bug-repro Did you remember to update the |
That was very helpful, thanks @andyjy. Was able to use your minimum repro to figure out that it's due to using an https://github.com/jkcorrea/prisma-unsupported-dbgenerated-bug Happening in v4.4.0 and v4.5 & for both |
@jkcorrea thanks for putting the effort in writing a reproduction repo for this. Please open a new issue, since it's a different problem, otherwise it will be forgotten if it's only a comment in a closed issue. |
awesome, thanks! |
Bug description
Using Postgres generated columns via
@default(dbgenerated())
with custom PostgresGENERATED AWAYS AS ... STORED
SQL in migration worked just fine through Prisma v3; breaks with Prisma 4.0.0 onwards.Reproduction repo: https://github.com/andyjy/prisma-dbgenerated-bug-repro
Reproduction details:
schema.prisma
:..with custom migration to use Postgres generated field:
migration.sql
:Worked just fine through prisma 3.15.2; prisma 4.0.0 onwards produces invalid migration with no schema change
that attempts to DROP DEFAULT (which we don't want to do, and fails since Postgres generated columns require
use of DROP EXPRESSION if we were actually to want to convert the generated column to a normal one).
...invalid_failed_migration/migration.sql
:(unwanted new migration fails with error:)
How to reproduce
Reproduction repo: https://github.com/andyjy/prisma-dbgenerated-bug-repro
Expected behavior
Prisma 4 continues to support this schema and migration history with no attempt
to generate a new migration dropping the default value for the column.
Prisma information
Schema above + in reproduction repo
Environment & setup
Prisma Version
works up to
3.15.2
, fails since4.0.0
(tested up to4.2.1
)The text was updated successfully, but these errors were encountered: