Research on possible history module implementation using sqlite ATTACH DATABASE

This commit is contained in:
Patrick Pacher
2023-06-14 09:38:25 +02:00
committed by Daniel
parent 45117c630f
commit e9e9b54364
3 changed files with 73 additions and 44 deletions

View File

@@ -66,12 +66,17 @@ func (ts TableSchema) GetColumnDef(name string) *ColumnDef {
}
// CreateStatement build the CREATE SQL statement for the table.
func (ts TableSchema) CreateStatement(ifNotExists bool) string {
func (ts TableSchema) CreateStatement(databaseName string, ifNotExists bool) string {
sql := "CREATE TABLE"
if ifNotExists {
sql += " IF NOT EXISTS"
}
sql += " " + ts.Name + " ( "
name := ts.Name
if databaseName != "" {
name = databaseName + "." + ts.Name
}
sql += " " + name + " ( "
for idx, col := range ts.Columns {
sql += col.AsSQL()