RebuildTable constructor

RebuildTable(
  1. TableSchema before,
  2. TableSchema after, {
  3. required Map<String, String> copy,
})

Freezes an explicit copy map between two shapes of the same SQLite table.

The map must be nonempty and may target only existing, noncomputed columns.

Implementation

RebuildTable(this.before, this.after, {required Map<String, String> copy})
  : copy = Map.unmodifiable(copy) {
  if (before.name != after.name ||
      copy.isEmpty ||
      copy.keys.any(
        (key) =>
            !after.columns.any((c) => c.name == key && c.computed == null),
      )) {
    throw const OrmException(
      'MIGRATION.REBUILD',
      'Rebuild requires the same table name and an explicit target-column copy map.',
    );
  }
}