Hi everyone, I’m pretty much lost on the upgrade a...
# prisma1-community
m
Hi everyone, I’m pretty much lost on the upgrade and don’t know where to start anymore, any help would be appreciated. Even an RTFM pointing to the right doc would be appreciated because I’m lacking the confidence I’m reading the correct one and investing the time in the right place. So here’s the situation. I have a project I started in mid-2019. I then decided to use Prisma, Apollo and GraphQL with a MySQL db. Below an excerpt of my package.json:
Copy code
"dependencies": {
		"bcryptjs": "^2.4.3",
		"dotenv": "^6.0.0",
		"graphql": "14.4.2",
		"graphql-yoga": "1.18.0",
		"jsonwebtoken": "^8.3.0",
		"prisma": "^1.18.1",
		"prisma-binding": "^2.1.4"
	}
It was deployed in prod with a bit of data, but I paused the project end of 2019 and I lost access to the account… So that’s gone. It was running locally but in the meantime, I changed computer (new mac M1) so I don’t have a local DB already there. Now I tried naively following the docs but: 1. I’m struggling to find the correct endpoints to set up for different reasons. a) I didn’t document enough it seems so I’m lost between yml and env files and b) I understood I needed an arm patch which seems to modify a bit the setup 2. I am definitely stuck at the
npx prisma db pull
step. I tried running
npx prisma db pull --schema=./src/generated/prisma.graphql
instead and this gives me validation errors. Which sends me on a sort of loop of documentation, because to validate it needs to run, to run I need to upgrade Maybe I didn’t try hard enough to run Prisma1 to begin with, but what set me off on the path to directly upgrade was that I understood I needed a new docker-compose.yml set-up. I have no shame to say I am very confused 😅 I haven’t touched all this in 3y and at the time I sort of rushed the project in a few months on the side, I don’t do backend so often and my memory is bad. I documented my code, but I did not document well enough to handle this kind of issues 😄 I’m willing to invest the time to re-up the project though! The last thing I was trying was to manually edit the prisma.graphql file, but I don’t really have the dictionary to translate since the doc assumes the bulk of it got translated by the db pull command. Pls send help prismo gif
n
Hey Maxime 👋 I’ll try to help you but have a couple of comments and clarifying questions 😄 What’s the status of the project at the moment? Is the GraphQL API still running in production somewhere? Is your MySQL still running somewhere?
I lost access to the account
Which account are you talking about?
I’m struggling to find the correct endpoints to set up for different reasons.
What kind of endpoints are you talking about here?
I have no shame to say I am very confused 😅
That’s very understandable btw, Prisma has changed a lot since you’ve worked with it so I’ll try to help you piece things together again 🙏 Also, what exactly are you trying to do? Do you just want to make the current set up work or actually upgrade to the new Prisma ORM? You’ve probably seen this, but here’s the upgrade documentation from Prisma 1 to Prisma 2: https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/how-to-upgrade
m
Hi @nikolasburk! Thanks for the reply 🙂 Sorry for the lack of precision, there was a lot to unpack I think the most important question is probably the last one, so I’ll start with that
Also, what exactly are you trying to do? Do you just want to make the current set up work or actually upgrade to the new Prisma ORM?
At the very least I want to put by app back online. At best, I want to be able to continue working and developing the project further, for which I’m ready to upgrade if that makes things easier
Which account are you talking about?
That referred to the heroku account where I had the server and DB. I just tried connecting to prisma cloud (I remember having a free account) but that forces me to connect my github, then my repo, then my heroku account (I gave up right about there) before I can even see if there’s anything there to recover. Edit: I went through with the onboarding on cloud.prisma but I couldn’t see any older project there
What’s the status of the project at the moment? Is the GraphQL API still running in production somewhere? Is your MySQL still running somewhere?
At the moment it is not running anymore (see above) and I can’t seem to be able to run it locally. Although I’ll try that a bit harder (with prisma 1) as my next step I think. Edit: I think I actually had some part of it (the graphql API) hosted at Now.sh. But that platform is now “vercel.com” and I just checked, although my builds are still “ready”, when I visit their new URL they give me a 404 (eg. karma-server.now.sh). Edit2: In the build that was once live on Now.sh, my graphql config my app/extensions/endpoints/default points to an herokuapp (account that I can’t access anymore). In all cases, pretty much everything is down at the moment is the easy way to explain it
What kind of endpoints are you talking about here?
This https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/upgrading-the-prisma-layer-mysql#3-determine-your-con[…]nect-to-your-database
Sorry the message went out too fast, it’s now edited and complete
@nikolasburk so I succeeded in running the project locally with Prisma 1 again. Database is working and all. But I really can’t figure out the DATABASE_URL value for the .env file. I’ve tried many combination but, so far, they all get me to:
Copy code
✖ Introspecting based on datasource defined in prisma/schema.prisma

Error: P1001

Can't reach database server at `localhost`:`3306`

Please make sure your database server is running at `localhost`:`3306`.
I tried switching to Postgres and now the equivalent error is:
Copy code
✖ Introspecting based on datasource defined in prisma/schema.prisma

Error: P1010

User `prisma` was denied access on the database `prisma.default$default`
So now I’m able to have my db run also with postgres, I can run
npx prisma1 deploy
and it all works (like with MySQL) but when I run db pull here’s what I get
Copy code
~/repos/server [local-update] >>> npx prisma db pull
Prisma schema loaded from prisma/schema.prisma
Environment variables loaded from .env
Datasource "db": PostgreSQL database "prisma", schema "default$default" at "localhost:5432"

✖ Introspecting based on datasource defined in prisma/schema.prisma
Error:
P4001 The introspected database was empty:

prisma db pull could not create any models in your schema.prisma file and you will not be able to generate Prisma Client with the prisma generate command.

To fix this, you have two options:

- manually create a table in your database.
- make sure the database connection URL inside the datasource block in schema.prisma points to a database that is not empty (it must contain at least one table).

Then you can run prisma db pull again.
And i can’t figure out how to get to the database correctly. It is existing somewhere but where? So still stuck with this URL issue. On top of that in the container, the db is having the following error:
Copy code
database-prisma-1    | {"key":"error/handled","requestId":"local:cl8oq5qri00240d13f9wpr36h","payload":{"exception":"com.prisma.deploy.schema.InvalidToken: Authentication token is invalid: 'Authorization' header not provided","query":"{\n        listProjects {\n          name\n        }\n      }","variables":"{}","code":"3015","stack_trace":"com.prisma.deploy.server.auth.SymmetricManagementAuth.$anonfun$verify$1(SymmetricManagementAuth.scala:17)\\n scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)\\n scala.util.Try$.apply(Try.scala:209)\\n com.prisma.deploy.server.auth.SymmetricManagementAuth.verify(SymmetricManagementAuth.scala:15)\\n com.prisma.deploy.schema.SchemaBuilderImpl.verifyAuthOrThrow(SchemaBuilder.scala:297)\\n com.prisma.deploy.schema.SchemaBuilderImpl.$anonfun$listProjectsField$1(SchemaBuilder.scala:107)\\n sangria.execution.Resolver.resolveField(Resolver.scala:1024)\\n sangria.execution.Resolver.$anonfun$collectActionsPar$1(Resolver.scala:445)\\n scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:156)\\n scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:156)\\n scala.collection.Iterator.foreach(Iterator.scala:937)\\n scala.collection.Iterator.foreach$(Iterator.scala:937)\\n scala.collection.AbstractIterator.foreach(Iterator.scala:1425)\\n scala.collection.IterableLike.foreach(IterableLike.scala:70)\\n scala.collection.IterableLike.foreach$(IterableLike.scala:69)\\n scala.collection.AbstractIterable.foreach(Iterable.scala:54)\\n scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:156)\\n scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:154)\\n scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)\\n sangria.execution.Resolver.collectActionsPar(Resolver.scala:439)\\n sangria.execution.Resolver.resolveFieldsPar(Resolver.scala:45)\\n sangria.execution.Executor.executeOperation(Executor.scala:155)\\n sangria.execution.Executor.$anonfun$execute$7(Executor.scala:97)\\n scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:303)\\n scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)\\n scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)\\n akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)\\n akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)\\n scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)\\n scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)\\n akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)\\n akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)\\n akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)\\n akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)\\n akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)\\n akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)\\n akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)","message":"Authentication token is invalid: 'Authorization' header not provided"}
FYI I understood there was not much to salvage, so I just rewrote/adapted my model by hand. There was more rewriting anyway since I had to migrate to apollo server and prisma client. Now onto trying to redeploy.