Closed boojack closed 2 years ago
Having the same issue here.
I can create a new model, link and sync it to the database without issues.
If I restart my deno app, it will once again link and sync, but will fail when syncing since it's just trying to recreate my (already present) model in the database.
This is my first time using denodb, so I might be overlooking something here, I'm not sure. Documentation doesn't mention anything about adding fields to models.
I'm a Laravel developer used to database migrations, so not sure how this is handled here.
Looks like no response ;)
Pretty weird IMO to close an issue and mark it as completed simply because there's no response to it.
Not getting a response to something does not equal the problem no longer existing. I would leave this open until actually resolved.
I'm having this issue as well. It would be nice to simply call db.sync()
unconditionally, and let the library determine which model tables need to be created, and ignore any that already exist or even better, check the existing ones for changes to the schema and synchronize those changes as well!
Or, if this is working as intended, it should be mentioned in the docs, that db.sync()
is only meant to be called from a one-time set up script, and any further changes need to be done via migration scripts.
The current code:
But if I delete the
await Note.drop(); await User.drop();
, the problem will throw errorError: Multiple primary key defined
.It looks like that I have to empty the database before connect to MySQL. It's really not nice :( How can I do this?