Примеры для pgloader

Типичный вариант запуска:

LOAD DATABASE
 FROM mysql://user:password@mysqlhost/us-redirector-production
 INTO postgresql://user:password@localhost/us-redirector-production

 WITH data only, truncate, reset sequences
 SET maintenance_work_mem to '128MB', work_mem to '12MB', search_path to 'public'

 BEFORE LOAD DO
 $$ ALTER TABLE "redirect_logs" DROP CONSTRAINT IF EXISTS "redirect_logs_link_uuid_foreign" CASCADE; $$,
 $$ ALTER SCHEMA "public" RENAME TO "us-redirector-production"; $$

 AFTER LOAD DO
 $$ ALTER SCHEMA "us-redirector-production" RENAME TO "public"; $$,
 $$ ALTER DATABASE "us-redirector-production" SET search_path TO "public"; $$,
 $$ ALTER TABLE "redirect_logs" ADD CONSTRAINT "redirect_logs_link_uuid_foreign" FOREIGN KEY (link_uuid) REFERENCES links(uuid) ON UPDATE CASCADE ON DELETE SET NULL; $$

 EXCLUDING TABLE NAMES MATCHING ~/telescope_/, 'jobs', 'failed_jobs', 'job_batches', 'jwt_public_keys', 'logs', 'redirect_logs'
;

В одном микросервисе в колонке ldap_data использовался какой-то binary тип, который после переезда стал нечитаемым (не помню почему). Пришлось обнулить:

 AFTER LOAD DO
 $$ ALTER SCHEMA "us-access-control-production" RENAME TO "public"; $$,
 $$ UPDATE "users" SET "ldap_data" = null; $$
Печать/экспорт