You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@xivk I see this old issue of mine is still open. I also noticed you removed the GTFS SQLite db code from this repo along with some other code not related to reading/parsing, handling and writing GTFS feeds in this commit.
Out of curiosity, did you move that code elsewhere? Or did you decide to no longer support databases?
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 TABLE
statements 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 TABLE
command) and ignore the new structure.The text was updated successfully, but these errors were encountered: