Hooks
When to use it
Section titled “When to use it”planreports views, routines, or data fixes you need to own- you want extension creation,
ANALYZE, cleanup SQL, or final view creation in-band with the migration
migration.toml
Section titled “migration.toml”schema = "app"on_schema_exists = "error"source_snapshot_mode = "none"unlogged_tables = falseclean_orphans = falsepreserve_defaults = trueadd_unsigned_checks = falsereplicate_on_update_current_timestamp = false
[source]type = "mysql"dsn = "root:root@tcp(127.0.0.1:3306)/source_db"
[target]dsn = "postgres://postgres:postgres@127.0.0.1:5432/target_db?sslmode=disable"
[type_mapping]tinyint1_as_boolean = falsebinary16_as_uuid = falsedatetime_as_timestamptz = falsejson_as_jsonb = trueenum_mode = "check"set_mode = "text"sanitize_json_null_bytes = trueunknown_as_text = false
[hooks]before_data = ["before_data.sql"]after_data = ["after_data.sql"]before_fk = ["before_fk.sql"]after_all = ["after_all.sql"]Hook SQL
Section titled “Hook SQL”-- before_data.sqlCREATE EXTENSION IF NOT EXISTS pgcrypto;-- after_data.sqlANALYZE {{schema}};-- before_fk.sql-- Put orphan cleanup statements here if needed.-- after_all.sql-- Put views/materialized views/validation queries here.Raw files: migration.toml, before_data.sql, after_data.sql, before_fk.sql, after_all.sql