Prisma1: Prisma Creating New Database in MongoDB

Created on 10 May 2019  路  4Comments  路  Source: prisma/prisma1

Describe the bug
Not sure if it's a bug but also don't understand why it's happening. I've got Prisma connected to my MongoDB but when I make any mutations, a new database is being created in MongoDB called default_default and data is being added there instead of the database I specified when going through the setup here

https://www.prisma.io/docs/get-started/01-setting-up-prisma-existing-database-JAVASCRIPT-a003/

Here is my docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            uri: 'mongodb://host.docker.internal:27017/name-of-db'

To Reproduce
Steps to reproduce the behavior:

  1. Go through process for setting up Prisma w/ existing db https://www.prisma.io/docs/get-started/01-setting-up-prisma-existing-database-JAVASCRIPT-a003/
  2. Try and add data via playground

Expected behavior
Expect data would be added to the db specified in docker-compose.yml

bu0-needs-info statustale areconnectomongo kinbug

All 4 comments

On the docker-compose file, you set up the Prisma container as follows:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            uri: 'mongodb://host.docker.internal:27017/admin'

You need to specify the database to use on the endpoint property of your prisma.yml file.

datamodel: database.prisma
endpoint: http://localhost:4466/app/alpha
databaseType: document

If you deploy to the endpoint above, Prisma will create the database: app_alpha. If you don't specify the path, the default database name is default_default

You will need to provide database in the config like so:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            database: name-of-db
            connector: mongo
            uri: 'mongodb://host.docker.internal:27017/name-of-db'

uri: 'mongodb://host.docker.internal:27017/admin'
note: 'host.docker.internal' is only useful for mac

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ragnorc picture ragnorc  路  3Comments

akoenig picture akoenig  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

marktani picture marktani  路  3Comments

marktani picture marktani  路  3Comments