willbryant/kitchen_sync

Support multiple schemas in postgresql databases

Closed this issue · 4 comments

I haven't done anything in particular about these, so it's unlikely that they work well.

Unclear if anyone actually uses these (comments/feedback very welcome here).

Quick testing shows that if there are multiple schemas at the 'from' end, we will only see tables in those schemas listed in the user's search_path (which makes sense), and we will essentially ignore the schema.

So if the tables exist in the search_path at the 'to' end, it should work fine (assuming that the search_path again contains the same schema), but:

  • if a table of the same name exists in two schemas, that won't work (which is the behavior you expect if the schemas are both in search_path anyway)
  • if we need to create the table (using --alter) we won't specify the schema to create it in, so it'll get created in the first schema in search_path (typically public)

I have a use case with a MySQL db that I want to sync with specific schema in PostgreSQL db.

Example: mysqldb.table1 -> postgresqldb.schema1.table1

Is there a way to specify the schema for the destination?

@easeev I think for that case you should be able to use something like --set-to-variables="search_path=schema1"?

@willbryant yup, it works. Thanks!