File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ package main
22
33import (
44 "database/sql"
5- "log "
5+ "fmt "
66 "net"
77 "time"
88
9+ "github.com/charmbracelet/log"
910 "google.golang.org/grpc/reflection"
1011
1112 commonv1 "github.com/rtmelsov/adv-keeper/gen/go/proto/common/v1"
@@ -31,7 +32,9 @@ func main() {
3132 if err != nil {
3233 log .Fatal (err )
3334 }
34- helpers .RunMigrations (envs .DBDSN )
35+ path := fmt .Sprintf ("file:/%s" , envs .MigrationsFilesDir )
36+ log .Info ("path" , "path" , path )
37+ helpers .RunMigrations (envs .DBDSN , path )
3538 // Подключение к Postgres
3639 dbx , err := sql .Open ("pgx" , envs .DBDSN )
3740 if err != nil {
@@ -56,7 +59,7 @@ func main() {
5659
5760 reflection .Register (s )
5861
59- log .Println ("gRPC listening on" , lis .Addr ())
62+ log .Info ("gRPC listening on" , "add " , lis .Addr ())
6063 if err := s .Serve (lis ); err != nil {
6164 log .Fatal (err )
6265 }
Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ import (
88)
99
1010type Config struct {
11- Addr string `env:"AK_GRPC_ADDR,required"`
12- DBDSN string `env:"DB_DSN,required"`
13- JWTSecret string `env:"JWT_SECRET,required" json:"-"`
14- FilesDir string `env:"FILES_DIR" envDefault:"./files"`
15- AccessTTL string `env:"ACCESS_TTL" envDefault:"15m"`
16- DownloadFilesDir string `env:"DOWNLOAD_FILES_DIR" envDefault:"./opt/adv-keeper/download"`
11+ Addr string `env:"AK_GRPC_ADDR,required"`
12+ DBDSN string `env:"DB_DSN,required"`
13+ JWTSecret string `env:"JWT_SECRET,required" json:"-"`
14+ FilesDir string `env:"FILES_DIR"`
15+ AccessTTL string `env:"ACCESS_TTL"`
16+ DownloadFilesDir string `env:"DOWNLOAD_FILES_DIR"`
17+ MigrationsFilesDir string `env:"MIGRATIONS_FILES_DIR"`
1718}
1819
1920var (
Original file line number Diff line number Diff line change 77 "log"
88)
99
10- func RunMigrations (dsn string ) {
10+ func RunMigrations (dsn , filePath string ) {
1111 m , err := migrate .New (
12- "file://migrations" , // путь до миграций
12+ filePath ,
1313 dsn ,
1414 )
1515 if err != nil {
You can’t perform that action at this time.
0 commit comments