`db push` fails when attempting to push empty model that is `@@ignore`d

Open
#12,232 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sqlite, typescript
Domain
database

Research direction

Reproduce the schema with the empty @@ignore model using SQLite, then read migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs and the SchemaPush entry point in migration-engine/core/src/api.rs. Done means db push no longer fails for this model, or reports a helpful validation error instead.

Written by the indexing model from the issue text.

Description

bug/2-confirmed kind/bug tech/engines topic: broken migrations topic: prisma db push topic: sqlite
Bug description

prisma db push fails with the following cryptic error when attempting to push a schema with an ignored model which is empty.

However, generation works and the prisma VS code extension doesn't highlight any errors.

When including the following model:

model Test {

  @@ignore
}

Generation will work, but db push will fail with the following error:

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database ".dev.db" at "file:.dev.db?connection_limit=1&socket_timeout=20&pool_timeout=20"

SQLite database .dev.db created at file:.dev.db?connection_limit=1&socket_timeout=20&pool_timeout=20
Error: near ")": syntax error
   0: sql_migration_connector::sql_database_step_applier::apply_migration
             at migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs:11
   1: migration_core::api::SchemaPush
             at migration-engine/core/src/api.rs:184

However, if the model is changed to:

model Test {
  id Int

  @@ignore
}

pushing will work again

How to reproduce

Include the following in your schema.prisma

model Test {

  @@ignore
}
Expected behavior

One of:

  • The ignored model doesn't cause db push to fail
  • prisma generate fails with helpful error message / VS code prisma extension shows an error
Prisma information
# .env
DATABASE_URL='file:.dev.db?connection_limit=1&socket_timeout=20&pool_timeout=20'
datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
Environment & setup
  • Ubuntu 20.04.2
  • Prisma v3.6.0
  • Node v16.3.0
Prisma Version
Environment variables loaded from .env
prisma                  : 3.6.0
@prisma/client          : 3.6.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio                  : 0.440.0
Dominant language
TypeScript
Stars
47.6k
Forks
2.5k
Avg merge
21h 59m
Merged PRs (30d)
95

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/orm

All issues in prisma/orm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.