init static method
Implementation
static init({required List<TableDatabase> tableList, String? databaseName, String? customPath}) async {
List<String> insertList = [_tableBuilder(sqlQueryTables()), _tableBuilder(foreignKeyTables())];
List<TableDatabase> foreignKey = [];
listForeignKeyQuery = [];
listTableQuery = [];
for (final tl in tableList) {
insertList.add(_tableBuilder(tl));
for (final col in tl.column) {
listTableQuery!.add(
buildToQuery(
nameTable: tl.tableName,
nameColumn: col.name,
isAI: col.autoIncrement ? "1" : '0',
isPirmary: col.primaryKey ? '1' : '0',
config: '${col.typeData}|${col.isNull}|${col.defaultValue}',
),
);
}
if (tl.foreignKey != null) {
listForeignKeyQuery!.add(
buildForeignKeyToQuery(
nameColumn: tl.foreignKey?.baseColumn,
nameColumnTarget: tl.foreignKey?.referenceColumn,
nameTable: tl.tableName,
nameTableTarget: tl.foreignKey?.referenceTable,
delete: tl.foreignKey?.deleteAction.toString(),
update: tl.foreignKey?.updateAction.toString(),
),
);
}
}
for (final tl in foreignKey) {
insertList.add(_tableBuilder(tl));
}
await DatabaseConfig.init(
tables: insertList,
dbName: databaseName,
rawTables: tableList,
customPath: customPath,
);
}