release 1.1.0 : sync V2 (upload, download, purge, placements, rétention, groupes)
Release / release-apk (push) Successful in 9m25s
Release / release-docker (push) Successful in 33s
CI / docker (push) Successful in 7s
CI / lint-backend (push) Successful in 1m29s
CI / lint-mobile (push) Failing after 7m46s
CI / test-backend (push) Successful in 1m30s
CI / test-mobile (push) Successful in 9m27s
CI / build-backend (push) Successful in 47s

This commit is contained in:
venture
2026-09-25 20:27:14 +02:00
parent b28fcdc774
commit a34220bf2d
45 changed files with 1900 additions and 76 deletions
@@ -0,0 +1,6 @@
DROP INDEX IF EXISTS idx_shares_active_group;
ALTER TABLE shares DROP CONSTRAINT IF EXISTS shares_grantee_xor_check;
ALTER TABLE shares ALTER COLUMN grantee_user_id SET NOT NULL;
ALTER TABLE shares DROP COLUMN IF EXISTS grantee_group_id;
DROP TABLE IF EXISTS group_members;
DROP TABLE IF EXISTS groups;
@@ -0,0 +1,32 @@
-- V2-6 groupes : partage vers un ensemble d'utilisateurs (famille, équipe).
-- `groups` : identité nommée possédée (created_by) ; `group_members` :
-- appartenances (pas de groupes imbriqués — un niveau, documenté).
-- `shares` accepte une cible groupe : exactement une des deux cibles est
-- renseignée (CHECK), avec un index d'unicité active par cible.
CREATE TABLE groups (
id TEXT PRIMARY KEY CHECK (id ~ '^[0-9a-f]{32}$'),
name TEXT NOT NULL CHECK (name <> '' AND char_length(name) <= 255),
created_by TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE group_members (
group_id TEXT NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT NOW(),
PRIMARY KEY (group_id, user_id)
);
CREATE INDEX idx_group_members_user ON group_members(user_id);
ALTER TABLE shares ADD COLUMN grantee_group_id TEXT REFERENCES groups(id) ON DELETE CASCADE;
ALTER TABLE shares ALTER COLUMN grantee_user_id DROP NOT NULL;
ALTER TABLE shares
ADD CONSTRAINT shares_grantee_xor_check
CHECK (
(grantee_user_id IS NOT NULL AND grantee_group_id IS NULL)
OR (grantee_user_id IS NULL AND grantee_group_id IS NOT NULL)
);
CREATE UNIQUE INDEX idx_shares_active_group
ON shares(resource_id, grantee_group_id) WHERE revoked_at IS NULL AND grantee_group_id IS NOT NULL;
+19
View File
@@ -349,6 +349,25 @@ func TestMigrationsUpDown(t *testing.T) {
assertHexCheck(t, conn, "storage_locations", "id")
assertHexCheck(t, conn, "storage_locations", "device_id")
assertHexCheck(t, conn, "groups", "id")
// shares XOR : exactement une cible (user ou groupe).
var xorCheck int
err = conn.QueryRow(`
SELECT COUNT(*) FROM pg_constraint c
JOIN pg_class t ON t.oid = c.conrelid
WHERE t.relname = 'shares'
AND pg_get_constraintdef(c.oid) LIKE '%grantee_user_id%'
AND pg_get_constraintdef(c.oid) LIKE '%grantee_group_id%'`).Scan(&xorCheck)
if err != nil {
t.Fatalf("shares xor check: %v", err)
}
if xorCheck == 0 {
t.Error("CHECK XOR (grantee_user_id / grantee_group_id) manquant sur shares après 000016")
}
// --- 000016 : groupes + cible groupe sur shares -------------------------
assertTables(t, conn, "users", "devices", "resources", "operations", "ocr_jobs", "shares", "share_links", "storage_locations", "resource_placements", "groups", "group_members", "schema_migrations")
if err := MigrateDownDatabase(url); err != nil {
t.Fatalf("migrate down: %v", err)