Migrate: SQLite: unexpected db schema created

Created on 23 Oct 2019  路  7Comments  路  Source: prisma/migrate

When I'm creating migrations for my model(_schema.prisma)_ :

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  enabled  = true
}

model User {
  id        Int      @id
  createdAt DateTime @default(now())
  email     String   @unique
  name      String?
  role      Role     @default(USER)
  posts     Post[]
  profile   Profile?
}

I get this sql as the migration script

CREATE TABLE "lift"."User" (
  "createdAt" DATE NOT NULL DEFAULT '1970-01-01 00:00:00'  ,
  "email" TEXT NOT NULL DEFAULT ''  ,
  "id" INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT ,
  "name" TEXT    ,
  "role" TEXT NOT NULL DEFAULT 'USER'  
);

Here, _lift_ schema is created in my database which is unexpected. Is there a way to avoid this, or configure it?

bu2-confirmed kinbug tecengines

Most helpful comment

I am not sure that this is a thing that we should fix as this only affects the README. This occurs only on SQLite because the driver requires you to attach files you want to use like this: ATTACH [/path/to/file] AS [schema]. In our case we hardcode the schema name to be always lift. It is a completely transient thing that is only used internally. It would require really awkward hacks to work around this.

All 7 comments

Ok, I managed to reproduce this:

  1. Create a new folder as the project
  2. Create prisma/schema.prisma inside with content:
    ```
    datasource db {
    provider = "sqlite"
    url = "file:dev.db"
    enabled = true
    }
model User {
  id        Int      @id
  createdAt DateTime @default(now())
  email     String   @unique
  name      String?
}
```

  1. Run prisma migrate up
  2. Look at README.md in the migration folder that was created

If you run prisma migrate up with the generated mirgation, it just creates the User table as it should - so I think this is a display problem in the README.md.

Does this match your observations @insanebaba?
Or did something actually break for you in other ways besides the displayed SQL queries?

Yes, That's right. Thank you

Thanks @insanebaba, this is actually a real bug in our code that should be fixed then.

I am not sure that this is a thing that we should fix as this only affects the README. This occurs only on SQLite because the driver requires you to attach files you want to use like this: ATTACH [/path/to/file] AS [schema]. In our case we hardcode the schema name to be always lift. It is a completely transient thing that is only used internally. It would require really awkward hacks to work around this.

internal note: Dropping for this sprint. Bring it up in a later sprint.

"quaint" prefix is used in the latest version instead of "lift" but yeah this still exists:
image

Version: @prisma/cli : 2.0.0-alpha.1244

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chanphiromsok picture chanphiromsok  路  3Comments

janpio picture janpio  路  3Comments

marcjulian picture marcjulian  路  4Comments

nickreynke picture nickreynke  路  4Comments

agryaznov picture agryaznov  路  3Comments