You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/dms/tutorial-azure-postgresql-to-azure-postgresql-online-portal.md
+3-54Lines changed: 3 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,60 +100,9 @@ To complete all the database objects like table schemas, indexes and stored proc
100
100
```
101
101
psql -h mypgserver-source.postgres.database.azure.com -U pguser@mypgserver-source -d dvdrental citus < dvdrentalSchema.sql
102
102
```
103
-
104
-
4. To extract the drop foreign key script and add it at the destination (Azure Database for PostgreSQL), in PgAdmin or in psql, run the following script.
105
-
106
-
> [!IMPORTANT]
107
-
> Foreign keys in your schema will cause the initial load and continuous sync of the migration to fail.
108
-
109
-
```
110
-
SELECT Q.table_name
111
-
,CONCAT('ALTER TABLE ','"', table_schema,'"', '.','"', table_name ,'"', STRING_AGG(DISTINCT CONCAT(' DROP CONSTRAINT ','"', foreignkey,'"'), ','), ';') as DropQuery
STRING_AGG(DISTINCT S.column_name, ',') AS column_name,
119
-
S.foreign_table_schema,
120
-
S.foreign_table_name,
121
-
STRING_AGG(DISTINCT S.foreign_column_name, ',') AS foreign_column_name,
122
-
S.update_rule,
123
-
S.delete_rule
124
-
FROM
125
-
(SELECT DISTINCT
126
-
tc.table_schema,
127
-
tc.constraint_name AS foreignkey,
128
-
tc.table_name,
129
-
kcu.column_name,
130
-
ccu.table_schema AS foreign_table_schema,
131
-
ccu.table_name AS foreign_table_name,
132
-
ccu.column_name AS foreign_column_name,
133
-
rc.update_rule AS update_rule,
134
-
rc.delete_rule AS delete_rule
135
-
FROM information_schema.table_constraints AS tc
136
-
JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name AND tc.table_schema = kcu.table_schema
137
-
JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name AND ccu.table_schema = tc.table_schema
138
-
JOIN information_schema.referential_constraints as rc ON rc.constraint_name = tc.constraint_name AND rc.constraint_schema = tc.table_schema
139
-
WHERE constraint_type = 'FOREIGN KEY'
140
-
) S
141
-
GROUP BY S.table_schema, S.foreignkey, S.table_name, S.foreign_table_schema, S.foreign_table_name,S.update_rule,S.delete_rule
142
-
) Q
143
-
GROUP BY Q.table_schema, Q.table_name;
144
-
```
145
-
146
-
5. Run the drop foreign key (which is the second column) in the query result.
147
-
148
-
6. To disable triggers in target database, run the script below.
149
-
150
-
> [!IMPORTANT]
151
-
> Triggers (insert or update) in the data enforce data integrity in the target ahead of the data being replicated from the source. As a result, it's recommended that you disable triggers in all the tables **at the target** during migration, and then re-enable the triggers after migration is complete.
> The migration service internally handles the enable/disable of foreign keys and triggers to ensure a reliable and robust data migration. As a result, you do not have to worry about making any modifications to the target database schema.
0 commit comments