Skip to content

Instantly share code, notes, and snippets.

@lippserd
lippserd / migration-procedures.sql
Created November 17, 2016 13:14
Helper functions and procedures for idempotent schema migrations to support if (not) exists functionality for creating and dropping indices and columns.
# Helper functions and procedures for idempotent schema migrations
# Provides if (not) exists functionality for creating and dropping indices and columns
DELIMITER //
DROP FUNCTION IF EXISTS m_index_exists //
CREATE FUNCTION m_index_exists(
f_table_name varchar(64),
f_index_name varchar(64)
)
RETURNS BOOL