Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
93 stars 13 forks source link

Set columm as unique #5

Closed ieow closed 3 years ago

ieow commented 3 years ago

How to se the column as unique? Is there a field such as #[unique] (as same as #[pk]) to define the column as unique data?

Electron100 commented 3 years ago

At the moment, the only way to set a unique constraint on a column would be to manually edit the migration sql after it's generated. It should be fairly straightforward to add a #[unique] field attribute though. Let me see if I can take a stab at that tonight.

ieow commented 3 years ago

Thanks for the workaround! Thanks also for considering to implement #[unique] feature !!

Electron100 commented 3 years ago

Took a couple days before I found the time I'm afraid, but I've just published 0.3.1 with #[unique]. Let me know if you see any issues!

Electron100 commented 3 years ago

Closing, as this is implemented in 0.3.1 and I haven't heard any feedback. Feel free to reopen if you see issues.

ieow commented 3 years ago

Just tried it with 0.3.1. It works great!