File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,4 +63,4 @@ public virtual void AfterDown()
6363 public virtual void InitializeOnce ( string [ ] args )
6464 {
6565 }
66- }
66+ }
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 ;
5+ using DotNetProjects . Migrator . Providers . Impl . SQLite ;
66
77namespace DotNetProjects . Migrator ;
88
@@ -63,13 +63,22 @@ public override bool Continue(long version)
6363
6464 public override void Migrate ( IMigration migration )
6565 {
66- _provider . BeginTransaction ( ) ;
6766#if NETSTANDARD
6867 var attr = migration . GetType ( ) . GetTypeInfo ( ) . GetCustomAttribute < MigrationAttribute > ( ) ;
6968#else
7069 var attr = ( MigrationAttribute ) Attribute . GetCustomAttribute ( migration . GetType ( ) , typeof ( MigrationAttribute ) ) ;
71- #endif
72-
70+ #endif
71+ var foreignKeysWasOn = false ;
72+ if ( _provider is SQLiteTransformationProvider sqlite )
73+ {
74+ foreignKeysWasOn = sqlite . IsPragmaForeignKeysOn ( ) ;
75+ if ( foreignKeysWasOn )
76+ {
77+ sqlite . SetPragmaForeignKeys ( false ) ;
78+ }
79+ }
80+
81+ _provider . BeginTransaction ( ) ;
7382
7483 if ( _provider . AppliedMigrations . Contains ( attr . Version ) )
7584 {
@@ -78,6 +87,11 @@ public override void Migrate(IMigration migration)
7887 else
7988 {
8089 ApplyMigration ( migration , attr ) ;
90+ }
91+
92+ if ( foreignKeysWasOn && _provider is SQLiteTransformationProvider sqlite2 )
93+ {
94+ sqlite2 . SetPragmaForeignKeys ( true ) ;
8195 }
8296 }
8397
You can’t perform that action at this time.
0 commit comments