Migrate: Migrate can't create new database

Created on 28 Jan 2020  路  3Comments  路  Source: prisma/migrate

Creating a new database with

yarn prisma2 migrate save --create-db --name init --experimental
yarn prisma2 migrate up --experimental

using the schema

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// The `datasource` block is used to specify the connection to your DB.
// Set the `provider` field to match your DB type: "postgresql", "mysql" or "sqlite".
// The `url` field must contain the connection string to your DB.
// Learn more about connection strings for your DB: https://pris.ly/connection-strings
datasource db {
  provider = "sqlite" // other options are: "mysql" and "sqlite"
  url      = "sqlite:./dev.db"
}
// Other examples for connection strings are:
// SQLite: url = "sqlite:./dev.db"
// MySQL:  url = "mysql://johndoe:johndoe@localhost:3306/mydb"
// You can also use environment variables to specify the connection string: https://pris.ly/prisma-schema#using-environment-variables

// By adding the `generator` block, you specify that you want to generate Prisma's DB client.
// The client is generated by runnning the `prisma generate` command and will be located in `node_modules/@prisma` and can be imported in your code as:
// import { PrismaClient } from '@prisma/client'
generator client {
  provider = "prisma-client-js"
}

// Next steps:
// 1. Add your DB connection string as the `url` of the `datasource` block
// 2. Run `prisma2 introspect` to get your data model into the schema (this will override this file and delete all comments!)
// 3. Run `prisma2 generate` to generate Prisma Client JS
// 4. Start using Prisma Client JS in your application

model User {
    id    String  @default(cuid()) @id
    email String  @unique
    name  String?
}

results in

Failure during a migration command: Generic error. (error: The datasource db already exists in this Schema. It is not possible to create it once more.)

using the latest alpha ([email protected], binary version: 321a958cfb891344dca5b7948c030e7273835565).

Most helpful comment

All 3 comments

It works fine in the latest stable version preview020.3:
image

But it was broken in alpha, @tomhoule has fixed it

Fixed in [email protected], binary version: c2994e6e2511c80d995a5756a92ee9c12df808a5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julien1619 picture julien1619  路  4Comments

sameoldmadness picture sameoldmadness  路  4Comments

RafaelKr picture RafaelKr  路  3Comments

chanphiromsok picture chanphiromsok  路  3Comments

jwld picture jwld  路  3Comments