mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 15:56:58 +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*
|
- *include drop*
|
||||||
|
|
||||||
When this option is listed, pgloader drop in the PostgreSQL
|
When this option is listed, pgloader drops all the tables in the
|
||||||
connection all the table whose names have been found in the MySQL
|
target PostgreSQL database whose names appear in the SQLite
|
||||||
database. This option allows for using the same command several
|
database. This option allows for using the same command several
|
||||||
times in a row until you figure out all the options, starting
|
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*
|
- *include no drop*
|
||||||
|
|
||||||
@ -1857,11 +1865,19 @@ The `sqlite` command accepts the following clauses and options:
|
|||||||
|
|
||||||
- *include drop*
|
- *include drop*
|
||||||
|
|
||||||
When this option is listed, pgloader drop in the PostgreSQL
|
When this option is listed, pgloader drops all the tables in the
|
||||||
connection all the table whose names have been found in the SQLite
|
target PostgreSQL database whose names appear in the SQLite
|
||||||
database. This option allows for using the same command several
|
database. This option allows for using the same command several
|
||||||
times in a row until you figure out all the options, starting
|
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*
|
- *include no drop*
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
(defun drop-table-if-exists-sql (table-name)
|
(defun drop-table-if-exists-sql (table-name)
|
||||||
"Return the PostgreSQL DROP TABLE IF EXISTS statement for TABLE-NAME."
|
"Return the PostgreSQL DROP TABLE IF EXISTS statement for TABLE-NAME."
|
||||||
(let ((table-name (apply-identifier-case 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
|
(defun create-table-sql-list (all-columns
|
||||||
&key
|
&key
|
||||||
|
Loading…
Reference in New Issue
Block a user