Commit 348a93d 1 parent 8abaa12 commit 348a93d Copy full SHA for 348a93d
File tree 1 file changed +5
-17
lines changed
1 file changed +5
-17
lines changed Original file line number Diff line number Diff line change 1
1
package exodus
2
2
3
- import "fmt"
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+ )
4
7
5
8
// Migration is a fully-formed SQL command that can be ran against
6
9
// a database connection.
@@ -15,7 +18,7 @@ type MigrationInterface interface {
15
18
// Create generates an SQL command to create a table using the
16
19
// schema provided.
17
20
func Create (table string , schema Schema ) Migration {
18
- sql := parseColumns (loadColumnSQL (schema ))
21
+ sql := strings . Join (loadColumnSQL (schema ), ", " )
19
22
20
23
return Migration (fmt .Sprintf ("CREATE TABLE %s ( %s );" , table , sql ))
21
24
}
@@ -36,18 +39,3 @@ func loadColumnSQL(schema Schema) (commands []string) {
36
39
37
40
return
38
41
}
39
-
40
- // parseColumns implodes the slice of SQL commands into a
41
- // single string containing all the column definitions.
42
- func parseColumns (sql []string ) (formatted string ) {
43
- for i , command := range sql {
44
- formatted = formatted + command
45
- // If it is not the last column, add ", " after the
46
- // formatted string.
47
- if i != len (sql )- 1 {
48
- formatted = formatted + ", "
49
- }
50
- }
51
-
52
- return
53
- }
You can’t perform that action at this time.
0 commit comments