Reputation: 34423
I have an application which creates its tables as needed on format changes. When the tables do not pass a simple functionality test, they are dropped and created again. This has worked great so far, but now I have changed some constraints: I have changed a primary key and added a foreign key.
The drop now fails with exception:
org.h2.jdbc.JdbcSQLException: Constraint "PERSON_ID" not found; SQL statement:
alter table "GARDEN" drop constraint "PERSON_ID" [90057-178]
The drop statement is as follows:
alter table "GARDEN" drop constraint "PERSON_ID"
alter table "GARDEN" drop constraint "PRIMARY_KEY"
drop table "GARDEN"
The trouble is this drop statement would be valid for the desired table format, but is invalid for the format used before (which is the format of the table which was detected as unusuable and triggered the drop to be done).
How can I drop the tables with no regard to the constraints? (I am always dropping all tables which are related - therefore I do not need the constraint checking in this case)
Upvotes: 0
Views: 503
Reputation: 11270
If you tell Slick there are constraints then Slick will try to drop them when dropping the table. You can use plain SQL to explicitly run the SQL statements you need. You can also use Slick2's createModel
in the driver and check for constraints and that way conditionally do things.
Upvotes: 2
Reputation: 3180
I'm unfamiliar with the framework, but if the constraints should be on the new table and not the old one, you might need to change where the properties are being assigned. Having said that, check this question for details.
Upvotes: 0