Skip to content

Instantly share code, notes, and snippets.

View eriknaslund's full-sized avatar

Erik Näslund eriknaslund

View GitHub Profile
-- This works on a normal postgres install, but on RDS it errors out with something similar too:
-- ERROR: permission denied: "RI_ConstraintTrigger_a_6654774" is a system trigger
-- It seems like rds_admin isn't admin enough...
ALTER TABLE accept_language DISABLE TRIGGER all;
-- This apparently disables all foreign keys for the current session.
-- Too bad we can't ask DMS to execute it before starting the migration.
SET session_replication_role = replica;
-- Luckily enough we can set the above thing using a so called "parameter group" in RDS.
SELECT max(pg_column_size(some_column)) / 1024.0
FROM some_table;
@eriknaslund
eriknaslund / pg_dump_and_restore.sh
Last active November 26, 2017 08:02
PG dump and restore
# Dump the database schema to the file schema.sql
pg_dump -h $SRC_SERVER_IP -d $DB_NAME -U $DB_USER -f dump.sql -W -s -v
# Restore the database schema into an empty database
psql -h $DST_SERVER_IP -d $DB_NAME -U $DB_USER -f dump.sql -W
aws dms create-replication-task \
--replication-task-identifier limited-lob \
--source-endpoint-arn $SRC_ENDPOINT_ARN \
--target-endpoint-arn $DST_ENDPOINT_ARN \
--replication-instance-arn $RPL_SERVER_ARN \
--migration-type full-load-and-cdc \
--table-mappings file://limited_lob_tables.json \
--replication-task-settings file://limited_lob_settings.json
{
"TableMappings": [
{
"Type": "Include",
"SourceSchema": "public",
"SourceTable": "%"
},
{
"Type": "Exclude",
"SourceSchema": "public",
{
"TargetMetadata": {
"TargetSchema": "",
"SupportLobs": true,
"FullLobMode": false,
"LobMaxSize": 8192,
"LimitedSizeLobMode": true,
"BatchApplyEnabled": false
},
"FullLoadSettings": {