Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lift up not applying migrations to fresh database, whilst prisma2 dev does? #1099

Closed
peterp opened this issue Dec 10, 2019 · 6 comments
Closed
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Milestone

Comments

@peterp
Copy link

peterp commented Dec 10, 2019

➜ yarn prisma2 -v
yarn run v1.19.1
$ /Users/peterp/Personal/hammer/create-hammer-app/node_modules/.bin/prisma2 -v
prisma2@2.0.0-preview018.1, binary version: bb7e89676c242c7fa4355fd09aa65ad2739c73cf
✨  Done in 0.44s.

Trying to apply the migration with yarn prisma2 lift up

➜ yarn prisma2 lift up
yarn run v1.19.1
$ /Users/peterp/Personal/hammer/create-hammer-app/node_modules/.bin/prisma2 lift up
🏋️‍ lift up

All migrations are already applied
✨  Done in 2.24s.

But the database is empty:

➜ sqlite3 prisma/dev.db
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> .tables
_Migration
sqlite> SELECT * FROM _Migration;
sqlite>
sqlite> ^C^C

➜ du -h prisma/dev.db
8.0K	prisma/dev.db

Running yarn prisma2 dev applies the migrations

~/Personal/hammer/create-hammer-app/api (master)
➜ du -h prisma/dev.db
 20K	prisma/dev.db

~/Personal/hammer/create-hammer-app/api (master)
➜ sqlite3 prisma/dev.db
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> .tables
User        _Migration
sqlite> SELECT * FROM _Migration
   ...> ;
1|watch-20191210135106|model User {
  id    Int    @id
  email String @unique
}|MigrationSuccess|1|0|[{"stepType":"CreateModel","model":"User"},{"stepType":"CreateField","model":"User","field":"id","type":"Int","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"id"},{"stepType":"CreateField","model":"User","field":"email","type":"String","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"email","directive":"unique"}]|{"before":{"tables":[{"name":"_Migration","columns":[{"name":"applied","tpe":{"raw":"INTEGER","family":"int"},"arity":"required","default":null,"autoIncrement":false},{"name":"database_migration","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false},{"name":"datamodel","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false},{"name":"datamodel_steps","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false},{"name":"errors","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false},{"name":"finished_at","tpe":{"raw":"DATE","family":"dateTime"},"arity":"nullable","default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false},{"name":"revision","tpe":{"raw":"INTEGER","family":"int"},"arity":"required","default":null,"autoIncrement":true},{"name":"rolled_back","tpe":{"raw":"INTEGER","family":"int"},"arity":"required","default":null,"autoIncrement":false},{"name":"started_at","tpe":{"raw":"DATE","family":"dateTime"},"arity":"required","default":null,"autoIncrement":false},{"name":"status","tpe":{"raw":"TEXT","family":"string"},"arity":"required","default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["revision"],"sequence":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"after":{"tables":[{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string"},"arity":"required","default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int"},"arity":"required","default":null,"autoIncrement":true}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"original_steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string"},"arity":"required","default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int"},"arity":"required","default":null,"autoIncrement":true}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}}],"corrected_steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string"},"arity":"required","default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int"},"arity":"required","default":null,"autoIncrement":true}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}}],"rollback":[{"DropIndex":{"table":"User","name":"User.email"}},{"DropTable":{"name":"User"}}]}|[]|1575978666805|1575978666812
sqlite>

A branch that reproduces this is available here: https://github.com/hammerframework/create-hammer-app/pull/new/pp-update-prisma-v18

@peterp peterp changed the title lift up not apply migrations to fresh database, whilst prisma2 dev does? lift up not applying migrations to fresh database, whilst prisma2 dev does? Dec 10, 2019
@steebchen
Copy link
Contributor

steebchen commented Dec 10, 2019

Hey @peterp, what OS are you using? prisma/migrate#241 seems related

@peterp
Copy link
Author

peterp commented Dec 11, 2019

@steebchen I'm on Mac OS.

@asciant
Copy link

asciant commented Dec 11, 2019

I had exactly the same issue on Mac OS, and running yarn prisma2 dev as @peterp noted made the migrations run as expected.

@tomhoule tomhoule self-assigned this Dec 11, 2019
@tomhoule
Copy link
Contributor

Found the bug, PR incoming!

@tomhoule
Copy link
Contributor

tomhoule commented Dec 11, 2019

PR: prisma/migrate#242

edit: there were more problems with the feature that introduced the bug, it was rolled back.

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. process/candidate labels Dec 11, 2019
@tomhoule
Copy link
Contributor

This is fixed in prisma2@2.0.0-preview018.2 🎉

@janpio janpio added this to the Preview 19 milestone Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

6 participants