Domanda

I use in Windows 7 IntelliJ IDEA 12, JDK 7, MyBatis, Spring 3 in order to create REST web application (Maven project with flyway-maven-plugin). I use Flyway in order to cope with sql migrations. Now I need to load some files to PostgreSQL 9.2 database. I've found this thread: https://dba.stackexchange.com/questions/1742/how-to-insert-file-data-into-a-postgresql-bytea-column

I'd like to use bytea_import from that thread. This custom function requires path to the uploaded file (it is in resources folder). How can I correctly set relative path to such file? What is considered as a current folder during migrations?

È stato utile?

Soluzione 2

You can use Java-based migrations. If you still want to use SQL-based migrations, then use Flyway placeholders. Save required path in placeholder using *.pom properties. Example:

<flyway.placeholders.rtfPath>${project.build.outputDirectory}/rtf</flyway.placeholders.rtfPath>

Then use rtfPath in your SQL migration file in order to generate the full path to your uploaded file.

Altri suggerimenti

Not sure about bytea_import (if you get it working, let me know!), but you should be able to achieve this easily using Java-based migrations.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top