private void SetupSQLiteEventStore()
{
this.DBfileFullPath = InternalSDKUtils.DetermineAppLocalStoragePath(dbFileName);
string vacuumCommand = "PRAGMA auto_vacuum = 1";
string sqlCommand = string.Format(CultureInfo.InvariantCulture, "CREATE TABLE IF NOT EXISTS {0} ({1} TEXT NOT NULL,{2} TEXT NOT NULL UNIQUE,{3} TEXT NOT NULL, {4} INTEGER NOT NULL DEFAULT 0 )",
TABLE_NAME, EVENT_COLUMN_NAME, EVENT_ID_COLUMN_NAME, MA_APP_ID_COLUMN_NAME, EVENT_DELIVERY_ATTEMPT_COUNT_COLUMN_NAME);
lock (_lock)
{
using (var connection = new SQLiteConnection("Data Source=" + this.DBfileFullPath + ";Version=3;"))
{
try
{
if (!File.Exists(this.DBfileFullPath))
{
string directory = Path.GetDirectoryName(this.DBfileFullPath);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
SQLiteConnection.CreateFile(this.DBfileFullPath);
}
connection.Open();
using (var command = new SQLiteCommand(vacuumCommand, connection))
{
command.ExecuteNonQuery();
}
using (var command = new SQLiteCommand(sqlCommand, connection))
{
command.ExecuteNonQuery();
}
}
finally
{
if (null != connection)
connection.Close();
}
}
}
}