-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.yml
78 lines (74 loc) · 2.17 KB
/
config.yml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
repositories:
fiber: https://github.com/TejasGhatte/fiber-base-template.git
echo: https://github.com/TejasGhatte/echo-basic-template.git
gin: https://github.com/TejasGhatte/gin-basic-template.git
databases:
postgres:
name: postgres
driverPkg: github.com/lib/pq
mysql:
name: mysql
driverPkg: github.com/go-sql-driver/mysql
sqlite:
name: sqlite3
driverPkg: github.com/mattn/go-sqlite3
orms:
gorm:
name: gorm
importPath: gorm.io/gorm
sqlx:
name: sqlx
importPath: github.com/jmoiron/sqlx
combinations:
postgres:
gorm:
dsnTemplate: "host=localhost user=%s password=%s dbname=%s port=5432 sslmode=disable"
initFunc: "gorm.Open(postgres.Open(dsn), &gorm.Config{})"
additionalImports:
- gorm.io/driver/postgres
sqlx:
dsnTemplate: "user=%s password=%s dbname=%s sslmode=disable"
initFunc: "sqlx.Connect"
mysql:
gorm:
dsnTemplate: "%s:%s@tcp(localhost:3306)/%s?parseTime=true"
initFunc: "gorm.Open(mysql.Open, &gorm.Config{})(dsn)"
additionalImports:
- gorm.io/driver/mysql
sqlx:
dsnTemplate: "%s:%s@tcp(localhost:3306)/%s?parseTime=true"
initFunc: "sqlx.Connect(\"mysql\", dsn)"
sqlite:
gorm:
dsnTemplate: ""
initFunc: ""
additionalImports:
-
sqlx:
dsnTemplate: ""
initFunc: ""
migrationCode:
gorm: |
err := DB.AutoMigrate(
// Add your models here
// &models.User{},
// &models.Post{},
)
if err != nil {
return fmt.Errorf("failed to run migrations: %w", err)
}
sqlx: |
migrations := []string{
// Add your migration SQL here
// "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);",
// "CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY, title TEXT, content TEXT, user_id INTEGER);",
}
fmt.Println("Running migrations")
for _, migration := range migrations {
_, err := DB.Exec(migration)
if err != nil {
fmt.Errorf("failed to run migrations: %w", err)
}
}
default: |
fmt.Println("No specific migration logic for this ORM. Implement custom migration logic here.")