Skip to content

Commit 831c7ee

Browse files
JaBistDuNarrischJaBistDuNarrisch
authored andcommitted
SQLite Unique index
1 parent d25394e commit 831c7ee

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/Migrator/Providers/Impl/SQLite/SQLiteTransformationProvider.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,12 +1198,9 @@ public override Index[] GetIndexes(string table)
11981198

11991199
var pragmaIndexListItems = GetPragmaIndexListItems(table);
12001200

1201-
// Since unique indexes are supported but only by using unique constraints or primary keys we filter them out here. See "GetUniques()" for unique constraints.
1202-
var pragmaIndexListItemsFiltered = pragmaIndexListItems.Where(x => !x.Unique).ToList();
1203-
1204-
foreach (var pragmaIndexListItemFiltered in pragmaIndexListItemsFiltered)
1201+
foreach (var pragmaIndexListItem in pragmaIndexListItems)
12051202
{
1206-
var indexInfos = GetPragmaIndexInfo(pragmaIndexListItemFiltered.Name);
1203+
var indexInfos = GetPragmaIndexInfo(pragmaIndexListItem.Name);
12071204

12081205
var columnNames = indexInfos.OrderBy(x => x.SeqNo)
12091206
.Select(x => x.Name)
@@ -1218,10 +1215,8 @@ public override Index[] GetIndexes(string table)
12181215
// SQLite does not support include colums
12191216
IncludeColumns = [],
12201217
KeyColumns = columnNames,
1221-
Name = pragmaIndexListItemFiltered.Name,
1222-
1223-
// See GetUniques()
1224-
Unique = false,
1218+
Name = pragmaIndexListItem.Name,
1219+
Unique = pragmaIndexListItem.Origin == "c"
12251220
};
12261221

12271222
indexes.Add(index);
@@ -1419,8 +1414,7 @@ public List<Unique> GetUniques(string tableName)
14191414

14201415
// Here we filter for origin u and unique while in "GetIndexes()" we exclude them.
14211416
// If "pk" is set then it was added by using a primary key. If so this is handled by "GetColumns()".
1422-
// If "c" is set it was created by using CREATE INDEX. At this moment in time this migrator does not support UNIQUE indexes but only normal indexes
1423-
// so "u" should never be set 30.06.2025).
1417+
// If "c" is set it was created by using CREATE INDEX.
14241418
var uniqueConstraints = pragmaIndexListItems.Where(x => x.Unique && x.Origin == "u")
14251419
.ToList();
14261420

0 commit comments

Comments
 (0)