Skip to content

Conversation

@amotl
Copy link
Member

@amotl amotl commented Dec 6, 2023

About

Verify Prisma works well with CrateDB.

Details

The code has been scaffolded like this:

npx try-prisma@latest --template javascript/script --install npm --name . --path .

Thoughts

Two pointers shared by @BaurzhanSakhariev. Thanks!

/cc @proddata, @hammerhead, @hlcianfagna, @simonprickett, @kneth

Comment on lines 22 to 30
### Create the database

Run the following command to submit the SQL DDL to the database. This will create
database tables for the `User` and `Post` entities that are defined in
[`prisma/schema.prisma`](./prisma/schema.prisma).
```shell
npx prisma migrate dev --name init
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prisma wants to run a CREATE SCHEMA command when using a connection string like postgresql://crate@localhost:5432/mydb?schema=public.

$ npx prisma migrate dev --name init
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "mydb", schema "public" at "localhost:5432"

Error: Schema engine error:
ERROR: line 1:8: no viable alternative at input 'CREATE SCHEMA'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using postgresql://crate@localhost:5432/?schema=doc as database connection string, it trips on the CREATE DATABASE statement.

Error: P3014

Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow

Original error:
ERROR: line 1:8: no viable alternative at input 'CREATE DATABASE'
   0: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:270

Copy link
Contributor

@hlcianfagna hlcianfagna Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this mechanism can be used to make CrateDB work, so that Prisma is no longer failing right away on migrate dev?

In some cases it might make sense (e.g. when creating and dropping databases is not allowed on cloud-hosted databases) to manually define the connection string and name of the database that should be used as the shadow database for migrate dev.

-- https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database#manually-configuring-the-shadow-database

@amotl

This comment was marked as duplicate.

amotl added 4 commits December 4, 2025 15:43
The code has been scaffolded like this:

  npx try-prisma@latest --template javascript/script --install npm --name . --path .

This commit adds the result unmodified.
@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch amo/prisma

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kneth
Copy link
Member

kneth commented Dec 9, 2025

Support for CREATE SCHEMA was merged recently and we might need to wait for CrateDB 6.2 to be released before finalizing this example.

@amotl
Copy link
Member Author

amotl commented Dec 21, 2025

Thanks. We may need to look into the CREATE DATABASE obstacle, see above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants