Schließe die Connector-Kapselung ab, damit Paperless, IMAP und weitere Quellen über dieselbe Anbindung laufen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
75a3949f7c
commit
d6b70d8f92
75 files changed
+9477
-414
No files matched your search
@@ -0,0 +1,66 @@
|
||||
-- Source instance binding and opaque storage generation.
|
||||
-- Connector ids are not a foreign key: deleting an access must not
|
||||
-- retarget or remove an existing reference.
|
||||
-- The legacy root path is bound in the migrator, not in this file.
|
||||
|
||||
CREATE TABLE storage_instances (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
kind text NOT NULL,
|
||||
generation text NOT NULL,
|
||||
root_path text,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT storage_instances_kind CHECK (kind IN ('local')),
|
||||
CONSTRAINT storage_instances_generation UNIQUE (generation),
|
||||
CONSTRAINT storage_instances_generation_len CHECK (char_length(generation) BETWEEN 1 AND 80)
|
||||
);
|
||||
|
||||
ALTER TABLE media_assets
|
||||
ADD COLUMN storage_instance_id uuid REFERENCES storage_instances (id),
|
||||
ADD COLUMN storage_generation text,
|
||||
ADD COLUMN object_key text,
|
||||
ADD COLUMN content_revision text,
|
||||
ADD COLUMN protection_profile text NOT NULL DEFAULT 'legacy-plaintext',
|
||||
ADD COLUMN key_responsibility text NOT NULL DEFAULT 'none',
|
||||
ADD CONSTRAINT media_assets_protection CHECK (
|
||||
protection_profile IN ('legacy-plaintext', 'managed-encrypted', 'client-encrypted')
|
||||
),
|
||||
ADD CONSTRAINT media_assets_key_responsibility CHECK (
|
||||
key_responsibility IN ('none', 'operator', 'client')
|
||||
);
|
||||
|
||||
ALTER TABLE dispatch_snapshots
|
||||
ADD COLUMN storage_instance_id uuid REFERENCES storage_instances (id),
|
||||
ADD COLUMN storage_generation text,
|
||||
ADD COLUMN object_key text,
|
||||
ADD COLUMN content_revision text,
|
||||
ADD COLUMN protection_profile text NOT NULL DEFAULT 'legacy-plaintext',
|
||||
ADD COLUMN key_responsibility text NOT NULL DEFAULT 'none',
|
||||
ADD CONSTRAINT dispatch_snapshots_protection CHECK (
|
||||
protection_profile IN ('legacy-plaintext', 'managed-encrypted', 'client-encrypted')
|
||||
),
|
||||
ADD CONSTRAINT dispatch_snapshots_key_responsibility CHECK (
|
||||
key_responsibility IN ('none', 'operator', 'client')
|
||||
);
|
||||
|
||||
UPDATE media_assets
|
||||
SET storage_generation = 'legacy-local-1',
|
||||
object_key = id::text,
|
||||
content_revision = id::text,
|
||||
protection_profile = 'legacy-plaintext',
|
||||
key_responsibility = 'none'
|
||||
WHERE object_key IS NULL;
|
||||
|
||||
UPDATE dispatch_snapshots
|
||||
SET storage_generation = 'legacy-local-1',
|
||||
object_key = 'dispatch/' || id::text,
|
||||
content_revision = id::text,
|
||||
protection_profile = 'legacy-plaintext',
|
||||
key_responsibility = 'none'
|
||||
WHERE object_key IS NULL;
|
||||
|
||||
ALTER TABLE external_references
|
||||
ADD COLUMN connector_id uuid,
|
||||
ADD COLUMN resolution text NOT NULL DEFAULT 'unresolved',
|
||||
ADD CONSTRAINT external_references_resolution CHECK (
|
||||
resolution IN ('bound', 'ambiguous', 'unresolved', 'none')
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Connector kinds are validated by the registered source modules.
|
||||
-- A database checklist must not grow for every additional source.
|
||||
|
||||
ALTER TABLE connectors DROP CONSTRAINT IF EXISTS connectors_kind;
|
||||
ALTER TABLE external_references DROP CONSTRAINT IF EXISTS external_references_source;
|
||||
Reference in new issue
Block a user