# Pre & Post Migration Activities

This article describes the required validation steps to be performed before and after database migration. These steps ensure data consistency, integrity, and completeness by capturing key database metrics. The captured values serve as a baseline for comparison after migration.

### Prerequisites

Ensure the following conditions are met before proceeding:

* **Database Access:** Access to both source and target database environments
* **Permissions:** Required privileges to query information\_schema
* **SQL Tool:** Availability of a SQL client or query execution tool
* **Database Details:** Database name identified for validation

### Procedure

Execute the following scripts before and after the migration activity to validate consistency.

1. #### Capture Table Row Counts
   * Run the following SQL query to retrieve table row counts and sizes. Save the output for post-migration comparison.

     ```sql
     USE information_schema;
     SELECT 
         TABLE_NAME AS "Table Name", 
         TABLE_ROWS AS "Row Count", 
         ROUND((COALESCE(DATA_LENGTH, 0) + COALESCE(INDEX_LENGTH, 0)) / 1024 / 1024) AS 
     "Size (MB)"
     FROM tables
     WHERE table_schema = 'YOUR_DB_NAME'
     UNION ALL
     SELECT 
         "Total Count", 
         SUM(RowCount), 
         SUM(Size)
     FROM (
         SELECT 
             TABLE_NAME AS "Table Name", 
             TABLE_ROWS AS "RowCount", 
             ROUND((COALESCE(DATA_LENGTH, 0) + COALESCE(INDEX_LENGTH, 0)) / 1024 / 1024) 
     AS "Size"
         FROM tables
         WHERE table_schema = 'YOUR_DB_NAME'
     ) summary;
     Reference: All_Tables_RowCount.sql
     ```

2. #### Capture Database Size
   * Run the following SQL query to retrieve the total database size.

     ```sql
     SELECT 
         table_schema AS "Database Name", 
         ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS "DB Size (MB)"
     FROM information_schema.tables 
     GROUP BY table_schema;
     ```

3. #### Verify Table Collation
   * Verify that all tables use the utf8mb4\_0900\_ai\_ci collation. \
     **Check Collation:**

     ```sql
     SELECT 
         TABLE_SCHEMA, 
         TABLE_NAME, 
         TABLE_COLLATION 
     FROM information_schema.tables 
     WHERE TABLE_COLLATION != 'utf8mb4_0900_ai_ci';
     ```

***

Copyright © 2026, OvalEdge LLC, Peachtree Corners, GA, USA.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ovaledge.com/release8.1/deployment-and-maintenance/migration/pre-and-post-migration-activities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
