I'm creating a multi-tenant RoR app using PostgreSQL 9.3.5 running on linux (Ubuntu 14). I'd like to copy the data from my public schema to another schema.
I tried:
pg_dump -U my_username -h localhost --schema=public -d my_db -Fc -f db/my_dump.backup
pg_restore -U my_username -h localhost --schema=my_schema -d my_db -a db/my_dump.backup
It does not copy the data from the public schema. Any thoughts?
insert into my_schema.some_table select * from public.some_table
will work just as well. Or evencreate table my_schema.some_table as select * from public.some_table
. You can automate this using a stored function, or a script that generates the necessary SQL statements – a_horse_with_no_name Nov 18 '14 at 7:08pg_restore -l -f db/my_dump.backup
, you'll see that the objects are dumped, meaning that the restore step does not do what you expect from it. If you are doing this regularly, the best way (in my view) is to store the database object definitions under version control, then roll them out on demand to a new schema with a few lines of shell script. – dezso Nov 18 '14 at 9:28