Skip to content

Commit 2b98a40

Browse files
JaBistDuNarrischJaBistDuNarrisch
authored andcommitted
Update Oracle
1 parent 4201bc4 commit 2b98a40

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/Migrator.Tests/Database/DerivedDatabaseIntegrationTestServices/OracleDatabaseIntegrationTestService.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,27 @@ await Parallel.ForEachAsync(
114114

115115
});
116116

117-
// To be on the safe side we check for table spaces used in tests that have not been deleted for any reason (possible connection issues/concurrent deletion attempts - there is
118-
// no transaction for DDL in Oracle etc.).
119-
var tableSpaceNames = await context.GetTable<DBADataFiles>()
120-
.Select(x => x.TablespaceName)
121-
.ToListAsync(cancellationToken);
122-
123-
var toBeDeletedTableSpaces = tableSpaceNames
124-
.Where(x =>
125-
{
126-
var replacedTablespaceString = _tablespaceRegex.Replace(x, "");
127-
var creationDate = DatabaseNameService.ReadTimeStampFromString(replacedTablespaceString);
128-
return creationDate.HasValue && creationDate.Value < timeProvider.GetUtcNow().Subtract(_MinTimeSpanBeforeDatabaseDeletion);
129-
});
130-
131-
foreach (var toBeDeletedTableSpace in toBeDeletedTableSpaces)
132-
{
133-
await context.ExecuteAsync($"DROP TABLESPACE {toBeDeletedTableSpace} INCLUDING CONTENTS AND DATAFILES", cancellationToken);
134-
}
135-
136117
using (context = new DataConnection(dataOptions))
137118
{
119+
// To be on the safe side we check for table spaces used in tests that have not been deleted for any reason (possible connection issues/concurrent deletion attempts - there is
120+
// no transaction for DDL in Oracle etc.).
121+
var tableSpaceNames = await context.GetTable<DBADataFiles>()
122+
.Select(x => x.TablespaceName)
123+
.ToListAsync(cancellationToken);
124+
125+
var toBeDeletedTableSpaces = tableSpaceNames
126+
.Where(x =>
127+
{
128+
var replacedTablespaceString = _tablespaceRegex.Replace(x, "");
129+
var creationDate = DatabaseNameService.ReadTimeStampFromString(replacedTablespaceString);
130+
return creationDate.HasValue && creationDate.Value < timeProvider.GetUtcNow().Subtract(_MinTimeSpanBeforeDatabaseDeletion);
131+
});
132+
133+
foreach (var toBeDeletedTableSpace in toBeDeletedTableSpaces)
134+
{
135+
await context.ExecuteAsync($"DROP TABLESPACE {toBeDeletedTableSpace} INCLUDING CONTENTS AND DATAFILES", cancellationToken);
136+
}
137+
138138
await context.ExecuteAsync($"CREATE USER \"{tempUserName}\" IDENTIFIED BY \"{tempUserName}\"", cancellationToken);
139139

140140
var privileges = new[]
@@ -172,11 +172,11 @@ public override async Task DropDatabaseAsync(DatabaseInfo databaseInfo, Cancella
172172
var dataOptions = new DataOptions().UseOracle(databaseInfo.DatabaseConnectionConfigMaster.ConnectionString)
173173
.UseMappingSchema(_mappingSchema);
174174

175-
using var context = new DataConnection(dataOptions);
176-
177175
var maxAttempts = 4;
178176
var delayBetweenAttempts = TimeSpan.FromSeconds(1);
179177

178+
using var context = new DataConnection(dataOptions);
179+
180180
for (var i = 0; i < maxAttempts; i++)
181181
{
182182
try

0 commit comments

Comments
 (0)