TableToString Table output a CREATE TABLE statement using mysql dialect.
(tbl *schema.Table)
| 42 | |
| 43 | // TableToString Table output a CREATE TABLE statement using mysql dialect. |
| 44 | func TableToString(tbl *schema.Table) string { |
| 45 | |
| 46 | w := &bytes.Buffer{} |
| 47 | //u.Infof("%s tbl=%p fields? %#v fields?%v", tbl.Name, tbl, tbl.FieldMap, len(tbl.Fields)) |
| 48 | fmt.Fprintf(w, "CREATE TABLE `%s` (", tbl.Name) |
| 49 | for i, fld := range tbl.Fields { |
| 50 | if i != 0 { |
| 51 | w.WriteByte(',') |
| 52 | } |
| 53 | fmt.Fprint(w, "\n ") |
| 54 | WriteField(w, fld) |
| 55 | } |
| 56 | fmt.Fprint(w, "\n);") |
| 57 | //tblStr := fmt.Sprintf("CREATE TABLE `%s` (\n\n);", tbl.Name, strings.Join(cols, ",")) |
| 58 | //return tblStr, nil |
| 59 | return w.String() |
| 60 | } |
| 61 | |
| 62 | // WriteField write a schema.Field as string output for sqlite create statement |
| 63 | // |