diff --git a/pgloader.1.md b/pgloader.1.md index e0b380a..773f88f 100644 --- a/pgloader.1.md +++ b/pgloader.1.md @@ -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* diff --git a/src/pgsql/schema.lisp b/src/pgsql/schema.lisp index 4e5755c..03196d5 100644 --- a/src/pgsql/schema.lisp +++ b/src/pgsql/schema.lisp @@ -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