Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): use tenant_id for sequence creation (#3519)
--------- Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
- Loading branch information
1 parent
dc5f609
commit 2ec83f8
Showing
5 changed files
with
51 additions
and
16 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,22 @@ | ||
DO $$ | ||
DECLARE | ||
temprow record; | ||
BEGIN | ||
FOR temprow IN | ||
SELECT max(id)+1 AS next_value, test_id, tenant_id | ||
FROM test_runs | ||
GROUP BY test_id, tenant_id | ||
LOOP | ||
EXECUTE format('CREATE SEQUENCE IF NOT EXISTS runs_test_%s_seq START WITH %s', | ||
MD5(FORMAT('%s%s', temprow.test_id, temprow.tenant_id)), temprow.next_value); | ||
END LOOP; | ||
|
||
FOR temprow IN | ||
SELECT max(id::int)+1 AS next_value, test_suite_id, tenant_id | ||
FROM test_suite_runs | ||
GROUP BY test_suite_id, tenant_id | ||
LOOP | ||
EXECUTE format('CREATE SEQUENCE IF NOT EXISTS runs_test_suite_%s_seq START WITH %s', | ||
MD5(FORMAT('%s%s', temprow.test_suite_id, temprow.tenant_id)), temprow.next_value); | ||
END LOOP; | ||
END $$; |
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
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