mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
Add a "with foreign keys" option to the MySQL Command.
This commit is contained in:
parent
911c40dc2d
commit
450c06b6fb
@ -121,6 +121,8 @@
|
||||
(def-keyword-rule "tables")
|
||||
(def-keyword-rule "indexes")
|
||||
(def-keyword-rule "sequences")
|
||||
(def-keyword-rule "foreign")
|
||||
(def-keyword-rule "keys")
|
||||
(def-keyword-rule "downcase")
|
||||
(def-keyword-rule "quote")
|
||||
(def-keyword-rule "identifiers")
|
||||
@ -442,6 +444,9 @@
|
||||
(defrule option-reset-sequences (and kw-reset kw-sequences)
|
||||
(:constant (cons :reset-sequences t)))
|
||||
|
||||
(defrule option-foreign-keys (and kw-foreign kw-keys)
|
||||
(:constant (cons :foreign-keys t)))
|
||||
|
||||
(defrule option-identifiers-case (and (or kw-downcase kw-quote) kw-identifiers)
|
||||
(:lambda (id-case)
|
||||
(destructuring-bind (action id) id-case
|
||||
@ -455,6 +460,7 @@
|
||||
option-create-tables
|
||||
option-create-indexes
|
||||
option-reset-sequences
|
||||
option-foreign-keys
|
||||
option-identifiers-case))
|
||||
|
||||
(defrule another-mysql-option (and #\, ignore-whitespace mysql-option)
|
||||
|
@ -195,6 +195,7 @@
|
||||
include-drop
|
||||
create-indexes
|
||||
reset-sequences
|
||||
foreign-keys
|
||||
(identifier-case :downcase) ; or :quote
|
||||
only-tables
|
||||
including
|
||||
@ -236,8 +237,9 @@
|
||||
(with-pgsql-transaction (pg-dbname)
|
||||
;; we need to first drop the Foreign Key Constraints, so that we
|
||||
;; can DROP TABLE when asked
|
||||
(when include-drop
|
||||
(drop-fkeys all-fkeys :identifier-case identifier-case))
|
||||
(when (and foreign-keys include-drop)
|
||||
(drop-fkeys all-fkeys
|
||||
:identifier-case identifier-case))
|
||||
|
||||
;; now drop then create tables and types, etc
|
||||
(create-tables all-columns
|
||||
@ -299,10 +301,11 @@
|
||||
;; tables to be able to build the foreign keys, so wait until all tables
|
||||
;; and indexes are imported before doing that.
|
||||
;;
|
||||
(when foreign-keys
|
||||
(create-fkeys all-fkeys
|
||||
:dbname pg-dbname
|
||||
:state state-after
|
||||
:identifier-case identifier-case)
|
||||
:identifier-case identifier-case))
|
||||
|
||||
;; and report the total time spent on the operation
|
||||
(when summary
|
||||
|
@ -2,7 +2,7 @@ load database
|
||||
from mysql://root@localhost/sakila
|
||||
into postgresql://localhost:54393/sakila
|
||||
|
||||
WITH drop tables, create tables, create indexes, reset sequences
|
||||
WITH drop tables, create tables, create indexes, reset sequences, foreign keys
|
||||
|
||||
SET maintenance_work_mem to '128MB', work_mem to '12MB', search_path to 'sakila'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user