slick-2.0cockroachdb

Wait for CockroachDB Command to Finish


I currently have a .sql file with the likes of:

DROP VIEW IF EXISTS vw_example;

CREATE VIEW vw_example as
SELECT a FROM b;

When running this command as part of a flyway migration, if the view already exists, it fails, as if the create command is not waiting for the DROP IF EXISTS to finish.

I know SQL server has a GO type keyword. Is there a way to sort of tell cockroachdb to wait for the first command?


Solution

  • As per the issue mentioned in the link, it is better to have the drop and create scripts in different migration files as flyway runs each migration in a single transaction.