Skip to content

Commit

Permalink
fix(sql): remove FUNCTION IF NOT EXIST clause
Browse files Browse the repository at this point in the history
Removes the "IF NOT EXIST" clause from the functions until we have an
opportunity to upgrade MySQL on SemaphoreCI.
  • Loading branch information
jniles committed May 12, 2022
1 parent 06fb5e1 commit ef163ff
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions server/models/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DELIMITER $$
Converts a hex uuid (36 chars) into a binary uuid (16 bytes)
*/
CREATE FUNCTION IF NOT EXISTS HUID(_uuid CHAR(36))
CREATE FUNCTION HUID(_uuid CHAR(36))
RETURNS BINARY(16) DETERMINISTIC
RETURN UNHEX(REPLACE(_uuid, '-', ''));
$$
Expand All @@ -21,7 +21,7 @@ $$
Converts a binary uuid (16 bytes) to dash-delimited hex UUID (36 characters).
*/
CREATE FUNCTION IF NOT EXISTS BUID(b BINARY(16))
CREATE FUNCTION BUID(b BINARY(16))
RETURNS CHAR(32) DETERMINISTIC
BEGIN
RETURN HEX(b);
Expand All @@ -42,7 +42,7 @@ $$
SET currentExchangeRate = GetExchangeRate(enterpriseId, currencyId, date);
SET currentExchangeRate = (SELECT IF(recordCurrencyId = enterpriseCurrencyId, 1, currentExchangeRate));
*/
CREATE FUNCTION IF NOT EXISTS GetExchangeRate(
CREATE FUNCTION GetExchangeRate(
enterpriseId INT,
currencyId INT,
date TIMESTAMP
Expand All @@ -60,7 +60,7 @@ END $$
/*
Sometime we need to get the exchange rate by the project id
*/
CREATE FUNCTION IF NOT EXISTS GetExchangeRateByProject(
CREATE FUNCTION GetExchangeRateByProject(
projectId INT,
currencyId INT,
date TIMESTAMP
Expand Down Expand Up @@ -88,7 +88,7 @@ END $$
SET transId = SELECT GenerateTransactionid(projectid);
*/
CREATE FUNCTION IF NOT EXISTS GenerateTransactionId(
CREATE FUNCTION GenerateTransactionId(
target_project_id SMALLINT(5)
)
RETURNS VARCHAR(100) DETERMINISTIC
Expand Down Expand Up @@ -122,7 +122,7 @@ END $$
Returns the number part of a transaction ID.
*/
CREATE FUNCTION IF NOT EXISTS GetTransactionNumberPart(
CREATE FUNCTION GetTransactionNumberPart(
trans_id TEXT,
project_id SMALLINT(5)
)
Expand All @@ -140,7 +140,7 @@ END $$
Returns the account type id of the given account number
*/
CREATE FUNCTION IF NOT EXISTS PredictAccountTypeId(accountNumber INT(11))
CREATE FUNCTION PredictAccountTypeId(accountNumber INT(11))
RETURNS MEDIUMINT(8) DETERMINISTIC
BEGIN
DECLARE oneDigit CHAR(1);
Expand Down Expand Up @@ -190,7 +190,7 @@ $$
function to emulate the PASSWORD function of MySQL 5, that is not available in MySQL 8
TODO: use better methods to store the password
*/
CREATE FUNCTION IF NOT EXISTS `MYSQL5_PASSWORD`(_pwd VARCHAR(40))
CREATE FUNCTION `MYSQL5_PASSWORD`(_pwd VARCHAR(40))
RETURNS VARCHAR(100) DETERMINISTIC
BEGIN
RETURN CONCAT('*', UPPER(SHA1(UNHEX(SHA1(_pwd)))));
Expand Down

0 comments on commit ef163ff

Please sign in to comment.