mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 07:47:00 +02:00
Fix DROP TABLE statements on tables with foreign keys
This commit is contained in:
parent
817fc9a258
commit
49dcae8068
@ -1433,11 +1433,19 @@ The `database` command accepts the following clauses and options:
|
||||
|
||||
- *include drop*
|
||||
|
||||
When this option is listed, pgloader drop in the PostgreSQL
|
||||
connection all the table whose names have been found in the MySQL
|
||||
When this option is listed, pgloader drops all the tables in the
|
||||
target PostgreSQL database whose names appear in the SQLite
|
||||
database. This option allows for using the same command several
|
||||
times in a row until you figure out all the options, starting
|
||||
automatically from a clean environment.
|
||||
automatically from a clean environment. Please note that `CASCADE`
|
||||
is used to ensure that tables are dropped even if there are foreign
|
||||
keys pointing to them. This is precisely what `include drop` is
|
||||
intended to do: drop all target tables and recreate them.
|
||||
|
||||
Great care needs to be taken when using `include drop`, as
|
||||
it will cascade to *all* objects referencing the target tables,
|
||||
possibly including other tables that are not being loaded from
|
||||
the source DB.
|
||||
|
||||
- *include no drop*
|
||||
|
||||
@ -1857,11 +1865,19 @@ The `sqlite` command accepts the following clauses and options:
|
||||
|
||||
- *include drop*
|
||||
|
||||
When this option is listed, pgloader drop in the PostgreSQL
|
||||
connection all the table whose names have been found in the SQLite
|
||||
When this option is listed, pgloader drops all the tables in the
|
||||
target PostgreSQL database whose names appear in the SQLite
|
||||
database. This option allows for using the same command several
|
||||
times in a row until you figure out all the options, starting
|
||||
automatically from a clean environment.
|
||||
automatically from a clean environment. Please note that `CASCADE`
|
||||
is used to ensure that tables are dropped even if there are foreign
|
||||
keys pointing to them. This is precisely what `include drop` is
|
||||
intended to do: drop all target tables and recreate them.
|
||||
|
||||
Great care needs to be taken when using `include drop`, as
|
||||
it will cascade to *all* objects referencing the target tables,
|
||||
possibly including other tables that are not being loaded from
|
||||
the source DB.
|
||||
|
||||
- *include no drop*
|
||||
|
||||
|
@ -180,7 +180,7 @@
|
||||
(defun drop-table-if-exists-sql (table-name)
|
||||
"Return the PostgreSQL DROP TABLE IF EXISTS statement for TABLE-NAME."
|
||||
(let ((table-name (apply-identifier-case table-name)))
|
||||
(format nil "DROP TABLE IF EXISTS ~a;~%" table-name)))
|
||||
(format nil "DROP TABLE IF EXISTS ~a~% CASCADE;" table-name)))
|
||||
|
||||
(defun create-table-sql-list (all-columns
|
||||
&key
|
||||
|
Loading…
Reference in New Issue
Block a user