I want to import database dump to new database that does not have all columns that old database had.
So, to ignore/remove those columns, my idea is to edit dump.sql.
How can I read and edit sql file in ruby?
Dump created:
pg_dump --data-only old_database > dump_data_12_3_2019.sql;
Using:
- PostgreSQL 9.5
- Ruby 2.5.1
Inside sql file:
COPY public.images (id, file, created_at, updated_at, rotation) FROM stdin;
255 31265d7843.JPG 2018-11-15 09:05:43.37898 2018-11-15 09:05:43.37898 0
256 78e834e4e7.JPG 2018-11-15 09:05:43.571389 2018-11-15 09:05:43.571389 0
257 7b6662659b.JPG 2018-11-15 09:05:44.275989 2018-11-15 09:05:44.275989 0
215 6fe307f4b5.jpg 2018-10-15 11:08:59.42583 2018-10-15 11:12:25.284024 0
Header is starting with COPY, column names are inside ( )
and data is below with space for separator.
How can I remove column rotation and his data?