planetscale/database-js

Weird error with FKC

205g0 opened this issue · 5 comments

[thread moved to here https://github.com/planetscale/discussion/discussions/576 ]

Not sure if this is the right place for the new beta feature:

Once I try to add an FCK to the child table I get:

sqlMessage: `target: mydb: vttablet: rpc error: code = Unknown desc = Failed to add the foreign key constraint. Missing index for constraint 'random_name' in the referenced table 'parents' (errno 1822) (sqlstate HY000) (CallerID: 54qabz7uuc5afdasdfasdx): Sql: "alter table children add constraint random_name foreign key (parent_id) references parents.(id) on delete no action on update no action", BindVars: {REDACTED}

This is a common error with mysql on SO, so I made sure that really everything is considered and the command should have be executed. Also, the operation worked only once, then never again (after deleting and recreating that table with a new random FKC name). I also ensured that the FCK name is always a new one. So the command must have been right.

Weirder, once I go the error, in PlanetScales schema overview, the new children table shows up (without the FCK) BUT all other tables (around a dozen) loose their PRIMARY KEY. When I remove table children again, all other tables get the PRIMARY KEY back

@205g0 I don't think this has anything in particular to do with database-js, it seems best to write into support to ask this question, or drop a question over here: https://github.com/planetscale/discussion/discussions or in our Discord channel: https://discord.gg/EqrcEf2dGv

Yeah, I assumed this already. However, we need some place where we can talk about the beta and which is visible and frequented. Not sure if the Discord is frequented enough and it's def not visible for Google searches, so other people with similar experiences can join the convo. So, this repo is, while technically the wrong spot, not the worst place to talk about the beta.

Isn't there any other public space than Discord users can talk about the beta?

Thanks, didn't know, then I submit there linking to this issue...

For others driving by, pls go here => planetscale/discussion#576

closing...