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

Deno db is not able to crate the relationship between tables if they are already exist. #270

Open
shreyasrkulkarni opened this issue Jun 7, 2021 · 4 comments

Comments

@shreyasrkulkarni
Copy link

I am using My SQL db with denodb and I am having an issue while creating one to many relationship in 2 tables. Deno db actually trying to create new foreign key even if its already present. I can not set await db.sync({drop: true}) because it is dropping my table and recreating it by mapping the model objects that I have created. Please help me with this issue.
Use case :-
My db contains 2 tables User and Moods . And one to many relationship is User has many Moods. (Or you can take another name as an example User has many Addresses). I already have the data in both the table and one foreign key in Moods table as "user_id".

@LiamKarlMitchell
Copy link

Confirming DenoDB v1.0.38 keeps trying to re-create the DB table on sync call.
But it already exists in the DB and has foreign key relationship set up.

MySQL but connecting to MariaDB.

Relationships.belongsTo(Example, OtherThing);
await db.link([Example, OtherThing]);
await db.sync();
error: Uncaught (in promise) Error: Can't create table `xyz`.`example` (errno: 121 "Duplicate key on write or update")

@LoganTann
Copy link

Very similar issue is happening with SQLite in #283

I got similar error at #349, still not fixed as of today.

Is the maintainer of this repo still active ?

@LiamKarlMitchell
Copy link

I switched over to using postgresql through https://deno.land/x/[email protected] nessie for migrations and writing my queries manually with my own classes... but there is almost no docs for anything, no examples, the guides I find don't match laravel like at all as the schema builder was removed or something, and the DB doesn't have support for defining custom data type parser/serializer or propper docs either. Deno DB solutions seem like they have a long way to go to reach maturity I guess.../rant.

Anyone know if recent advantages allow for using Node.js ORM's and drivers in Deno?

@nodgear
Copy link

nodgear commented Jul 2, 2022

+1
This still happens on v1.0.40

This makes ddb impossible to use since dropping the whole table every time the server restarts is far from ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants