Before creating a migration task, read the following precautions:
Table 2 Precautions
Type
Restrictions
Database permissions
Full migration (minimum permissions):
The source database user must have the CONNECT permission for the database, the USAGE permission for schemas, the SELECT permission for tables, and the SELECT permission for sequences. If user synchronization is required, the CREATEROLE permission is required.
During a database-level migration, the destination database account must have the CREATEDB permission.
During table-level migration, if the database does not exist, the destination database account must have the CREATEDB permission. If the database exists, the destination database account must have the CREATE and CONNECT permissions. If a schema exists, the CREATE and USAGE permissions are required.
Migration objects
Supported migration objects: tables, indexes, foreign keys, stored procedures, functions (excluding C functions and functions with LEAKPROOF or SUPPORT attributes), views, constraints, triggers, schemas, plug-ins, sorting rules, code conversion information, data types (excluding basic types), aggregate functions, operators, sequences, materialized views, statistics extensions, rules, event triggers (only PostgreSQL 11.11 and later versions of destination databases), type conversion (excluding forcible binary type conversion), conversion information, text search configurations, and text search dictionaries, text search parser (only PostgreSQL 11.11 and later versions of destination databases) and text search template (only PostgreSQL 11.11 and later versions of destination databases)
Tablespaces, external data wrappers, external servers, user mappings, releases, subscriptions, and other unsupported objects cannot be migrated.
Supported field types: digit, currency, character, binary, date/time, Boolean, enumeration, geometry, network address, bit, text search, UUID, XML, JSON, array, compound, and range.
Only extension objects can be migrated. The version of the extension object created in the destination database is the default version. If new extension metadata is generated to the source database, use the syntax of the extension to rebuild the metadata after the migration is complete.
Temporary tables in the source database cannot be migrated.
Tables whose names end with spaces cannot be migrated.
Data cannot be migrated from the database of a later major version to the database of an earlier major version.
System schemas that are not migrated include: schemas starting with pg_ and information_schema.
Source database
The source database name cannot contain the following characters: + % "\ '>< . The schema name and table name cannot contain double quotation marks (") and periods (.).
The trigger name in the source database must be unique.
The block_size value of the source database cannot be greater than that of the destination database.
The source database version cannot be earlier than PostgreSQL 9.4.
To ensure the security of the source database connection, set the ssl parameter of the source database to on and ensure that the source database uses the password authentication mode. To change the authentication mode, add host all <src_user_name> <drs_instance_ip>/32 md5 to the first line of all configurations in the pg_hba.conf file of the source database, and then run the select pg_reload_conf(); statement as the superuser in the source database or restart the DB instance for the change to take effect.
Destination database
The destination database version cannot be older than the source database version.
The destination DB instance is running properly.
During a database-level migration, if the source does not contain plugins other than plpgsql, the destination cannot contain databases with the same name as the source databases to be migrated. If a plugin other than plpgsql is installed in the source database, ensure that only the plugin is installed in the destination database and no other self-built objects are created.
During a table-level migration, the destination database cannot contain objects with the same names as the objects to be migrated in the source database.
The destination DB instance must have sufficient storage space.
The lc_monetary values of the source and destination databases must be the same.
The block_size value of the destination database must be greater than that of the source database.
Precautions
A migration task can migrate data of only one database. If multiple databases in a PostgreSQL instance need to be migrated, create a real-time migration task for each database.
Table-level migration refers to the migration of tables, views, materialized views, and sequences. The constraints, indexes, and rules created for tables are migrated together with the tables. Triggers are not migrated. Objects that have dependencies must be migrated at the same time or created in the destination in advance to avoid migration failure. Common dependencies: tables referenced by views, views referenced by views, tables referenced by primary and foreign keys, parent tables referenced by child tables, partitioned tables referenced by sub-partitioned tables, and sequences referenced by auto-increment columns.
During the migration, do not modify or delete the usernames, passwords, and permissions of the source and destination databases or change the ports of the source and destination databases.
During the migration, do not write data to the destination database. Otherwise, data will be inconsistent.
During a full migration, ongoing changes made to the source database cannot be fully synchronized to the destination database. Ensure that no change is made to the source database during the full migration. Otherwise, data inconsistency may occur.
During task startup or full migration, do not perform DDL operations on the source database, such as deleting or adding tables. Otherwise, the migration fails.
After the full migration of materialized views, if the destination database needs to use the materialized views, run the following statement to update the views: