/// <summary> /// Drop a table from the database schema /// </summary> /// <param name="table">Name of table to drop</param> public async Task DropAsync(string table) { var totalTimer = ScopeTiming.StartTiming(); try { NameValues.ClearCaches(); int tableId = await Tables.GetIdAsync(Ctxt, table, noCreate : true, noException : true).ConfigureAwait(false); if (tableId < 0) { return; } await Ctxt.Db.ExecuteSqlAsync($"DELETE FROM itemnamevalues WHERE nameid IN (SELECT id FROM names WHERE tableid = {tableId})").ConfigureAwait(false); await Ctxt.Db.ExecuteSqlAsync($"DELETE FROM names WHERE tableid = {tableId}").ConfigureAwait(false); await Ctxt.Db.ExecuteSqlAsync($"DELETE FROM items WHERE tableid = {tableId}").ConfigureAwait(false); await Ctxt.Db.ExecuteSqlAsync($"DELETE FROM tables WHERE id = {tableId}").ConfigureAwait(false); NameValues.ClearCaches(); } finally { ScopeTiming.RecordScope("Cmd.Drop", totalTimer); } }
/// <summary> /// Reset the metastrings database /// Only used internally for testing, should not be used in a production environment /// </summary> /// <param name="reset">Reset request object</param> public void Reset(bool includeNameValues = false) { if (includeNameValues) { NameValues.Reset(Ctxt); } else { Items.Reset(Ctxt); } NameValues.ClearCaches(); }