I haven't tested it to see what would happen, but there is a backward compatibility issue when adding more columns to existing tables in the way that you did it. I would suggest adding this line to the end of SQLiteGTFSFeedDb.RebuildDb():
if (!ColumnExists("stop_time", "timepoint")) this.ExecuteNonQuery("ALTER TABLE [stop_time] ADD [timepoint] TEXT;");
this uses the new method in RebuildDb():
/// <summary>
/// Checks if the given table contains a column with the given name.
/// </summary>
/// <param name="tableName">The table in this database to check.</param>
/// <param name="columnName">The column in the given table to look for.</param>
/// <returns>True if the given table contains a column with the given name.</returns>
private bool ColumnExists(string tableName, string columnName)
{
var cmd = new SQLiteCommand("PRAGMA table_info(" + tableName + ")", _connection);
var dr = cmd.ExecuteReader();
while (dr.Read())
{
var value = dr.GetValue(1);//column 1 from the result contains the column names
if (columnName.Equals(value))
{
dr.Close();
return true;
}
}
dr.Close();
return false;
}
Further, I noticed that there are 2 CREATE TABLE statements for the stop_time table in RebuildDb. Not entirely sure what the effect of this is going to be, but I'm pretty sure it would just go ahead and create the table with the old structure (first CREATE TABLE command) and ignore the new structure.
I haven't tested it to see what would happen, but there is a backward compatibility issue when adding more columns to existing tables in the way that you did it. I would suggest adding this line to the end of
SQLiteGTFSFeedDb.RebuildDb():if (!ColumnExists("stop_time", "timepoint")) this.ExecuteNonQuery("ALTER TABLE [stop_time] ADD [timepoint] TEXT;");this uses the new method in
RebuildDb():Further, I noticed that there are 2
CREATE TABLEstatements for the stop_time table inRebuildDb. Not entirely sure what the effect of this is going to be, but I'm pretty sure it would just go ahead and create the table with the old structure (firstCREATE TABLEcommand) and ignore the new structure.