Below function/procedure will create a csv file for each table in the database.
CREATE OR REPLACE FUNCTION db_to_csv(path TEXT) RETURNS void AS $$
FOR tables IN
SELECT (table_schema || '.' || table_name) AS schema_table
FROM information_schema.tables t INNER JOIN information_schema.schemata s
ON s.schema_name = t.table_schema
WHERE t.table_schema NOT IN ('pg_catalog', 'information_schema')
AND t.table_type NOT IN ('VIEW')
ORDER BY schema_table
statement := 'COPY ' || tables.schema_table || ' TO ''' || path || '/' || tables.schema_table || '.csv' ||''' DELIMITER '','' CSV HEADER';
$$ LANGUAGE plpgsql;
Simply run the select command which will create file in provided path. Remember to provide chmod 777 /your/path so that the folder is writable.
If you’re creating this inside a docker container use following command to copy it from container to host:
When there is a situation where you want to get only the changes or lines of code from some branch but not merge the whole branch, you can make use of cherry pick.
Lets say there was a bug in production and somebody in your team fixes that bug in there branch and commits it. You can cherry pick those lines of code (to be specific its all code from the last commit).
In below example: we are checkout in production branch and we are cherry picking the commit called “document and allocation export issue fixed” from KEY-1978 to production.