Adding a unique key to Drupal column I'm just doing a one-off script, but I'm wondering if there's a correct "Drupal way" to alter a table and a unique key.

For example, this is essentially the query I want to do:

ALTER IGNORE TABLE `node_revision` ADD UNIQUE(`hash`);


And then if I later wanted to remove the unique index on hash, how would I also do that?

Does it have something to do with updating the database schema? or possibly db_change_field()?
db_add_unique_key() is the function you're looking for.