Skip to content

Commit

Permalink
delete AddCrossingType from db (fixes #5522)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Mar 5, 2024
1 parent 497d35f commit b2067e2
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import de.westnordost.streetcomplete.quests.oneway_suspects.data.WayTrafficFlowT

/** Creates the database and upgrades it */
object DatabaseInitializer {
const val DB_VERSION = 15
const val DB_VERSION = 16

fun onCreate(db: Database) {
// OSM notes
Expand Down Expand Up @@ -242,9 +242,22 @@ object DatabaseInitializer {
if (oldVersion <= 14 && newVersion > 14) {
db.renameOverlay("ShopsOverlay", "PlacesOverlay")
}
if (oldVersion <= 15 && newVersion > 15) {
db.deleteQuest("AddCrossingType")
}
}
}

private fun Database.deleteQuest(name: String) {
deleteValue(ElementEditsTable.NAME, ElementEditsTable.Columns.QUEST_TYPE, name)
deleteValue(OsmQuestTable.NAME, OsmQuestTable.Columns.QUEST_TYPE, name)
deleteValue(OsmQuestsHiddenTable.NAME, OsmQuestsHiddenTable.Columns.QUEST_TYPE, name)
deleteValue(VisibleQuestTypeTable.NAME, VisibleQuestTypeTable.Columns.QUEST_TYPE, name)
deleteValue(OpenChangesetsTable.NAME, OpenChangesetsTable.Columns.QUEST_TYPE, name)
deleteValue(QuestTypeOrderTable.NAME, QuestTypeOrderTable.Columns.BEFORE, name)
deleteValue(QuestTypeOrderTable.NAME, QuestTypeOrderTable.Columns.AFTER, name)
}

private fun Database.renameQuest(old: String, new: String) {
renameValue(ElementEditsTable.NAME, ElementEditsTable.Columns.QUEST_TYPE, old, new)
renameValue(OsmQuestTable.NAME, OsmQuestTable.Columns.QUEST_TYPE, old, new)
Expand All @@ -263,3 +276,7 @@ private fun Database.renameOverlay(old: String, new: String) {
private fun Database.renameValue(table: String, column: String, oldValue: String, newValue: String) {
update(table, listOf(column to newValue), "$column = ?", arrayOf(oldValue))
}

private fun Database.deleteValue(table: String, column: String, value: String) {
delete(table, "$column = ?", arrayOf(value))
}

0 comments on commit b2067e2

Please sign in to comment.