protected static void EnsureDatabase(string path)
{
if (!File.Exists(path))
{
string sql;
Stream stream = null;
try
{
stream = typeof(SQLiteRepository).Assembly.GetManifestResourceStream("BlueCollar.SQLite.Schema.sql");
using (StreamReader reader = new StreamReader(stream))
{
stream = null;
sql = reader.ReadToEnd();
}
}
finally
{
if (stream != null)
{
stream.Dispose();
}
}
using (SQLiteConnection connection = new SQLiteConnection(string.Concat("data source=", path, ";journal mode=Off;synchronous=Off;version=3")))
{
connection.Open();
connection.Execute(sql, null);
}
}
}