@@ -139,12 +139,22 @@ let sqlRecords = [
139139
140140let props = tradesSingle.GetType() .GetProperties()
141141
142+ // Helper function to drop tables before creating them (handles schema changes)
143+ let dropTableIfExists tableName connectionString =
144+ connectionString
145+ |> Sql.connect
146+ |> Sql.query ( sprintf " DROP TABLE IF EXISTS %s " tableName)
147+ |> Sql.executeNonQuery
148+ |> ignore
149+
142150[<Tests>]
143151let tests =
144- testList " Fumble" [
152+ testSequenced <| testList " Fumble" [
145153 testList " Create and insert" [
146154 testDatabase " Create trade table"
147155 <| fun connectionStringMemory ->
156+ // Drop existing table to handle schema changes
157+ dropTableIfExists " Trades" connectionStringMemory
148158 connectionStringMemory
149159 |> Sql.connect
150160 |> Sql.commandCreate< TradeData> ( " Trades" )
@@ -156,6 +166,7 @@ let tests =
156166 fail ()
157167 testDatabase " Create status table with optional status"
158168 <| fun connectionStringMemory ->
169+ dropTableIfExists " Status" connectionStringMemory
159170 connectionStringMemory
160171 |> Sql.connect
161172 |> Sql.commandCreate< Status> ( " Status" )
@@ -167,6 +178,7 @@ let tests =
167178 fail ()
168179 testDatabase " Create sqlrecords table"
169180 <| fun connectionStringMemory ->
181+ dropTableIfExists " SqlRecords" connectionStringMemory
170182 connectionStringMemory
171183 |> Sql.connect
172184 |> Sql.commandCreate< SqlRecord> ( " SqlRecords" )
@@ -178,6 +190,7 @@ let tests =
178190 fail ()
179191 testDatabase " Create width table"
180192 <| fun connectionStringMemory ->
193+ dropTableIfExists " Width" connectionStringMemory
181194 connectionStringMemory
182195 |> Sql.connect
183196 |> Sql.commandCreate< Width> ( " Width" )
@@ -356,9 +369,10 @@ let tests =
356369 // New Feature Tests for v2.0
357370 // ============================================
358371
359- testList " New data types" [
372+ testSequenced <| testList " New data types" [
360373 testCase " Create table with new types"
361374 <| fun _ ->
375+ dropTableIfExists " NewTypes" connectionStringMemory
362376 connectionStringMemory
363377 |> Sql.connect
364378 |> Sql.commandCreate< NewTypesRecord> " NewTypes"
@@ -435,6 +449,7 @@ let tests =
435449 testList " executeScalar tests" [
436450 testCase " executeScalar returns count"
437451 <| fun _ ->
452+ // Use the persistent database - depends on earlier tests inserting data
438453 connectionStringMemory
439454 |> Sql.connect
440455 |> Sql.query " SELECT COUNT(*) FROM Trades"
0 commit comments