1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00
woodpecker/server/store/datastore/sql/postgres/files/perms.sql
Jacob Floyd 5fe712cca6
Move package store/ to server/store/ (#341)
* Refactor: move store/ to server/store/

* fix pipeline for moved tests

Co-authored-by: 6543 <6543@obermui.de>
2021-09-23 13:33:59 +02:00

64 lines
1.0 KiB
SQL

-- name: perms-find-user
SELECT
perm_user_id
,perm_repo_id
,perm_pull
,perm_push
,perm_admin
,perm_date
FROM perms
WHERE perm_user_id = $1
-- name: perms-find-user-repo
SELECT
perm_user_id
,perm_repo_id
,perm_pull
,perm_push
,perm_admin
,perm_synced
FROM perms
WHERE perm_user_id = $1
AND perm_repo_id = $2
-- name: perms-insert-replace
REPLACE INTO perms (
perm_user_id
,perm_repo_id
,perm_pull
,perm_push
,perm_admin
,perm_synced
) VALUES ($1,$2,$3,$4,$5,$6)
-- name: perms-insert-replace-lookup
INSERT INTO perms (
perm_user_id
,perm_repo_id
,perm_pull
,perm_push
,perm_admin
,perm_synced
) VALUES ($1,(SELECT repo_id FROM repos WHERE repo_full_name = $2),$3,$4,$5,$6)
ON CONFLICT (perm_user_id, perm_repo_id) DO UPDATE SET
perm_pull = EXCLUDED.perm_pull
,perm_push = EXCLUDED.perm_push
,perm_admin = EXCLUDED.perm_admin
,perm_synced = EXCLUDED.perm_synced
-- name: perms-delete-user-repo
DELETE FROM perms
WHERE perm_user_id = $1
AND perm_repo_id = $2
-- name: perms-delete-user-date
DELETE FROM perms
WHERE perm_user_id = $1
AND perm_synced < $2