Skip to content

Instantly share code, notes, and snippets.

@dinorahto
Created July 16, 2019 14:23
Show Gist options
  • Select an option

  • Save dinorahto/150455745b917f68c56300c24fe616b8 to your computer and use it in GitHub Desktop.

Select an option

Save dinorahto/150455745b917f68c56300c24fe616b8 to your computer and use it in GitHub Desktop.
ForeignKeys on Room migration
val queryForDatabase = """
CREATE TABLE IF NOT EXISTS UpdatedTableProduct (idProduct TEXT PRIMARY KEY NOT NULL, name TEXT, nameClean TEXT,
description TEXT, discount INT, skuId TEXT, hasAddedToCart INT, opened INT, notified INT,
FOREIGN KEY (idProduct) REFERENCES Image(imageId) ON UPDATE NO ACTION ON DELETE NO ACTION,
FOREIGN KEY (skuId) REFERENCES Prices(idProduct) ON UPDATE NO ACTION ON DELETE NO ACTION """"
database.execSQL(queryForDatabase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment