-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from SSchulze1989/develop
v 0.9.0
- Loading branch information
Showing
28 changed files
with
20,121 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet | ||
{ | ||
"name": "C# (.NET)", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/dotnet:0-6.0" | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [5000, 5001], | ||
// "portsAttributes": { | ||
// "5001": { | ||
// "protocol": "https" | ||
// } | ||
// } | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "dotnet restore", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/iRLeagueDatabaseCore/MigrationChangeBonusPointColumnTypeToJson.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions | ||
* instead of previous FilterConditionEntity | ||
*/ | ||
|
||
USE TestDatabase; | ||
|
||
SET autocommit=0; | ||
START TRANSACTION; | ||
|
||
-- Pre migration | ||
-- Create Temporary table holding the bonus points before changing column type | ||
CREATE TEMPORARY TABLE TmpBonusPoints ( | ||
LeagueId BIGINT NOT NULL, | ||
PointRuleId BIGINT NOT NULL PRIMARY KEY, | ||
BonusPoints TEXT | ||
); | ||
|
||
INSERT INTO TmpBonusPoints (LeagueId, PointRuleId, BonusPoints) | ||
SELECT LeagueId, PointRuleId, BonusPoints | ||
FROM PointRules; | ||
|
||
UPDATE PointRules | ||
SET BonusPoints='[]'; | ||
|
||
-- Post migration | ||
-- Create function to convert bonus values from single string into json array | ||
DELIMITER // | ||
|
||
DROP FUNCTION IF EXISTS splitStringToBonusPoints; | ||
|
||
CREATE FUNCTION splitStringToBonusPoints(inputString TEXT, | ||
pointDelimiter TEXT) | ||
RETURNS TEXT | ||
DETERMINISTIC | ||
BEGIN | ||
DECLARE bonusType TEXT; | ||
DECLARE bonusValue TEXT; | ||
DECLARE bonusPoints TEXT; | ||
SET bonusType = SUBSTRING_INDEX(inputString,pointDelimiter,1); | ||
SET bonusPoints = SUBSTRING(SUBSTRING_INDEX(inputString,pointDelimiter,2), LENGTH(bonusType)+2, 10); | ||
SET bonusValue = IF(LENGTH(bonusType)>1, SUBSTRING(bonusType, 2, 10), '0'); | ||
SET bonusType = SUBSTRING(bonusType, 1, 1); | ||
SET bonusType = CASE bonusType | ||
WHEN 'p' THEN '0' | ||
WHEN 'q' THEN '1' | ||
WHEN 'f' THEN '2' | ||
WHEN 'a' THEN '3' | ||
WHEN 'c' THEN '4' | ||
WHEN 'n' THEN '5' | ||
WHEN 'g' THEN '6' | ||
WHEN 'd' THEN '7' | ||
WHEN 'l' THEN '8' | ||
WHEN 'm' THEN '9' | ||
END; | ||
RETURN CONCAT('{"Type":',bonusType,',"Value":',bonusValue,',"Points":',bonusPoints,',"Conditions":[]}'); | ||
END; | ||
|
||
DROP FUNCTION IF EXISTS splitToArray; | ||
|
||
CREATE FUNCTION splitToArray( | ||
inputString TEXT, | ||
arrayDelimiter TEXT, | ||
pointDelimiter TEXT) | ||
RETURNS TEXT | ||
DETERMINISTIC | ||
BEGIN | ||
DECLARE tempString TEXT; | ||
SET tempString = '['; | ||
WHILE LOCATE(arrayDelimiter,inputString) > 1 DO | ||
SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ','); | ||
SET inputString = REGEXP_REPLACE(inputString, ( | ||
SELECT LEFT(inputString, LOCATE(arrayDelimiter, inputString)) | ||
),'',1,1); | ||
END WHILE; | ||
SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ']'); | ||
RETURN tempString; | ||
END; // | ||
|
||
DELIMITER ; | ||
|
||
-- Populate `Conditions` column with stored values and perform necessary value conversions | ||
UPDATE TmpBonusPoints | ||
SET BonusPoints = splitToArray(BonusPoints, ';', ':'); | ||
UPDATE PointRules AS pr | ||
JOIN TmpBonusPoints AS tmp | ||
ON tmp.PointRuleId=pr.PointRuleId | ||
SET pr.BonusPoints = tmp.BonusPoints | ||
WHERE tmp.BonusPoints IS NOT NULL; | ||
|
||
DROP TABLE TmpBonusPoints; | ||
DROP FUNCTION splitToArray; | ||
DROP FUNCTION splitStringToBonusPoints; | ||
|
||
ROLLBACK; |
20 changes: 20 additions & 0 deletions
20
src/iRLeagueDatabaseCore/MigrationFiltersForChampSeason.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions | ||
* instead of previous FilterConditionEntity | ||
*/ | ||
|
||
USE TestDatabase; | ||
|
||
START TRANSACTION; | ||
|
||
-- Populate `Conditions` column with stored values and perform necessary value conversions | ||
UPDATE FilterOptions AS f | ||
JOIN ResultConfigurations AS rc | ||
ON rc.ResultConfigId=f.ResultFilterResultConfigId | ||
JOIN ChampSeasons AS cs | ||
ON cs.ChampSeasonId=rc.ChampSeasonId | ||
JOIN Seasons AS s | ||
ON cs.SeasonId=s.SeasonId | ||
WHERE s.Finished=0 AND cs.IsActive | ||
SET f.ChampSeasonId = rc.ChampSeasonId, f.ResultFilterResultConfigId=NULL; | ||
|
||
ROLLBACK; |
38 changes: 38 additions & 0 deletions
38
src/iRLeagueDatabaseCore/MigrationMoveResultKindToChampSeasonTable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions | ||
* instead of previous FilterConditionEntity | ||
*/ | ||
|
||
USE TestDatabase; | ||
|
||
START TRANSACTION; | ||
|
||
DROP TABLE IF EXISTS TmpResultConfigKinds; | ||
|
||
CREATE TEMPORARY TABLE TmpResultConfigKinds( | ||
LeagueId BIGINT NOT NULL, | ||
ResultConfigId BIGINT NOT NULL, | ||
ChampSeasonId BIGINT NOT NULL, | ||
ResultKind VARCHAR(50) NOT NULL, | ||
PRIMARY KEY(LeagueId, ResultConfigId) | ||
); | ||
|
||
INSERT INTO TmpResultConfigKinds(LeagueId, ResultConfigId, ChampSeasonId, ResultKind) | ||
SELECT LeagueId, ResultConfigId, ChampSeasonId, ResultKind FROM ResultConfigurations; | ||
|
||
SELECT * FROM TmpResultConfigKinds; | ||
|
||
-- Populate `Conditions` column with stored values and perform necessary value conversions | ||
UPDATE ChampSeasons AS cs | ||
JOIN TmpResultConfigKinds as rc | ||
ON cs.ChampSeasonId=rc.ChampSeasonId | ||
SET cs.ResultKind=rc.ResultKind; | ||
|
||
UPDATE ChampSeasons | ||
SET ResultKind='Member' | ||
WHERE ResultKind=''; | ||
|
||
SELECT LeagueId, ChampSeasonId, ResultKind FROM ChampSeasons; | ||
|
||
DROP TABLE TmpResultConfigKinds; | ||
|
||
ROLLBACK; |
89 changes: 89 additions & 0 deletions
89
src/iRLeagueDatabaseCore/MigrationUseJsonFiltersOnResultConfig.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions | ||
* instead of previous FilterConditionEntity | ||
*/ | ||
|
||
USE TestDatabase; | ||
|
||
START TRANSACTION; | ||
|
||
-- Pre migration | ||
-- Create Temporary table holding the filter conditions before dropping table | ||
CREATE TEMPORARY TABLE TmpFilterConditions ( | ||
LeagueId BIGINT NOT NULL, | ||
ConditionId BIGINT NOT NULL, | ||
FilterOptionId BIGINT NOT NULL, | ||
FilterType LONGTEXT NOT NULL, | ||
ColumnPropertyName LONGTEXT NULL, | ||
Comparator LONGTEXT NOT NULL, | ||
`Action` LONGTEXT NOT NULL, | ||
FilterValues LONGTEXT NULL, | ||
PRIMARY KEY (LeagueId, ConditionId) | ||
); | ||
|
||
INSERT INTO TmpFilterConditions (LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues) | ||
SELECT LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues | ||
FROM FilterConditions; | ||
|
||
-- Post migration | ||
-- Create function to convert Filter values from single string into json array | ||
DELIMITER // | ||
|
||
DROP FUNCTION IF EXISTS splitStringToJsonArray; | ||
|
||
CREATE FUNCTION splitStringToJsonArray( | ||
inputString TEXT, | ||
delimiterChar CHAR(1)) | ||
RETURNS TEXT | ||
DETERMINISTIC | ||
BEGIN | ||
DECLARE temp_string TEXT; | ||
SET temp_string = '["'; | ||
WHILE LOCATE(delimiterChar,inputString) > 1 DO | ||
SET temp_string = CONCAT(temp_string, SUBSTRING_INDEX(inputString,delimiterChar,1), '","'); | ||
SET inputString = REGEXP_REPLACE(inputString, ( | ||
SELECT LEFT(inputString, LOCATE(delimiterChar, inputString)) | ||
),'',1,1); | ||
END WHILE; | ||
SET temp_string = CONCAT(temp_string, inputString, '"]'); | ||
RETURN temp_string; | ||
END; // | ||
|
||
DELIMITER ; | ||
|
||
-- Populate `Conditions` column with stored values and perform necessary value conversions | ||
UPDATE FilterOptions AS f | ||
JOIN (SELECT FilterOptionId, | ||
CASE FilterType | ||
WHEN 'ColumnProperty' THEN 0 | ||
WHEN 'Member' THEN 1 | ||
WHEN 'Team' THEN 2 | ||
END AS FilterType, | ||
ColumnPropertyName, | ||
CASE Comparator | ||
WHEN 'IsSmaller' THEN 0 | ||
WHEN 'IsSmallerOrEqual' THEN 1 | ||
WHEN 'IsEqual' THEN 2 | ||
WHEN 'IsBiggerOrEqual' THEN 3 | ||
WHEN 'IsBigger' THEN 4 | ||
WHEN 'NotEqual' THEN 5 | ||
WHEN 'InList' THEN 6 | ||
WHEN 'ForEach' THEN 7 | ||
END AS Comparator, | ||
CASE `Action` | ||
WHEN 'Keep' THEN 0 | ||
WHEN 'Remove' THEN 1 | ||
END AS `Action`, | ||
FilterValues | ||
FROM TmpFilterConditions) AS fc | ||
ON fc.FilterOptionId = f.FilterOptionId | ||
SET f.Conditions = CONCAT( | ||
'[{"Action": ', fc.`Action`, | ||
', "Comparator": ', fc.Comparator, | ||
', "FilterType": ', fc.FilterType, | ||
', "FilterValues": ', splitStringToJsonArray(fc.FilterValues, ';'), | ||
', "ColumnPropertyName": "', fc.ColumnPropertyName, '"}]'); | ||
|
||
DROP TABLE TmpFilterConditions; | ||
DROP FUNCTION splitStringToJsonArray; | ||
|
||
ROLLBACK; |
Oops, something went wrong.