diff --git a/import-custom-sql.sh b/import-custom-sql.sh index ee090af39..ca2fe0370 100644 --- a/import-custom-sql.sh +++ b/import-custom-sql.sh @@ -184,6 +184,16 @@ import_store_sql() { return 0 fi + # Store.sql is a one-time bootstrap, not a repeatable migration. It + # contains UPDATE and DELETE statements that would overwrite values + # maintained in the live store database. The canonical services table is + # created by the initial bootstrap, so its presence also protects + # installations created before this guard was introduced. + if database_exists "store" && table_exists "store" "store_services"; then + log "store database already initialized, skipping one-time Store.sql bootstrap" + return 0 + fi + if ! database_exists "store"; then log "creating database store" mysql_exec "" "CREATE DATABASE IF NOT EXISTS \`store\` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"