From 667116c9b6714b7cbb62fd91cd77d071a45ba023 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Thu, 8 Dec 2022 10:00:52 +1100 Subject: [PATCH] feat(migrations): add additional indexes to bookings table --- src/migrations/0023_add_additional_indexes.cr | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/migrations/0023_add_additional_indexes.cr diff --git a/src/migrations/0023_add_additional_indexes.cr b/src/migrations/0023_add_additional_indexes.cr new file mode 100644 index 00000000..7f5e9be3 --- /dev/null +++ b/src/migrations/0023_add_additional_indexes.cr @@ -0,0 +1,17 @@ +class AddAdditionalIndexes + include Clear::Migration + + def change(dir) + dir.up do + execute("CREATE INDEX IF NOT EXISTS bookings_booking_start_end_idx ON bookings (booking_start, booking_end)") + execute("CREATE INDEX IF NOT EXISTS bookings_booking_user_id_idx ON bookings (user_id)") + execute("CREATE INDEX IF NOT EXISTS bookings_booking_email_digest_idx ON bookings (email_digest)") + end + + dir.down do + execute("DROP INDEX IF EXISTS bookings_booking_start_end_idx") + execute("DROP INDEX IF EXISTS bookings_booking_user_id_idx") + execute("DROP INDEX IF EXISTS bookings_booking_email_digest_idx") + end + end +end