opened
sandust
username_0
Is pgsync supposed to sync functions created on the database been synced? If so then is not working.
Does pgsync syncs functions?
issue
created
ankane
username_1
PgSync only syncs data by default.
comment
closed
ankane
username_1
issue
created
sandust
username_0
Any plans to include functions on migrations? even the --schema-only or --schema-first options won't copy the functions in the schema.
comment
created
ankane
username_1
On the master branch, if you include `--all-schemas` with either option, they should sync.
comment
created
ykostsik
username_2
It doesn't work actually.
comment
created
ykostsik
username_2
I'm not sure anyone read it but let me add my investigation steps here.
Looks like pgsync is able to sync functions (and it's expected because pg_dump does) but it works only when we use 'postgres' db name for connection. For others pgsync creates much more complicated pg_dump request and skips some data.
```
cat .pgsync.yml | grep -E 'from:|to:'
from: postgres://postgres:pwd123@172.17.0.2:5432/postgres
to: postgres://postgres:pwd123@172.17.0.3:5432/postgres
```
And run pgsync --schema-only. ps -ef says:
```
sh -c pg_dump -Fc --verbose --schema-only --no-owner --no-acl  -d postgres://postgres:pwd123@172.17.0.2:5432/postgres | pg_restore --verbose --no-owner --no-acl --clean --if-exists -d postgres://postgres:pwd123@172.17.0.3:5432/postgres
```
Logs:
```
pg_restore: dropping TABLE tab1
pg_restore: dropping TABLE tab2
pg_restore: dropping FUNCTION sum1(integer, integer)
pg_restore: dropping FUNCTION add(integer, integer)
pg_restore: dropping SCHEMA test
pg_restore: creating FUNCTION "public.add(integer, integer)"
pg_restore: creating FUNCTION "test.sum1(integer, integer)"
pg_restore: creating TABLE "public.tab2"
pg_restore: creating TABLE "test.tab1"
WARNING: errors ignored on restore: 3
Completed in 0.3s
```

Next, I tried to sync one more db -  products.
```
cat .pgsync.yml | grep -E 'from:|to:'
from: postgres://postgres:pwd123@172.17.0.2:5432/products
to: postgres://postgres:pwd123@172.17.0.3:5432/products
```
and ran the same
Now the process looks like
`sh -c pg_dump -Fc --verbose --schema-only --no-owner --no-acl -t \"products\".\"my_tab1\" -t \"products\".\"my_tab2\" -t  <....cut...> -d postgres://postgres:pwd123@172.17.0.2:5432/products | pg_restore --verbose --no-owner --no-acl --clean --if-exists -d postgres://postgres:pwd123@172.17.0.3:5432/products
`

After adding `-t` option into pg_dump it didn't include functions in products db into new dump. 
I'm posting this one here, because I granted all possible privileges to the products db, but with no effect. I'm not an expert in Ruby, but probably it was hard-coded in some way and it's possible to easy change it. `--all-schemas` doesn't work too.
sorry for my mistakes.
comment