Skip to content

Instantly share code, notes, and snippets.

@florina-muntenescu
Last active April 22, 2021 17:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save florina-muntenescu/39f4ff6f6cb6f68fe14078f23d60f8b4 to your computer and use it in GitHub Desktop.
Save florina-muntenescu/39f4ff6f6cb6f68fe14078f23d60f8b4 to your computer and use it in GitHub Desktop.
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Database(
version = 2,
entities = [ GoodDoggos.class ],
autoMigrations = [
AutoMigration (
from = 1,
to = 2,
spec = DoggosDatabase.DoggosAutoMigration::class
)
]
)
abstract class DoggosDatabase : RoomDatabase {
@RenameTable(fromTableName = "Doggos", toTableName = "GoodDoggos")
class DoggosAutoMigration: AutoMigrationSpec { }
}
@bilgehankalkan
Copy link

DoggosDatabase .java

@itsandreramon
Copy link

I was so confused at first, wondering why it didn't work I thought we were over this Java stuff lol

@itsandreramon
Copy link

itsandreramon commented Apr 22, 2021

In Kotlin you would write it like this I think:

@Database(
    version = 2,
    entities = [
        MyEntity::class,
    ],
    autoMigrations = [
        AutoMigration(from = 1, to = 2)
    ],
    exportSchema = true
)
abstract class ... 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment