11using System ;
22using System . IO ;
33using DbUp . Helpers ;
4-
5- #if MONO
6- using SQLiteConnection = Mono . Data . Sqlite . SqliteConnection ;
7- using SQLiteConnectionStringBuilder = Mono . Data . Sqlite . SqliteConnectionStringBuilder ;
8- using SQLiteJournalModeEnum = Mono . Data . Sqlite . SQLiteJournalModeEnum ;
9- #elif NETCORE
10- using SQLiteConnection = Microsoft . Data . Sqlite . SqliteConnection ;
11- using SQLiteConnectionStringBuilder = Microsoft . Data . Sqlite . SqliteConnectionStringBuilder ;
12- #else
13- using System . Data . SQLite ;
14- #endif
4+ using Microsoft . Data . Sqlite ;
155
166namespace DbUp . SQLite . Helpers
177{
@@ -21,7 +11,7 @@ namespace DbUp.SQLite.Helpers
2111 public class TemporarySQLiteDatabase : IDisposable
2212 {
2313 readonly string dataSourcePath ;
24- readonly SQLiteConnection sqLiteConnection ;
14+ readonly SqliteConnection sqLiteConnection ;
2515
2616 /// <summary>
2717 /// Initializes a new instance of the <see cref="TemporarySQLiteDatabase"/> class.
@@ -31,22 +21,12 @@ public TemporarySQLiteDatabase(string name)
3121 {
3222 dataSourcePath = Path . Combine ( Directory . GetCurrentDirectory ( ) , name ) ;
3323
34- var connectionStringBuilder = new SQLiteConnectionStringBuilder
24+ var connectionStringBuilder = new SqliteConnectionStringBuilder
3525 {
3626 DataSource = name ,
37- #if ! NETCORE
38- Version = 3 ,
39- DefaultTimeout = 5 ,
40- #if MONO
41- JournalMode = SQLiteJournalModeEnum . Off ,
42- #else
43- JournalMode = SQLiteJournalModeEnum . Memory ,
44- #endif
45- UseUTF16Encoding = true
46- #endif
4727 } ;
4828
49- sqLiteConnection = new SQLiteConnection ( connectionStringBuilder . ConnectionString ) ;
29+ sqLiteConnection = new SqliteConnection ( connectionStringBuilder . ConnectionString ) ;
5030 sqLiteConnection . Open ( ) ;
5131 SharedConnection = new SharedConnection ( sqLiteConnection ) ;
5232 SqlRunner = new AdHocSqlRunner ( ( ) => sqLiteConnection . CreateCommand ( ) , new SQLiteObjectParser ( ) , null , ( ) => true ) ;
@@ -59,20 +39,6 @@ public TemporarySQLiteDatabase(string name)
5939
6040 public SharedConnection SharedConnection { get ; }
6141
62- /// <summary>
63- /// Creates the database.
64- /// </summary>
65- public void Create ( )
66- {
67- #if ! NETCORE
68- var filePath = new FileInfo ( dataSourcePath ) ;
69- if ( ! filePath . Exists )
70- {
71- SQLiteConnection . CreateFile ( dataSourcePath ) ;
72- }
73- #endif
74- }
75-
7642 /// <summary>
7743 /// Deletes the database.
7844 /// </summary>
@@ -82,14 +48,6 @@ public void Dispose()
8248 if ( ! filePath . Exists ) return ;
8349 SharedConnection . Dispose ( ) ;
8450 sqLiteConnection . Dispose ( ) ;
85- #if ! NETCORE
86- SQLiteConnection . ClearAllPools ( ) ;
87-
88- // SQLite requires all created sql connection/command objects to be disposed
89- // in order to delete the database file
90- GC . Collect ( 2 , GCCollectionMode . Forced ) ;
91- System . Threading . Thread . Sleep ( 100 ) ;
92- #endif
9351 File . Delete ( dataSourcePath ) ;
9452 }
9553 }
0 commit comments