Add API for dropping all tables during destructive migrations.

The APIs are overloaded versions of the current fallbackToDestructiveMigration APIs with the older ones deprecated in order to have users migrate to the recommended behavior of dropping all tables, done so via the extra param in the overloaded version.

The API and behavior change addresses the issue of an application adding a new table in a version n+1 schema, then rolling back the deployment causing a downgrade but due to the table / entity not existing at version n Room would unknowingly keep the table (its untracked) thus causing a failure when the redeployment of the app at version n+1 is done again along with its migration.

Test: MigrationTest.dropAllTablesDuringDestructiveMigrations
Relnote: "Overload fallbackToDestructiveMigration APIs with a boolean parameter to indicate if all tables, including those not tracked by Room should be dropped during destructive migrations. Usually the value should be 'true' unless the database contains tables not defined via Room entities. The version of the APIs without the parameter are now deprecated and the default behavior of not destroying untracked tables is kept."
Change-Id: Ic8ef384aef7443430a1fc1e461aacaa18065126d
diff --git a/paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerViewModel.java b/paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerViewModel.java
index 6800bf7..731bf8a 100644
--- a/paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerViewModel.java
+++ b/paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerViewModel.java
@@ -29,11 +29,12 @@
 import androidx.paging.RxPagedListBuilder;
 import androidx.room.Room;
 
-import java.util.UUID;
-
 import io.reactivex.BackpressureStrategy;
 import io.reactivex.Flowable;
 
+import java.util.UUID;
+
+
 /**
  * Sample database-backed view model of Customers
  */
@@ -49,7 +50,7 @@
     private void createDb() {
         mDatabase = Room.databaseBuilder(this.getApplication(), SampleDatabase.class,
                         "customerDatabase")
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
 
         ArchTaskExecutor.getInstance().executeOnDiskIO(() -> {
diff --git a/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/AppDatabase.kt b/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/AppDatabase.kt
index 7fa6e40..bdd74bf 100644
--- a/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/AppDatabase.kt
+++ b/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/AppDatabase.kt
@@ -38,7 +38,7 @@
                 context.applicationContext,
                 AppDatabase::class.java,
                 "app_database"
-            ).fallbackToDestructiveMigration().build().also { Instance = it }
+            ).fallbackToDestructiveMigration(true).build().also { Instance = it }
         }
     }
 }
diff --git a/paging/samples/build.gradle b/paging/samples/build.gradle
index 23c0de7..aafe5a5 100644
--- a/paging/samples/build.gradle
+++ b/paging/samples/build.gradle
@@ -38,7 +38,7 @@
     implementation("androidx.fragment:fragment-ktx:1.3.0")
     implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0")
     implementation("androidx.recyclerview:recyclerview:1.2.0")
-    implementation("androidx.room:room-ktx:2.3.0")
+    implementation(project(":room:room-ktx"))
     implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
 
     implementation(project(":paging:paging-common"))
diff --git a/paging/samples/src/main/java/androidx/paging/samples/shared/RoomDb.kt b/paging/samples/src/main/java/androidx/paging/samples/shared/RoomDb.kt
index 9fcd9af..253201c 100644
--- a/paging/samples/src/main/java/androidx/paging/samples/shared/RoomDb.kt
+++ b/paging/samples/src/main/java/androidx/paging/samples/shared/RoomDb.kt
@@ -30,7 +30,7 @@
     companion object {
         fun create(context: Context): RoomDb {
             return Room.databaseBuilder(context, RoomDb::class.java, "user.db")
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(true)
                 .build()
         }
     }
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
index e298302..b3eee5d 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
@@ -57,7 +57,9 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Test custom database migrations.
@@ -360,7 +362,7 @@
         try {
             Context targetContext = ApplicationProvider.getApplicationContext();
             MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
-                    .fallbackToDestructiveMigrationOnDowngrade()
+                    .fallbackToDestructiveMigrationOnDowngrade(false)
                     .build();
             helper.closeWhenFinished(db);
             db.dao().loadAllEntity1s();
@@ -379,7 +381,7 @@
 
         Context targetContext = ApplicationProvider.getApplicationContext();
         MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         assertThat(db.dao().loadAllEntity1s().size(), is(0));
         db.close();
@@ -486,7 +488,7 @@
 
         Context targetContext = ApplicationProvider.getApplicationContext();
         MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
-                .fallbackToDestructiveMigrationOnDowngrade()
+                .fallbackToDestructiveMigrationOnDowngrade(false)
                 .build();
         assertThat(db.dao().loadAllEntity1s().size(), is(0));
         db.close();
@@ -503,7 +505,7 @@
 
         Context targetContext = ApplicationProvider.getApplicationContext();
         MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         assertThat(db.dao().loadAllEntity1s().size(), is(0));
         db.close();
@@ -520,7 +522,7 @@
 
         Context targetContext = ApplicationProvider.getApplicationContext();
         MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
-                .fallbackToDestructiveMigrationOnDowngrade()
+                .fallbackToDestructiveMigrationOnDowngrade(false)
                 .addMigrations(MIGRATION_MAX_LATEST)
                 .build();
         // Check that two values are present, confirming the database migration was successful
@@ -622,6 +624,28 @@
         }
     }
 
+    @Test
+    public void dropAllTablesDuringDestructiveMigrations() throws IOException {
+        SupportSQLiteDatabase database = helper.createDatabase(TEST_DB, MigrationDb.MAX_VERSION);
+        database.close();
+
+        Context targetContext = ApplicationProvider.getApplicationContext();
+        MigrationDb db = Room.databaseBuilder(targetContext, MigrationDb.class, TEST_DB)
+                .fallbackToDestructiveMigration(true)
+                .build();
+        Set<String> tableNames = new HashSet<>();
+        Cursor c = db.query("SELECT name FROM sqlite_master WHERE type = 'table'", new Object[0]);
+        while (c.moveToNext()) {
+            tableNames.add(c.getString(0));
+        }
+        c.close();
+        db.close();
+        // Extra table is no longer present
+        assertThat(tableNames.contains("Extra"), is(false));
+        // Android special table is present
+        assertThat(tableNames.contains("android_metadata"), is(true));
+    }
+
     private void testFailure(int startVersion, int endVersion) throws IOException {
         final SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, startVersion);
         db.close();
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java
index 1e9c3df..af1f237 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java
@@ -192,7 +192,7 @@
                 context, ProductsDatabase_v2.class, "products.db")
                 .createFromAsset("databases/products_v1.db")
                 .addCallback(callback)
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
 
         assertFalse(callback.mDestructivelyMigrated);
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PrepackageTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PrepackageTest.java
index 9a3a183..cbed55b 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PrepackageTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PrepackageTest.java
@@ -257,7 +257,7 @@
         ProductsDatabase_v2 database = Room.databaseBuilder(
                 context, ProductsDatabase_v2.class, "products.db")
                 .createFromAsset("databases/products_v1.db")
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
 
         ProductDao dao = database.getProductDao();
@@ -284,7 +284,7 @@
         ProductsDatabase_v2 database_v2 = Room.databaseBuilder(
                 context, ProductsDatabase_v2.class, "products.db")
                 .createFromAsset("databases/products_v2.db")
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         dao = database_v2.getProductDao();
         assertThat(dao.countProducts(), is(3));
@@ -310,7 +310,7 @@
         ProductsDatabase_v2 database_v2 = Room.databaseBuilder(
                 context, ProductsDatabase_v2.class, "products.db")
                 .createFromAsset("databases/products_v1.db")
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         dao = database_v2.getProductDao();
         assertThat(dao.countProducts(), is(0));
@@ -343,7 +343,7 @@
                                 "INSERT INTO Products (id, name) VALUES (null, 'Mofongo')");
                     }
                 })
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         dao = database_v2.getProductDao();
         assertThat(dao.countProducts(), is(3));
@@ -438,7 +438,7 @@
         ProductsDatabase_v2 database_v2 = Room.databaseBuilder(
                 context, ProductsDatabase_v2.class, "products_external.db")
                 .createFromFile(dataDbFile)
-                .fallbackToDestructiveMigration()
+                .fallbackToDestructiveMigration(false)
                 .build();
         dao = database_v2.getProductDao();
         assertThat(dao.countProducts(), is(0));
diff --git a/room/room-runtime/api/current.txt b/room/room-runtime/api/current.txt
index e8034b4..75eb444 100644
--- a/room/room-runtime/api/current.txt
+++ b/room/room-runtime/api/current.txt
@@ -4,6 +4,7 @@
   public class DatabaseConfiguration {
     method public boolean isMigrationRequired(int fromVersion, int toVersion);
     method @Deprecated public boolean isMigrationRequiredFrom(int version);
+    field public final boolean allowDestructiveMigrationForAllTables;
     field public final boolean allowDestructiveMigrationOnDowngrade;
     field public final boolean allowMainThreadQueries;
     field public final java.util.List<androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs;
@@ -102,9 +103,12 @@
     method public androidx.room.RoomDatabase.Builder<T> createFromInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamCallable);
     method public androidx.room.RoomDatabase.Builder<T> createFromInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamCallable, androidx.room.RoomDatabase.PrepackagedDatabaseCallback callback);
     method public androidx.room.RoomDatabase.Builder<T> enableMultiInstanceInvalidation();
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration();
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(int... startVersions);
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade();
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration();
+    method public final androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration(boolean dropAllTables);
+    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(boolean dropAllTables, int... startVersions);
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(int... startVersions);
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade();
+    method public final androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade(boolean dropAllTables);
     method public androidx.room.RoomDatabase.Builder<T> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory? factory);
     method @SuppressCompatibility @androidx.room.ExperimentalRoomApi public androidx.room.RoomDatabase.Builder<T> setAutoCloseTimeout(@IntRange(from=0L) long autoCloseTimeout, java.util.concurrent.TimeUnit autoCloseTimeUnit);
     method public androidx.room.RoomDatabase.Builder<T> setJournalMode(androidx.room.RoomDatabase.JournalMode journalMode);
diff --git a/room/room-runtime/api/restricted_current.txt b/room/room-runtime/api/restricted_current.txt
index 018c4e3..0e50e61 100644
--- a/room/room-runtime/api/restricted_current.txt
+++ b/room/room-runtime/api/restricted_current.txt
@@ -3,7 +3,8 @@
 
   public class DatabaseConfiguration {
     ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, boolean requireMigration, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom);
-    ctor @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, android.content.Intent? multiInstanceInvalidationServiceIntent, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile, java.util.concurrent.Callable<java.io.InputStream>? copyFromInputStream, androidx.room.RoomDatabase.PrepackagedDatabaseCallback? prepackagedDatabaseCallback, java.util.List<?> typeConverters, java.util.List<? extends androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs);
+    ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, android.content.Intent? multiInstanceInvalidationServiceIntent, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile, java.util.concurrent.Callable<java.io.InputStream>? copyFromInputStream, androidx.room.RoomDatabase.PrepackagedDatabaseCallback? prepackagedDatabaseCallback, java.util.List<?> typeConverters, java.util.List<? extends androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs);
+    ctor @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, android.content.Intent? multiInstanceInvalidationServiceIntent, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile, java.util.concurrent.Callable<java.io.InputStream>? copyFromInputStream, androidx.room.RoomDatabase.PrepackagedDatabaseCallback? prepackagedDatabaseCallback, java.util.List<?> typeConverters, java.util.List<? extends androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs, boolean allowDestructiveMigrationForAllTables);
     ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, boolean multiInstanceInvalidation, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom);
     ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, boolean multiInstanceInvalidation, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile);
     ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, boolean multiInstanceInvalidation, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile, java.util.concurrent.Callable<java.io.InputStream>? copyFromInputStream);
@@ -12,6 +13,7 @@
     ctor @Deprecated @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public DatabaseConfiguration(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory, androidx.room.RoomDatabase.MigrationContainer migrationContainer, java.util.List<? extends androidx.room.RoomDatabase.Callback>? callbacks, boolean allowMainThreadQueries, androidx.room.RoomDatabase.JournalMode journalMode, java.util.concurrent.Executor queryExecutor, java.util.concurrent.Executor transactionExecutor, boolean multiInstanceInvalidation, boolean requireMigration, boolean allowDestructiveMigrationOnDowngrade, java.util.Set<java.lang.Integer>? migrationNotRequiredFrom, String? copyFromAssetPath, java.io.File? copyFromFile, java.util.concurrent.Callable<java.io.InputStream>? copyFromInputStream, androidx.room.RoomDatabase.PrepackagedDatabaseCallback? prepackagedDatabaseCallback, java.util.List<?> typeConverters, java.util.List<? extends androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs);
     method public boolean isMigrationRequired(int fromVersion, int toVersion);
     method @Deprecated public boolean isMigrationRequiredFrom(int version);
+    field public final boolean allowDestructiveMigrationForAllTables;
     field public final boolean allowDestructiveMigrationOnDowngrade;
     field public final boolean allowMainThreadQueries;
     field public final java.util.List<androidx.room.migration.AutoMigrationSpec> autoMigrationSpecs;
@@ -157,9 +159,12 @@
     method public androidx.room.RoomDatabase.Builder<T> createFromInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamCallable);
     method public androidx.room.RoomDatabase.Builder<T> createFromInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamCallable, androidx.room.RoomDatabase.PrepackagedDatabaseCallback callback);
     method public androidx.room.RoomDatabase.Builder<T> enableMultiInstanceInvalidation();
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration();
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(int... startVersions);
-    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade();
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration();
+    method public final androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigration(boolean dropAllTables);
+    method public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(boolean dropAllTables, int... startVersions);
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationFrom(int... startVersions);
+    method @Deprecated public androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade();
+    method public final androidx.room.RoomDatabase.Builder<T> fallbackToDestructiveMigrationOnDowngrade(boolean dropAllTables);
     method public androidx.room.RoomDatabase.Builder<T> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory? factory);
     method @SuppressCompatibility @androidx.room.ExperimentalRoomApi public androidx.room.RoomDatabase.Builder<T> setAutoCloseTimeout(@IntRange(from=0L) long autoCloseTimeout, java.util.concurrent.TimeUnit autoCloseTimeUnit);
     method public androidx.room.RoomDatabase.Builder<T> setJournalMode(androidx.room.RoomDatabase.JournalMode journalMode);
diff --git a/room/room-runtime/src/main/java/androidx/room/DatabaseConfiguration.kt b/room/room-runtime/src/main/java/androidx/room/DatabaseConfiguration.kt
index 0d4aa4f..4f23139 100644
--- a/room/room-runtime/src/main/java/androidx/room/DatabaseConfiguration.kt
+++ b/room/room-runtime/src/main/java/androidx/room/DatabaseConfiguration.kt
@@ -30,7 +30,8 @@
  * Configuration class for a [RoomDatabase].
  */
 @Suppress("UNUSED_PARAMETER")
-open class DatabaseConfiguration @SuppressLint("LambdaLast")
+open class DatabaseConfiguration
+@SuppressLint("LambdaLast")
 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
 constructor(
     /**
@@ -100,6 +101,7 @@
     val allowDestructiveMigrationOnDowngrade: Boolean,
 
     private val migrationNotRequiredFrom: Set<Int>?,
+
     @JvmField
     val copyFromAssetPath: String?,
 
@@ -116,7 +118,10 @@
     val typeConverters: List<Any>,
 
     @JvmField
-    val autoMigrationSpecs: List<AutoMigrationSpec>
+    val autoMigrationSpecs: List<AutoMigrationSpec>,
+
+    @JvmField
+    val allowDestructiveMigrationForAllTables: Boolean,
 ) {
     /**
      * If true, table invalidation in an instance of [RoomDatabase] is broadcast and
@@ -144,14 +149,7 @@
      *
      */
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -182,7 +180,8 @@
         prepackagedDatabaseCallback = null,
         copyFromInputStream = null,
         typeConverters = emptyList(),
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -206,14 +205,7 @@
      *
      */
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -250,7 +242,8 @@
         prepackagedDatabaseCallback = null,
         copyFromInputStream = null,
         typeConverters = emptyList(),
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -276,14 +269,7 @@
      *
      */
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -322,7 +308,8 @@
         prepackagedDatabaseCallback = null,
         copyFromInputStream = null,
         typeConverters = emptyList(),
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -350,14 +337,7 @@
      *
      */
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -397,7 +377,8 @@
         prepackagedDatabaseCallback = null,
         copyFromInputStream = copyFromInputStream,
         typeConverters = emptyList(),
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -427,14 +408,7 @@
      */
     @SuppressLint("LambdaLast")
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -475,7 +449,8 @@
         prepackagedDatabaseCallback = prepackagedDatabaseCallback,
         copyFromInputStream = copyFromInputStream,
         typeConverters = emptyList(),
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -506,14 +481,7 @@
      */
     @SuppressLint("LambdaLast")
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -555,7 +523,8 @@
         prepackagedDatabaseCallback = prepackagedDatabaseCallback,
         copyFromInputStream = copyFromInputStream,
         typeConverters = typeConverters,
-        autoMigrationSpecs = emptyList()
+        autoMigrationSpecs = emptyList(),
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
@@ -587,14 +556,7 @@
      */
     @SuppressLint("LambdaLast")
     @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-    @Deprecated(
-        "This constructor is deprecated.",
-        ReplaceWith("DatabaseConfiguration(Context, String, " +
-            "SupportSQLiteOpenHelper.Factory, RoomDatabase.MigrationContainer, " +
-            "List, boolean, RoomDatabase.JournalMode, Executor, Executor, Intent, boolean, " +
-            "boolean, Set, String, File, Callable, RoomDatabase.PrepackagedDatabaseCallback, " +
-            "List, List)")
-    )
+    @Deprecated("This constructor is deprecated.")
     constructor(
         context: Context,
         name: String?,
@@ -637,7 +599,82 @@
         prepackagedDatabaseCallback = null,
         copyFromInputStream = copyFromInputStream,
         typeConverters = typeConverters,
-        autoMigrationSpecs = autoMigrationSpecs
+        autoMigrationSpecs = autoMigrationSpecs,
+        allowDestructiveMigrationForAllTables = false,
+    )
+
+    /**
+     * Creates a database configuration with the given values.
+     *
+     * @param context The application context.
+     * @param name Name of the database, can be null if it is in memory.
+     * @param sqliteOpenHelperFactory The open helper factory to use.
+     * @param migrationContainer The migration container for migrations.
+     * @param callbacks The list of callbacks for database events.
+     * @param allowMainThreadQueries Whether to allow main thread reads/writes or not.
+     * @param journalMode The journal mode. This has to be either TRUNCATE or WRITE_AHEAD_LOGGING.
+     * @param queryExecutor The Executor used to execute asynchronous queries.
+     * @param transactionExecutor The Executor used to execute asynchronous transactions.
+     * @param multiInstanceInvalidationServiceIntent Intent that should be bound to acquire the
+     * invalidation service or `null` if not used.
+     * @param requireMigration True if Room should require a valid migration if version changes,
+     * @param allowDestructiveMigrationOnDowngrade True if Room should recreate tables if no
+     * migration is supplied during a downgrade.
+     * @param migrationNotRequiredFrom The collection of schema versions from which migrations
+     * aren't required.
+     * @param copyFromAssetPath The assets path to the pre-packaged database.
+     * @param copyFromFile The pre-packaged database file.
+     * @param copyFromInputStream The callable to get the input stream from which a
+     * pre-package database file will be copied from.
+     * @param prepackagedDatabaseCallback The pre-packaged callback.
+     * @param typeConverters The type converters.
+     * @param autoMigrationSpecs The auto migration specs.
+     *
+     */
+    @SuppressLint("LambdaLast")
+    @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
+    @Deprecated("This constructor is deprecated.")
+    constructor(
+        context: Context,
+        name: String?,
+        sqliteOpenHelperFactory: SupportSQLiteOpenHelper.Factory,
+        migrationContainer: RoomDatabase.MigrationContainer,
+        callbacks: List<RoomDatabase.Callback>?,
+        allowMainThreadQueries: Boolean,
+        journalMode: RoomDatabase.JournalMode,
+        queryExecutor: Executor,
+        transactionExecutor: Executor,
+        multiInstanceInvalidationServiceIntent: Intent?,
+        requireMigration: Boolean,
+        allowDestructiveMigrationOnDowngrade: Boolean,
+        migrationNotRequiredFrom: Set<Int>?,
+        copyFromAssetPath: String?,
+        copyFromFile: File?,
+        copyFromInputStream: Callable<InputStream>?,
+        prepackagedDatabaseCallback: RoomDatabase.PrepackagedDatabaseCallback?,
+        typeConverters: List<Any>,
+        autoMigrationSpecs: List<AutoMigrationSpec>
+    ) : this(
+        context = context,
+        name = name,
+        sqliteOpenHelperFactory = sqliteOpenHelperFactory,
+        migrationContainer = migrationContainer,
+        callbacks = callbacks,
+        allowMainThreadQueries = allowMainThreadQueries,
+        journalMode = journalMode,
+        queryExecutor = queryExecutor,
+        transactionExecutor = transactionExecutor,
+        multiInstanceInvalidationServiceIntent = multiInstanceInvalidationServiceIntent,
+        allowDestructiveMigrationOnDowngrade = allowDestructiveMigrationOnDowngrade,
+        requireMigration = requireMigration,
+        migrationNotRequiredFrom = migrationNotRequiredFrom,
+        copyFromAssetPath = copyFromAssetPath,
+        copyFromFile = copyFromFile,
+        prepackagedDatabaseCallback = null,
+        copyFromInputStream = copyFromInputStream,
+        typeConverters = typeConverters,
+        autoMigrationSpecs = autoMigrationSpecs,
+        allowDestructiveMigrationForAllTables = false,
     )
 
     /**
diff --git a/room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt b/room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt
index c382488..f8c62e6 100644
--- a/room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt
+++ b/room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt
@@ -692,6 +692,7 @@
         private var multiInstanceInvalidationIntent: Intent? = null
         private var requireMigration: Boolean = true
         private var allowDestructiveMigrationOnDowngrade = false
+        private var allowDestructiveMigrationForAllTables = false
         private var autoCloseTimeout = -1L
         private var autoCloseTimeUnit: TimeUnit? = null
 
@@ -1078,8 +1079,8 @@
          * If it cannot find the set of [Migration]s that will bring the database to the
          * current version, it will throw an [IllegalStateException].
          *
-         * You can call this method to change this behavior to re-create the database instead of
-         * crashing.
+         * You can call this method to change this behavior to re-create the database tables instead
+         * of crashing.
          *
          * If the database was create from an asset or a file then Room will try to use the same
          * file to re-create the database, otherwise this will delete all of the data in the
@@ -1090,12 +1091,49 @@
          *
          * @return This builder instance.
          */
+        @Deprecated(
+            message = "Replace by overloaded version with parameter to indicate if all tables" +
+                "should be dropped or not.",
+            replaceWith = ReplaceWith("fallbackToDestructiveMigration(false)")
+        )
+        @Suppress("BuilderSetStyle") // Overload of exsisting API
         open fun fallbackToDestructiveMigration() = apply {
             this.requireMigration = false
             this.allowDestructiveMigrationOnDowngrade = true
         }
 
         /**
+         * Allows Room to destructively recreate database tables if [Migration]s that would
+         * migrate old database schemas to the latest schema version are not found.
+         *
+         * When the database version on the device does not match the latest schema version, Room
+         * runs necessary [Migration]s on the database.
+         *
+         * If it cannot find the set of [Migration]s that will bring the database to the
+         * current version, it will throw an [IllegalStateException].
+         *
+         * You can call this method to change this behavior to re-create the database tables instead
+         * of crashing.
+         *
+         * If the database was create from an asset or a file then Room will try to use the same
+         * file to re-create the database, otherwise this will delete all of the data in the
+         * database tables managed by Room.
+         *
+         * To let Room fallback to destructive migration only during a schema downgrade then use
+         * [fallbackToDestructiveMigrationOnDowngrade].
+         *
+         * @param dropAllTables Set to `true` if all tables should be dropped during destructive
+         * migration including those not managed by Room.
+         * @return This builder instance.
+         */
+        @Suppress("BuilderSetStyle") // Overload of existing API
+        fun fallbackToDestructiveMigration(dropAllTables: Boolean) = apply {
+            this.requireMigration = false
+            this.allowDestructiveMigrationOnDowngrade = true
+            this.allowDestructiveMigrationForAllTables = dropAllTables
+        }
+
+        /**
          * Allows Room to destructively recreate database tables if [Migration]s are not
          * available when downgrading to old schema versions.
          *
@@ -1103,12 +1141,35 @@
          *
          * @return This builder instance.
          */
+        @Deprecated(
+            message = "Replace by overloaded version with parameter to indicate if all tables" +
+                "should be dropped or not.",
+            replaceWith = ReplaceWith("fallbackToDestructiveMigrationOnDowngrade(false)")
+        )
         open fun fallbackToDestructiveMigrationOnDowngrade() = apply {
             this.requireMigration = true
             this.allowDestructiveMigrationOnDowngrade = true
         }
 
         /**
+         * Allows Room to destructively recreate database tables if [Migration]s are not
+         * available when downgrading to old schema versions.
+         *
+         * For details, see [Builder.fallbackToDestructiveMigration].
+         *
+         * @param dropAllTables Set to `true` if all tables should be dropped during destructive
+         * migration including those not managed by Room. Recommended value is `true` as otherwise
+         * Room could leave obsolete data when table names or existence changes between versions.
+         * @return This builder instance.
+         */
+        @Suppress("BuilderSetStyle") // Overload of existing API
+        fun fallbackToDestructiveMigrationOnDowngrade(dropAllTables: Boolean) = apply {
+            this.requireMigration = true
+            this.allowDestructiveMigrationOnDowngrade = true
+            this.allowDestructiveMigrationForAllTables = dropAllTables
+        }
+
+        /**
          * Informs Room that it is allowed to destructively recreate database tables from specific
          * starting schema versions.
          *
@@ -1129,6 +1190,11 @@
          * migration.
          * @return This builder instance.
          */
+        @Deprecated(
+            message = "Replace by overloaded version with parameter to indicate if all tables" +
+                "should be dropped or not.",
+            replaceWith = ReplaceWith("fallbackToDestructiveMigrationFrom(false, startVersions)")
+        )
         open fun fallbackToDestructiveMigrationFrom(vararg startVersions: Int) = apply {
             for (startVersion in startVersions) {
                 this.migrationsNotRequiredFrom.add(startVersion)
@@ -1136,6 +1202,40 @@
         }
 
         /**
+         * Informs Room that it is allowed to destructively recreate database tables from specific
+         * starting schema versions.
+         *
+         * This functionality is the same as that provided by
+         * [fallbackToDestructiveMigration], except that this method allows the
+         * specification of a set of schema versions for which destructive recreation is allowed.
+         *
+         * Using this method is preferable to [fallbackToDestructiveMigration] if you want
+         * to allow destructive migrations from some schema versions while still taking advantage
+         * of exceptions being thrown due to unintentionally missing migrations.
+         *
+         * Note: No versions passed to this method may also exist as either starting or ending
+         * versions in the [Migration]s provided to [addMigrations]. If a
+         * version passed to this method is found as a starting or ending version in a Migration, an
+         * exception will be thrown.
+         *
+         * @param dropAllTables Set to `true` if all tables should be dropped during destructive
+         * migration including those not managed by Room.
+         * @param startVersions The set of schema versions from which Room should use a destructive
+         * migration.
+         * @return This builder instance.
+         */
+        @Suppress("BuilderSetStyle") // Overload of existing API
+        open fun fallbackToDestructiveMigrationFrom(
+            dropAllTables: Boolean,
+            vararg startVersions: Int
+        ) = apply {
+            for (startVersion in startVersions) {
+                this.migrationsNotRequiredFrom.add(startVersion)
+            }
+            this.allowDestructiveMigrationForAllTables = dropAllTables
+        }
+
+        /**
          * Adds a [Callback] to this database.
          *
          * @param callback The callback.
@@ -1329,7 +1429,8 @@
                 copyFromInputStream,
                 prepackagedDatabaseCallback,
                 typeConverters,
-                autoMigrationSpecs
+                autoMigrationSpecs,
+                allowDestructiveMigrationForAllTables
             )
             val db = Room.getGeneratedImplementation<T, T>(klass, "_Impl")
             db.init(configuration)
diff --git a/room/room-runtime/src/main/java/androidx/room/RoomOpenHelper.kt b/room/room-runtime/src/main/java/androidx/room/RoomOpenHelper.kt
index 879f98d..7c67988 100644
--- a/room/room-runtime/src/main/java/androidx/room/RoomOpenHelper.kt
+++ b/room/room-runtime/src/main/java/androidx/room/RoomOpenHelper.kt
@@ -103,7 +103,13 @@
         if (!migrated) {
             val config = this.configuration
             if (config != null && !config.isMigrationRequired(oldVersion, newVersion)) {
-                delegate.dropAllTables(db)
+                if (config.allowDestructiveMigrationForAllTables) {
+                    // Drops all tables (excluding special ones)
+                    dropAllTables(db)
+                } else {
+                    // Drops known tables (Room entity tables)
+                    delegate.dropAllTables(db)
+                }
                 delegate.createAllTables(db)
             } else {
                 throw IllegalStateException(
@@ -205,13 +211,13 @@
 
         /**
          * Called before migrations execute to perform preliminary work.
-         * @param database The SQLite database.
+         * @param db The SQLite database.
          */
         open fun onPreMigrate(db: SupportSQLiteDatabase) {}
 
         /**
          * Called after migrations execute to perform additional work.
-         * @param database The SQLite database.
+         * @param db The SQLite database.
          */
         open fun onPostMigrate(db: SupportSQLiteDatabase) {}
     }
@@ -240,5 +246,23 @@
                 return cursor.moveToFirst() && cursor.getInt(0) == 0
             }
         }
+
+        internal fun dropAllTables(db: SupportSQLiteDatabase) {
+            db.query(
+                "SELECT name FROM sqlite_master WHERE type = 'table'"
+            ).useCursor { cursor ->
+                buildList {
+                    while (cursor.moveToNext()) {
+                        val name = cursor.getString(0)
+                        if (name.startsWith("sqlite_") || name == "android_metadata") {
+                            continue
+                        }
+                        add(name)
+                    }
+                }
+            }.forEach { table ->
+                db.execSQL("DROP TABLE IF EXISTS $table")
+            }
+        }
     }
 }
diff --git a/room/room-runtime/src/test/java/androidx/room/BuilderTest.kt b/room/room-runtime/src/test/java/androidx/room/BuilderTest.kt
index e48d8ed..b203581 100644
--- a/room/room-runtime/src/test/java/androidx/room/BuilderTest.kt
+++ b/room/room-runtime/src/test/java/androidx/room/BuilderTest.kt
@@ -172,7 +172,7 @@
     fun skipMigration() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigration()
+            .fallbackToDestructiveMigration(false)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.requireMigration).isFalse()
@@ -182,7 +182,7 @@
     fun fallbackToDestructiveMigrationFrom_calledOnce_migrationsNotRequiredForValues() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationFrom(1, 2).build()
+            .fallbackToDestructiveMigrationFrom(true, 1, 2).build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.isMigrationRequired(1, 2)).isFalse()
         assertThat(config.isMigrationRequired(2, 3)).isFalse()
@@ -192,8 +192,8 @@
     fun fallbackToDestructiveMigrationFrom_calledTwice_migrationsNotRequiredForValues() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationFrom(1, 2)
-            .fallbackToDestructiveMigrationFrom(3, 4)
+            .fallbackToDestructiveMigrationFrom(true, 1, 2)
+            .fallbackToDestructiveMigrationFrom(true, 3, 4)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.isMigrationRequired(1, 2)).isFalse()
@@ -206,7 +206,7 @@
     fun isMigrationRequiredFrom_fallBackToDestructiveCalled_alwaysReturnsFalse() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigration()
+            .fallbackToDestructiveMigration(false)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
 
@@ -228,7 +228,7 @@
     fun isMigrationRequired_destructiveMigrationOnDowngrade_returnTrueWhenUpgrading() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationOnDowngrade()
+            .fallbackToDestructiveMigrationOnDowngrade(false)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
 
@@ -245,7 +245,7 @@
     fun isMigrationRequired_destructiveMigrationOnDowngrade_returnFalseWhenDowngrading() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationOnDowngrade()
+            .fallbackToDestructiveMigrationOnDowngrade(false)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
 
@@ -281,7 +281,7 @@
     fun isMigrationRequiredFrom_fallBackToDestFromCalled_falseForProvidedValues() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationFrom(1, 4, 81)
+            .fallbackToDestructiveMigrationFrom(true, 1, 4, 81)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.isMigrationRequired(1, 2)).isFalse()
@@ -293,7 +293,7 @@
     fun isMigrationRequiredFrom_fallBackToDestFromCalled_trueForNonProvidedValues() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationFrom(1, 4, 81)
+            .fallbackToDestructiveMigrationFrom(true, 1, 4, 81)
             .build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.isMigrationRequired(2, 3)).isTrue()
@@ -320,8 +320,8 @@
     fun fallbackToDestructiveMigrationOnDowngrade_withProvidedValues_falseForDowngrades() {
         val context: Context = mock()
         val db = inMemoryDatabaseBuilder(context, TestDatabase::class.java)
-            .fallbackToDestructiveMigrationOnDowngrade()
-            .fallbackToDestructiveMigrationFrom(2, 4).build()
+            .fallbackToDestructiveMigrationOnDowngrade(false)
+            .fallbackToDestructiveMigrationFrom(true, 2, 4).build()
         val config: DatabaseConfiguration = (db as BuilderTest_TestDatabase_Impl).mConfig
         assertThat(config.isMigrationRequired(1, 2)).isTrue()
         assertThat(config.isMigrationRequired(2, 3)).isFalse()
diff --git a/room/room-testing/src/main/java/androidx/room/testing/MigrationTestHelper.kt b/room/room-testing/src/main/java/androidx/room/testing/MigrationTestHelper.kt
index 689fa7b..792bb02 100644
--- a/room/room-testing/src/main/java/androidx/room/testing/MigrationTestHelper.kt
+++ b/room/room-testing/src/main/java/androidx/room/testing/MigrationTestHelper.kt
@@ -214,7 +214,8 @@
             copyFromInputStream = null,
             prepackagedDatabaseCallback = null,
             typeConverters = emptyList(),
-            autoMigrationSpecs = emptyList()
+            autoMigrationSpecs = emptyList(),
+            allowDestructiveMigrationForAllTables = false
         )
         val roomOpenHelper = RoomOpenHelper(
             configuration = configuration,
@@ -293,7 +294,8 @@
             copyFromInputStream = null,
             prepackagedDatabaseCallback = null,
             typeConverters = emptyList(),
-            autoMigrationSpecs = emptyList()
+            autoMigrationSpecs = emptyList(),
+            allowDestructiveMigrationForAllTables = false
         )
         val roomOpenHelper = RoomOpenHelper(
             configuration = databaseConfiguration,
diff --git a/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/room/PhotoDatabase.java b/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/room/PhotoDatabase.java
index 4cfee59..28fa643 100644
--- a/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/room/PhotoDatabase.java
+++ b/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/room/PhotoDatabase.java
@@ -55,7 +55,7 @@
                             }
                         }
                     })
-                    .fallbackToDestructiveMigration()
+                    .fallbackToDestructiveMigration(false)
                     .build();
         }
         return sInstance;
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabase.kt b/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabase.kt
index b1d2015..85de971 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabase.kt
+++ b/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabase.kt
@@ -147,6 +147,7 @@
                         FrameworkSQLiteOpenHelperFactory().create(configBuilder.build())
                     }
             }
+            @Suppress("DEPRECATION") // b/310884421 for fallbackToDestructiveMigration()
             return builder.setQueryExecutor(queryExecutor)
                 .addCallback(CleanupCallback(clock))
                 .addMigrations(Migration_1_2)