mirror of https://github.com/status-im/migrate.git
Support the 'redshift' URL scheme
This brings the 'redshift2' package in alignment with the existing 'redshift' package.
This commit is contained in:
parent
3373343f23
commit
22334834ac
|
@ -94,6 +94,7 @@ func (p *Redshift) Open(url string) (database.Driver, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
purl.Scheme = "postgres"
|
||||
|
||||
db, err := sql.Open("postgres", migrate.FilterCustomQuery(purl).String())
|
||||
if err != nil {
|
||||
|
|
|
@ -25,8 +25,16 @@ var versions = []mt.Version{
|
|||
{Image: "postgres:9.3"},
|
||||
}
|
||||
|
||||
func redshiftConnectionString(host string, port uint) string {
|
||||
return connectionString("redshift", host, port)
|
||||
}
|
||||
|
||||
func pgConnectionString(host string, port uint) string {
|
||||
return fmt.Sprintf("postgres://postgres@%s:%v/postgres?sslmode=disable", host, port)
|
||||
return connectionString("postgres", host, port)
|
||||
}
|
||||
|
||||
func connectionString(schema, host string, port uint) string {
|
||||
return fmt.Sprintf("%s://postgres@%s:%v/postgres?sslmode=disable", schema, host, port)
|
||||
}
|
||||
|
||||
func isReady(i mt.Instance) bool {
|
||||
|
@ -52,7 +60,7 @@ func Test(t *testing.T) {
|
|||
mt.ParallelTest(t, versions, isReady,
|
||||
func(t *testing.T, i mt.Instance) {
|
||||
p := &Redshift{}
|
||||
addr := pgConnectionString(i.Host(), i.Port())
|
||||
addr := redshiftConnectionString(i.Host(), i.Port())
|
||||
d, err := p.Open(addr)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
@ -66,7 +74,7 @@ func TestMultiStatement(t *testing.T) {
|
|||
mt.ParallelTest(t, versions, isReady,
|
||||
func(t *testing.T, i mt.Instance) {
|
||||
p := &Redshift{}
|
||||
addr := pgConnectionString(i.Host(), i.Port())
|
||||
addr := redshiftConnectionString(i.Host(), i.Port())
|
||||
d, err := p.Open(addr)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
@ -91,7 +99,7 @@ func TestErrorParsing(t *testing.T) {
|
|||
mt.ParallelTest(t, versions, isReady,
|
||||
func(t *testing.T, i mt.Instance) {
|
||||
p := &Redshift{}
|
||||
addr := pgConnectionString(i.Host(), i.Port())
|
||||
addr := redshiftConnectionString(i.Host(), i.Port())
|
||||
d, err := p.Open(addr)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
@ -125,7 +133,7 @@ func TestWithSchema(t *testing.T) {
|
|||
mt.ParallelTest(t, versions, isReady,
|
||||
func(t *testing.T, i mt.Instance) {
|
||||
p := &Redshift{}
|
||||
addr := pgConnectionString(i.Host(), i.Port())
|
||||
addr := redshiftConnectionString(i.Host(), i.Port())
|
||||
d, err := p.Open(addr)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
|
Loading…
Reference in New Issue