File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3- using System . Reflection ;
43using DotNetProjects . Migrator . Framework ;
54using DotNetProjects . Migrator . Providers ;
65using DotNetProjects . Migrator . Providers . Impl . SQLite ;
@@ -68,10 +67,15 @@ public override void Migrate(IMigration migration)
6867 var attr = migration . GetType ( ) . GetTypeInfo ( ) . GetCustomAttribute < MigrationAttribute > ( ) ;
6968#else
7069 var attr = ( MigrationAttribute ) Attribute . GetCustomAttribute ( migration . GetType ( ) , typeof ( MigrationAttribute ) ) ;
71- #endif
70+ #endif
71+ var foreignKeysWasOn = false ;
7272 if ( attr . DisableForeignKeysInSqlite && _provider is SQLiteTransformationProvider sqlite )
7373 {
74- sqlite . SetPragmaForeignKeys ( false ) ;
74+ foreignKeysWasOn = sqlite . IsPragmaForeignKeysOn ( ) ;
75+ if ( foreignKeysWasOn )
76+ {
77+ sqlite . SetPragmaForeignKeys ( false ) ;
78+ }
7579 }
7680
7781 _provider . BeginTransaction ( ) ;
@@ -85,7 +89,7 @@ public override void Migrate(IMigration migration)
8589 ApplyMigration ( migration , attr ) ;
8690 }
8791
88- if ( attr . DisableForeignKeysInSqlite && _provider is SQLiteTransformationProvider sqlite2 )
92+ if ( foreignKeysWasOn && _provider is SQLiteTransformationProvider sqlite2 )
8993 {
9094 sqlite2 . SetPragmaForeignKeys ( true ) ;
9195 }
You can’t perform that action at this time.
0 commit comments