createManyToManyTable method

Future<void> createManyToManyTable(
  1. String junctionTableName,
  2. String table1,
  3. String table2,
  4. String foreignKey1,
  5. String foreignKey2,
)

Implementation

Future<void> createManyToManyTable(
    String junctionTableName,
    String table1,
    String table2,
    String foreignKey1,
    String foreignKey2) async {
  await _database.execute(
    'CREATE TABLE IF NOT EXISTS $junctionTableName ($foreignKey1 INTEGER, $foreignKey2 INTEGER, '
    'FOREIGN KEY ($foreignKey1) REFERENCES $table1(id), '
    'FOREIGN KEY ($foreignKey2) REFERENCES $table2(id))',
  );
}