Improvement : ability to split DDL in the same file without triggering warnings
My workflow is generating SQL migration using Prisma.
When creating a new table with a foreign key, Prisma creates a table CREATE TABLE table_name (id UUID NOT NULL, foreign_id UUID NOT NULL) and then create another DDL in the same file ALTER TABLE table_name ADD CONSTRAINT "table_name_fkey" FOREIGN KEY ("foreign_id") REFERENCES "foreign_table" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
Prisma does this for a good reason, some databases do not support foreign key definition in the create table DDL.
I would like to be able to split those DDL when the config assume_in_transaction is set to true.
It seems that require-concurrent-index-creation is using this behavior.
Many thanks
Related to #220 apparently
This should be fixed in latest, can you double check it works for you?
https://play.squawkhq.com/#code/M4UwLgBMYIZiBbEA7MB9MBLJB7ArpALwQDkArMCQNwBQokANjgMYDWG2I+RpAjJbQBGIAOaZktAMIAlAKIBBACqyIi+QCEAMiswAzCMhyQQAD0zRgEWIIYg0yGEggAKTABMIAVU8BJACIQAHIA8opBnpqaADQQujgATiCYIsho7l6+ASFhgRGaAJS08prK0qoa2lYwNnYOTjTyfgGSwYEAyorS8j6BYQBE1rb2jna6rCAAnn0QNBAQAGLBcj4A4oEQANKyAJoufXGJyanuffkzc3LzsnKBkrJtEPsJSSkY1bbTzn0nZ7MQrRA-LJtMogsEIPJJIofK0-v91p4AAp+JQqEIQqEwwK0Zg4BAITBgKhAA
The following passes:
set statement_timeout = '5s';
set lock_timeout = '1s';
begin;
CREATE TABLE if not exists table_name (id UUID NOT NULL, foreign_id UUID NOT NULL);
ALTER TABLE table_name
ADD CONSTRAINT "table_name_fkey"
FOREIGN KEY ("foreign_id")
REFERENCES "foreign_table" ("id")
ON DELETE NO ACTION
ON UPDATE NO ACTION;
commit;