Open KAction opened 1 year ago
If I'm not mistaken, it seems there's already a unique index on value(name)
: https://github.com/oniony/TMSU/blob/0bf4b8031cbeffc0347007d85647062953e90571/storage/database/schema.go#L186
However, a unique index on tag(name)
would be very useful IMHO too.
Hello.
Other day I was working on some script that would add/remove tags automatically based on complicated, non-general-utility logic, and I figured that it will be easier to work with database directly.
I really appreciate the choice of sqlite3 as data storage instead of some language-specific binary format. One
.schema
command, and I knew exactly what I need to do.One thing that surprised me is that
tmsu
database has no unique indexes, so if I want knowid
of the tag, creating it if necessary, I have to do it using multiple queries:Should table had unique index, the same could have been done atomically and much easier:
Additionally, unique index would be extra protection against logic errors that may introduce duplicate tags/value/files. Would you be interested if I make pull request that creates unique indexes, like following: