-1

I cloned an existing repository (repository created by a team in my office which deals with subscriptions in a certain app we are working on) which have some database migration files inside the path ..\internal\db\migrations , this is migration files path. First of all i run the command docker compose up .for an existing docker.yaml , then i run the command go build then go run . .

I made a debug and the app reaches the point when it is about to run the migration file then it displays an error:

Failed to initialize App. Error: first D:\subscription-store: file does not exist

although I checked the paths through debugging and they are correct and at the same time the migration files all are exists.

I am using visual studio code as an editor, Go version 1.15 ,docker and MySQL. I am running on enviroment windows 10.

Laila
  • 549
  • 1
  • 13
  • 30
  • 1
    more info would be be helpful. You say " I cloned an existing repository", which repository? , You say "I made a search and had found that this is a common issue when running docker on windows", but you do no supply the links where you did find this info... – Luuk Dec 27 '20 at 13:56
  • I updated the question and posted the answer , i resolved it today – Laila Dec 28 '20 at 11:49

1 Answers1

0

After debugging and searching , it was found that the repository uses some paths to get the migration files from the local drive . the paths was written for Mac in the code base and i cloned the repository on a windows machine so it didn't work .

The error specifically happened in the call of the function

migrate.NewWithDatabaseInstance(
        fmt.Sprintf("file://%s", fullPath),
        "mysql",
        driver,
    )

The generated path for the first parameter was

file//d:\\subscription-store\\....\\db\\migrations

And this is wrong for windows as the driver d: shouldn't be supported in the path . it is resolved as following

"file:///"+"subscription-store\\....\\db\\migrations"

When the above URL sent to the function rather than the old one , it worked successfully.

Laila
  • 549
  • 1
  • 13
  • 30