dvStudioIndexesOf function
Every index spec asks for: each unique field on its own, then its
declared indexes. Named for the table and fields, so asking twice is
asking for the same index.
Implementation
List<({String name, List<String> fields, bool unique})> dvStudioIndexesOf(
DVStudioModelSpec spec,
) =>
<({String name, List<String> fields, bool unique})>[
for (final DVStudioFieldSpec field in spec.fields)
if (field.unique && field.name != spec.key)
(
name: '${spec.table}_${field.name}_unique',
fields: <String>[field.name],
unique: true,
),
for (final DVStudioIndexSpec index in spec.indexes)
(
name: '${spec.table}_${index.fields.join('_')}_${index.unique ? 'unique' : 'idx'}',
fields: index.fields,
unique: index.unique,
),
];