Custom Statements
Hi I have a question
How do I do the following
I tried to check the custom statements , it seems I am missing some import perhaps Ash.DataLayer.Info
This message was copied from the ash-hq channel by user @sriky27
2 Replies
So you can use
custom_statements
for this, but you need to include a "down" for that migration. For example:
And for the extension, you can get a migration automatically generated for it by adding it to your repo's installed_extensions/0
callback
Few fixes I had to do for making it compile
custom_statements do
statement :overlapping_appointments do
up """
ALTER TABLE appointments
ADD CONSTRAINT overlapping_appointments
EXCLUDE USING GIST (
doctor_id WITH =,
tsrange("from", "until", '[)') WITH &&
) WHERE (NOT canceled);
"""
down """
ALTER TABLE appointments
DROP CONSTRAINT overlapping_appointments
"""
end
end
Thanks @Zach Daniel for the quick suggestion.