checkStyleTable method
Implementation
Future<bool> checkStyleTable() async {
if (!await _postgresDb.hasTable(TableName(HM_STYLES_TABLE))) {
var createTablesQuery = '''
CREATE TABLE $HM_STYLES_TABLE (
tablename TEXT NOT NULL,
sld TEXT,
simplified TEXT
);
CREATE UNIQUE INDEX ${HM_STYLES_TABLE}_tablename_idx ON $HM_STYLES_TABLE (tablename);
''';
var split = createTablesQuery.replaceAll("\n", "").trim().split(";");
for (int i = 0; i < split.length; i++) {
var sql = split[i].trim();
if (sql.isNotEmpty) {
try {
await _postgresDb.execute(sql);
_canHanldeStyle = true;
} catch (e) {
_canHanldeStyle = false;
return false;
}
}
}
} else {
_canHanldeStyle = true;
}
return true;
}