Skip to content

Commit

Permalink
Added locking Table Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Aug 11, 2017
1 parent 6451a52 commit fb9e72a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/SQLiteAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,38 @@ public Task<CreateTablesResult> CreateTablesAsync (CreateFlags createFlags = Cre
return WriteAsync (conn => conn.CreateTables (createFlags, types));
}

/// <summary>
/// Executes a "create table if not exists" on the database for each type. It also
/// creates any specified indexes on the columns of the table. It uses
/// a schema automatically generated from the specified type. You can
/// later access this schema by calling GetMapping.
/// </summary>
/// <returns>
/// Whether the table was created or migrated for each type.
/// </returns>
public CreateTablesResult CreateTables (CreateFlags createFlags = CreateFlags.None, params Type[] types)
{
var result = new CreateTablesResult ();
var conn = GetConnection ();
using (conn.Lock())
{
foreach (Type type in types)
{
try
{
var aResult = conn.CreateTable (type);
result.Results[type] = aResult;
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("Error creating table for {0}", type);
throw;
}
}
}
return result;
}

/// <summary>
/// Executes a "drop table" on the database. This is non-recoverable.
/// </summary>
Expand Down

0 comments on commit fb9e72a

Please sign in to comment.