这是我的架构:
diesel::table! {
account (organization_id) {
#[max_length = 255]
organization_id -> Varchar,
#[max_length = 255]
name -> Varchar,
#[max_length = 255]
description -> Varchar,
account_was_verified -> Bool,
#[max_length = 255]
username -> Varchar,
#[max_length = 255]
password_hash -> Varchar,
}
}
我希望用户名属性在创建表时是唯一的(即生成迁移时具有唯一约束)。可以这样做吗?
不支持此功能。
Diesel 架构定义不是用于配置数据库表的一站式服务。在许多情况下,您需要手动调整柴油自动生成的迁移;这是其中之一。