Hi! I’ve upgraded from P1 to 3.0.2 and I’m having ...
# orm-help
f
Hi! I’ve upgraded from P1 to 3.0.2 and I’m having problems with n-m relations. I had a few
@relationTable
in P1 and I have renamed all of them in DB (PG9) to follow P2 conventions for implicit n-m relations. However, it now throws with these tables something like
The column _AddressBook.B does not exist in the current database.
at run time. And same happens when trying
db push
command:
Added the required column B to the _AddressBook table without a default value
. Any ideas? The table looks like this:
r
@Fran Dios 👋 I don’t think
db push
is the correct command in this case. You would need to run
prisma db pull
to get the changes.
f
@Ryan Hey! I did
db pull
so my
model AddressBook
disappeared since now it is considered to be an implicit relationship. However, these errors keep happening. If I try
db pull
again it doesn’t change anything else, but
db push
fails with that issue I mentioned.
r
Implicit relationships don’t appear by default in the schema. Also
db push
is for prototyping. What you would ideally work with is Migrate.
f
@Ryan Yes I understand implicit relationships don’t appear in the schema, and that’s right. What I’m saying is that Prisma CLI recognized that a relationship was made implicit (it removed it from the schema) but I still cannot use the Prisma Client because it throws on this relationship (
The column _AddressBook.B does not exist in the current database
<-- but it actually does exist). And it seems to be a deadlock:
db pull
does not make any change to my schema anymore but the client doesn’t work. And when trying
db push
to make sure the DB and Schema are in sync, it tells me that I need to wipe all DB data because a new column “A” was added 🤷 I don’t think Migrate would make any difference here, right?
r
db push
is just for prototyping in development and is not mentioned in our Upgrade Guide as a process.
f
Hey @Ryan so I figured out my problem: I renamed the tables to follow Prisma convention in Postgres doing this:
Copy code
alter table blackship$dev."AddressBook" rename column "address" to A;
The problem here is that I wass missing double quotes on the column name so Postgres was renaming it to
a
instead of
A
🤦 This makes it happy again:
Copy code
alter table blackship$dev."AddressBook" rename column "address" to "A";
💯 1
I didn’t use Prisma Migrate at the end but thanks for the help anyway!
👍 1