forked from coracle/caravel
20 lines
593 B
SQL
20 lines
593 B
SQL
CREATE UNIQUE INDEX IF NOT EXISTS tenant_stripe_customer_id_unique
|
|
ON tenant(stripe_customer_id)
|
|
WHERE stripe_customer_id <> '';
|
|
|
|
CREATE TRIGGER IF NOT EXISTS tenant_stripe_customer_id_not_empty_insert
|
|
BEFORE INSERT ON tenant
|
|
FOR EACH ROW
|
|
WHEN trim(NEW.stripe_customer_id) = ''
|
|
BEGIN
|
|
SELECT RAISE(ABORT, 'stripe_customer_id cannot be empty');
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS tenant_stripe_customer_id_not_empty_update
|
|
BEFORE UPDATE OF stripe_customer_id ON tenant
|
|
FOR EACH ROW
|
|
WHEN trim(NEW.stripe_customer_id) = ''
|
|
BEGIN
|
|
SELECT RAISE(ABORT, 'stripe_customer_id cannot be empty');
|
|
END;
|