mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
Postgres: Add path to schema_migrations insert statement (#49)
Since Postgres 9.6.8, at the top of the output of `pg_dump` it adds the line:
```sql
SELECT pg_catalog.set_config('search_path', '', false);
```
We must provide an absolute table reference to avoid errors when importing schema.sql.
This commit is contained in:
parent
4710a35da1
commit
7603e83f0e
2 changed files with 3 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ func postgresSchemaMigrationsDump(db *sql.DB) ([]byte, error) {
|
|||
buf.WriteString("\n--\n-- Dbmate schema migrations\n--\n\n")
|
||||
|
||||
if len(migrations) > 0 {
|
||||
buf.WriteString("INSERT INTO schema_migrations (version) VALUES\n (" +
|
||||
buf.WriteString("INSERT INTO public.schema_migrations (version) VALUES\n (" +
|
||||
strings.Join(migrations, "),\n (") +
|
||||
");\n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,14 +91,14 @@ func TestPostgresDumpSchema(t *testing.T) {
|
|||
// DumpSchema should return schema
|
||||
schema, err := drv.DumpSchema(u, db)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(schema), "CREATE TABLE schema_migrations")
|
||||
require.Contains(t, string(schema), "CREATE TABLE public.schema_migrations")
|
||||
require.Contains(t, string(schema), "\n--\n"+
|
||||
"-- PostgreSQL database dump complete\n"+
|
||||
"--\n\n\n"+
|
||||
"--\n"+
|
||||
"-- Dbmate schema migrations\n"+
|
||||
"--\n\n"+
|
||||
"INSERT INTO schema_migrations (version) VALUES\n"+
|
||||
"INSERT INTO public.schema_migrations (version) VALUES\n"+
|
||||
" ('abc1'),\n"+
|
||||
" ('abc2');\n")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue