Skip to content

Commit 1ea99b4

Browse files
committed
shau update
1 parent e10dadc commit 1ea99b4

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

articles/dms/tutorial-postgresql-azure-postgresql-online.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.service: dms
1010
ms.workload: data-services
1111
ms.custom: mvc, tutorial
1212
ms.topic: article
13-
ms.date: 05/08/2019
13+
ms.date: 06/28/2019
1414
---
1515

1616
# Tutorial: Migrate PostgreSQL to Azure Database for PostgreSQL online using DMS
@@ -19,6 +19,7 @@ You can use Azure Database Migration Service to migrate the databases from an on
1919

2020
In this tutorial, you learn how to:
2121
> [!div class="checklist"]
22+
>
2223
> * Migrate the sample schema using pg_dump utility.
2324
> * Create an instance of the Azure Database Migration Service.
2425
> * Create a migration project by using the Azure Database Migration Service.
@@ -60,21 +61,21 @@ To complete this tutorial, you need to:
6061
* Create a server-level [firewall rule](https://docs.microsoft.com/azure/sql-database/sql-database-firewall-configure) for Azure Database for PostgreSQL to allow Azure Database Migration Service to access to the target databases. Provide the subnet range of the VNet used for Azure Database Migration Service.
6162
* There are two methods for invoking the CLI:
6263

63-
* In the upper-right corner of the Azure postal, select the Cloud Shell button:
64+
* In the upper-right corner of the Azure postal, select the Cloud Shell button:
6465

6566
![Cloud Shell button in the Azure portal](media/tutorial-postgresql-to-azure-postgresql-online/cloud-shell-button.png)
6667

67-
* Install and run the CLI locally. CLI 2.0 is the command-line tool for managing Azure resources.
68+
* Install and run the CLI locally. CLI 2.0 is the command-line tool for managing Azure resources.
6869

6970
To download the CLI, follow the instructions in the article [Install Azure CLI 2.0](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest). The article also lists the platforms that support CLI 2.0.
7071

7172
To set up Windows Subsystem for Linux (WSL), follow the instructions in the [Windows 10 Installation Guide](https://docs.microsoft.com/windows/wsl/install-win10)
7273

7374
* Enable logical replication in the postgresql.config file, and set the following parameters:
7475

75-
* wal_level = **logical**
76-
* max_replication_slots = [number of slots], recommend setting to **5 slots**
77-
* max_wal_senders =[number of concurrent tasks] - The max_wal_senders parameter sets the number of concurrent tasks that can run, recommend setting to **10 tasks**
76+
* wal_level = **logical**
77+
* max_replication_slots = [number of slots], recommend setting to **5 slots**
78+
* max_wal_senders =[number of concurrent tasks] - The max_wal_senders parameter sets the number of concurrent tasks that can run, recommend setting to **10 tasks**
7879

7980
## Migrate the sample schema
8081

@@ -110,11 +111,10 @@ To complete all the database objects like table schemas, indexes and stored proc
110111
```
111112
112113
4. If you have foreign keys in your schema, the initial load and continuous sync of the migration will fail. Execute the following script in PgAdmin or in psql to extract the drop foreign key script and add foreign key script at the destination (Azure Database for PostgreSQL).
113-
114-
114+
115115
```
116116
SELECT Queries.tablename
117-
,concat('alter table ', Queries.tablename, ' ', STRING_AGG(concat('DROP CONSTRAINT ', Queries.foreignkey), ',')) as DropQuery
117+
,concat('alter table ', Queries.tableland, ' ', STRING_AGG(concat('DROP CONSTRAINT ', Queries.foreignkey), ',')) as DropQuery
118118
,concat('alter table ', Queries.tablename, ' ',
119119
STRING_AGG(concat('ADD CONSTRAINT ', Queries.foreignkey, ' FOREIGN KEY (', column_name, ')', 'REFERENCES ', foreign_table_name, '(', foreign_column_name, ')' ), ',')) as AddQuery
120120
FROM
@@ -136,7 +136,7 @@ To complete all the database objects like table schemas, indexes and stored proc
136136
AND ccu.table_schema = tc.table_schema
137137
WHERE constraint_type = 'FOREIGN KEY') Queries
138138
GROUP BY Queries.tablename;
139-
```
139+
```
140140
141141
Run the drop foreign key (which is the second column) in the query result.
142142

articles/dms/tutorial-rds-postgresql-server-azure-db-for-postgresql-online.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.service: dms
1010
ms.workload: data-services
1111
ms.custom: mvc, tutorial
1212
ms.topic: article
13-
ms.date: 05/08/2019
13+
ms.date: 06/28/2019
1414
---
1515

1616
# Tutorial: Migrate RDS PostgreSQL to Azure Database for PostgreSQL online using DMS
@@ -99,23 +99,31 @@ To complete this tutorial, you need to:
9999
```
100100
101101
4. If you have foreign keys in your schema, the initial load and continuous sync of the migration will fail. To extract the drop foreign key script and add foreign key script at the destination (Azure Database for PostgreSQL), run the following script in PgAdmin or in psql:
102-
102+
103103
```
104-
SET group_concat_max_len = 8192;
105-
SELECT SchemaName, GROUP_CONCAT(DropQuery SEPARATOR ';\n') as DropQuery, GROUP_CONCAT(AddQuery SEPARATOR ';\n') as AddQuery
104+
SELECT Queries.tablename
105+
,concat('alter table ', Queries.tableland, ' ', STRING_AGG(concat('DROP CONSTRAINT ', Queries.foreignkey), ',')) as DropQuery
106+
,concat('alter table ', Queries.tablename, ' ',
107+
STRING_AGG(concat('ADD CONSTRAINT ', Queries.foreignkey, ' FOREIGN KEY (', column_name, ')', 'REFERENCES ', foreign_table_name, '(', foreign_column_name, ')' ), ',')) as AddQuery
106108
FROM
107109
(SELECT
108-
KCU.REFERENCED_TABLE_SCHEMA as SchemaName,
109-
KCU.TABLE_NAME,
110-
KCU.COLUMN_NAME,
111-
CONCAT('ALTER TABLE ', KCU.TABLE_NAME, ' DROP FOREIGN KEY ', KCU.CONSTRAINT_NAME) AS DropQuery,
112-
CONCAT('ALTER TABLE ', KCU.TABLE_NAME, ' ADD CONSTRAINT ', KCU.CONSTRAINT_NAME, ' FOREIGN KEY (`', KCU.COLUMN_NAME, '`) REFERENCES `', KCU.REFERENCED_TABLE_NAME, '` (`', KCU.REFERENCED_COLUMN_NAME, '`) ON UPDATE ',RC.UPDATE_RULE, ' ON DELETE ',RC.DELETE_RULE) AS AddQuery
113-
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU, information_schema.REFERENTIAL_CONSTRAINTS RC
114-
WHERE
115-
KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME
116-
AND KCU.REFERENCED_TABLE_SCHEMA = RC.UNIQUE_CONSTRAINT_SCHEMA
117-
AND KCU.REFERENCED_TABLE_SCHEMA = 'sakila') Queries
118-
GROUP BY SchemaName;
110+
tc.table_schema,
111+
tc.constraint_name as foreignkey,
112+
tc.table_name as tableName,
113+
kcu.column_name,
114+
ccu.table_schema AS foreign_table_schema,
115+
ccu.table_name AS foreign_table_name,
116+
ccu.column_name AS foreign_column_name
117+
FROM
118+
information_schema.table_constraints AS tc
119+
JOIN information_schema.key_column_usage AS kcu
120+
ON tc.constraint_name = kcu.constraint_name
121+
AND tc.table_schema = kcu.table_schema
122+
JOIN information_schema.constraint_column_usage AS ccu
123+
ON ccu.constraint_name = tc.constraint_name
124+
AND ccu.table_schema = tc.table_schema
125+
WHERE constraint_type = 'FOREIGN KEY') Queries
126+
GROUP BY Queries.tablename;
119127
```
120128
121129
5. Run the drop foreign key (which is the second column) in the query result to drop the foreign key.

0 commit comments

Comments
 (0)