0

I'm using [golang-migrate][1] for Postgress migration from my Go application. Database is located on another machine from the Go app. I put my migrations into the folder on the Go machine and execute it:

m, err := migrate.New(
    "file://migrations/sql/",
    str,
)
m.Up()

In the migration I have a CSV file, which is located on the GO machine, I read it from the migration sql file like:

COPY product.foundation_import FROM 'migrations/data/b_v0.csv' DELIMITER ',' CSV HEADER;

Since file is located on my service machine, I receive an error:

could not open file "migrations/data/b_v0.csv" for reading: No such file or directory

Is it possible to "copy" from a local file while using "golang-migrate"?

Note: I seen a recommendation to use \copy of psql but I cannot put it in the sql migration file, or at least don't know how to. I receive error: unexpected symbol \

ilbets
  • 640
  • 1
  • 8
  • 30

0 Answers0