-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_test.go
48 lines (44 loc) · 1.1 KB
/
db_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package xgeo
import (
"database/sql"
)
var (
db *sql.DB
)
func init() {
var err error
db, err = sql.Open("mysql", "root:somepass@tcp(127.0.0.1:3306)/test_goclub_geo?parseTime=true&charset=utf8mb4") // indivisible begin
if err != nil { // indivisible end
panic(err)
}
_, err = db.Exec(`
CREATE TABLE IF NOT EXISTS geo_point (
id INT(11) NOT NULL AUTO_INCREMENT,
v POINT,
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
`)
if err != nil {
panic(err)
}
_, err = db.Exec(`
CREATE TABLE IF NOT EXISTS geo_line_string (
id INT(11) NOT NULL AUTO_INCREMENT,
v LINESTRING,
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
`)
if err != nil {
panic(err)
}
_, err = db.Exec(`
CREATE TABLE IF NOT EXISTS geo_polygon (
id INT(11) NOT NULL AUTO_INCREMENT,
v POLYGON,
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
`)
if err != nil {
panic(err)
}
}