Creating PostgreSQL tables in Golang app with a dynamic name while using the golang-migrate library

Viewed 49

I am new to the golang-migrate/migrate library and started playing around with it.

I am interested in creating PostgreSql tables with dynamic names in my Golang app by using the migrate library and the .up.sql files with placeholders. Something like this:

CREATE TABLE IF NOT EXISTS ${my-variable-table-name}(

   id serial PRIMARY KEY,
   email VARCHAR (300) UNIQUE NOT NULL
);

I do know that I can create tables with dynamic names by using the database/sql package with the different Exec() methods as explained here and here. However, I was wondering if this can be accomplished with the migrate library functionality only, without explicitly using the database/sql methods.

I searched a lot for any piece of information but could not find anything.

Thanks in advance!

0 Answers
Related