File tree 2 files changed +46
-0
lines changed
Persistence/Migrations/Upgrades/TargetVersionSevenTwoZero 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Linq ;
2
+ using Umbraco . Core . Configuration ;
3
+ using Umbraco . Core . Persistence . DatabaseModelDefinitions ;
4
+ using Umbraco . Core . Persistence . SqlSyntax ;
5
+
6
+ namespace Umbraco . Core . Persistence . Migrations . Upgrades . TargetVersionSevenTwoZero
7
+ {
8
+ [ Migration ( "7.2.0" , 3 , GlobalSettings . UmbracoMigrationName ) ]
9
+ public class AddIndexToUmbracoNodeTable : MigrationBase
10
+ {
11
+ private readonly bool _skipIndexCheck ;
12
+
13
+ internal AddIndexToUmbracoNodeTable ( bool skipIndexCheck )
14
+ {
15
+ _skipIndexCheck = skipIndexCheck ;
16
+ }
17
+
18
+ public AddIndexToUmbracoNodeTable ( )
19
+ {
20
+ }
21
+
22
+ public override void Up ( )
23
+ {
24
+ var dbIndexes = _skipIndexCheck ? new DbIndexDefinition [ ] { } : SqlSyntaxContext . SqlSyntaxProvider . GetDefinedIndexes ( Context . Database )
25
+ . Select ( x => new DbIndexDefinition
26
+ {
27
+ TableName = x . Item1 ,
28
+ IndexName = x . Item2 ,
29
+ ColumnName = x . Item3 ,
30
+ IsUnique = x . Item4
31
+ } ) . ToArray ( ) ;
32
+
33
+ //make sure it doesn't already exist
34
+ if ( dbIndexes . Any ( x => x . IndexName . InvariantEquals ( "IX_umbracoNodeUniqueID" ) ) == false )
35
+ {
36
+ Create . Index ( "IX_umbracoNodeUniqueID" ) . OnTable ( "umbracoNode" ) . OnColumn ( "uniqueID" ) . Unique ( ) ;
37
+ }
38
+ }
39
+
40
+ public override void Down ( )
41
+ {
42
+ Delete . Index ( "IX_umbracoNodeUniqueID" ) . OnTable ( "umbracoNode" ) ;
43
+ }
44
+ }
45
+ }
Original file line number Diff line number Diff line change 393
393
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AddMissingForeignKeyForContentType.cs" />
394
394
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AlterDataTypePreValueTable.cs" />
395
395
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSevenOneZero\AssignMissingPrimaryForMySqlKeys.cs" />
396
+ <Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AddIndexToUmbracoNodeTable.cs" />
396
397
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\RemoveCmsDocumentAliasColumn.cs" />
397
398
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSeven\AssignMissingKeysAndIndexes.cs" />
398
399
<Compile Include =" Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AssignMissingPrimaryForMySqlKeys.cs" />
You can’t perform that action at this time.
0 commit comments