purge function
Purges all data and schemas.
Implementation
Future purge(Connection conn,
Map<String, Map<String, SqlType>> tables,
Map<String, IndexInfo> indexes, Map<String, RuleInfo> rules) {
return Future.forEach(rules.keys,
(name) => conn.execute('drop rule "$name" on "${rules[name]!.table}"')
.catchError((ex) {}, test: _isUndefined))
.then((_) => Future.forEach(indexes.keys.toList().reversed,
(name) => conn.execute('drop index "$name"')
.catchError((ex) {}, test: _isUndefined)))
.then((_) {
final tblsGened = HashSet<String>();
final refsDeferred = <_DeferredRef>[];
for (final otype in tables.keys)
_scanDeferredRefs(otype, tables[otype]!, tblsGened, refsDeferred);
return Future.forEach(refsDeferred,
(_DeferredRef defRef) => defRef.drop(conn)
.catchError((ex) {}, test: _isUndefined));
})
.then((_) => Future.forEach(
tables.keys.toList().reversed,
(String name) => conn.execute('drop table "$name"')
.catchError((ex) {}, test: _isUndefined)
));
}