Updated on 2022-08-16 GMT+08:00

PostgreSQL->PostgreSQL

Operation Constraints

DRS has the following constraints on common operations in the case of migration failures caused by unpredictable errors or sudden environment changes.
Table 1 Operation constraints

Type

Constraint

Notes

  • Environment constraints in Table 2 must be complied with during the entire migration process.
  • 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.

Precautions

  • During the migration, do not modify or delete the usernames, passwords, permissions, or 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:
    refresh materialized view matviewname;
  • During a database-level migration, if the destination database user is not a superuser, the following objects created in the source database cannot be migrated due to insufficient permissions: EVENT TRIGGER, CAST with the WITHOUT FUNCTION parameter specified, and FUNCTION with the LEAKROOF or SUPPORT parameter specified.

Environment Constraints

  • Ensure that the environment configuration meets the following constraints. DRS automatically checks the following items and provides handling suggestions.
    Table 2 Environment constraints

    Type

    Constraint

    Database permissions

    • Full migration (minimum permissions):
      • The source database user must have the CONNECT permission for databases, the USAGE permission for schemas, the SELECT permission for tables, the SELECT and USAGE permissions for sequences, and the UPDATE, DELETE, and TRUNCATE permissions for tables without primary keys (only for locking tables without primary keys for a short period of time).
      • 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 objects: tables, indexes, foreign keys, stored procedures, functions, views, constraints, triggers, modes, sorting rules, code conversion information, data types, aggregate functions, operators, sequences, materialized views, statistical extensions, rules, event triggers, type conversion, conversion information, text search parsers, text search dictionaries, text search template, and text search configurations.
    • Supports the following field types: digit, currency, character, binary, date/time, Boolean, enumeration, geometry, network address, bit, text search, UUID, XML, JSON, array, compound, and range.
    • Plugins cannot be migrated. If the source contains plugins other than plpgsql, install the plugins in the destination in advance. The version of the plugins in the destination must be the same or newer than those in the source. If you can relocate the plugin to a schema in the destination database, specify the schema the same as that in the source database.
    • Temporary tables in the source database 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. For RDS PostgreSQL Enhanced Edition, the following schemas are not migrated: sys, utl_raw, dbms_lob, dbms_output, and dbms_random.

    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.
    • If the source database type is RDS PostgreSQL Enhanced Edition, the destination database type must be the same.
    • 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.