Hi This is with H2 1.3.172.
I am trying to import an existing MySQL database schema from a legacy project into an in-memory H2 instance, for unit-testing purposes. Unfortunately, the MySQL database schema is taken from a database dump, and the tables are not listed in dependency order vis-a-vis foreign key constraints. This causes errors when I try to load the schema - as constraints are sometimes declared before the parent table has been created. I had thought, from the documentation, that SET REFERENTIAL_INTEGRITY FALSE these constraints would not be checked, but it doesn't appear to work (at least when creating tables). Below is a simple example that shows the problem. Note that the second table, test_2, depends on the third table in the schema, test_1. Applying this script results in Table "TEST_1" not found; It would be great to have a workaround for this, as otherwise I need to manually massage the dump file to reorder the tables (and then maintain that massaged version forever). Thanks! Patrick SET REFERENTIAL_INTEGRITY FALSE; DROP TABLE IF EXISTS `test_3`; CREATE TABLE `test_3` ( `id` bigint(20) NOT NULL, PRIMARY KEY (`id`), ) ; DROP TABLE IF EXISTS `test_2`; CREATE TABLE `test_2` ( `id` bigint(20) NOT NULL, `test_1_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `FK_TEST_1_ID` FOREIGN KEY (`test_1_id`) REFERENCES `test_1` (`id`) ) ; DROP TABLE IF EXISTS `test_1`; CREATE TABLE `test_1` ( `id` bigint(20) NOT NULL, PRIMARY KEY (`id`) ) ; -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
