()
| 69 | } |
| 70 | |
| 71 | func (APIToken) Indexes() []ent.Index { |
| 72 | return []ent.Index{ |
| 73 | // names are unique within a organization and affects only to non-deleted items |
| 74 | // These are for org level tokens |
| 75 | index.Fields("name").Edges("organization").Unique().Annotations( |
| 76 | entsql.IndexWhere("revoked_at IS NULL AND project_id IS NULL"), |
| 77 | ), |
| 78 | |
| 79 | // for project level tokens, we scope the uniqueness to the organization and project |
| 80 | index.Fields("name").Edges("project").Unique().Annotations( |
| 81 | entsql.IndexWhere("revoked_at IS NULL AND project_id IS NOT NULL"), |
| 82 | ), |
| 83 | |
| 84 | // for instance-level tokens, names must be unique across all instance tokens |
| 85 | index.Fields("name").Unique().Annotations( |
| 86 | entsql.IndexWhere("revoked_at IS NULL AND organization_id IS NULL"), |
| 87 | ), |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected