Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
56 lines
2.3 KiB
SQL
56 lines
2.3 KiB
SQL
CREATE TABLE IF NOT EXISTS resources (
|
|
id VARCHAR(36) NOT NULL PRIMARY KEY,
|
|
handle VARCHAR(22) NOT NULL UNIQUE,
|
|
tenant_id BIGINT NOT NULL,
|
|
storage_backend_id VARCHAR(36),
|
|
provider VARCHAR(32) NOT NULL,
|
|
physical_path TEXT NOT NULL,
|
|
location_hash VARCHAR(64) NOT NULL,
|
|
kind VARCHAR(32) NOT NULL DEFAULT 'file',
|
|
mime_type VARCHAR(255) NOT NULL DEFAULT '',
|
|
original_name VARCHAR(1024) NOT NULL DEFAULT '',
|
|
size BIGINT NOT NULL DEFAULT 0,
|
|
content_hash VARCHAR(64) NOT NULL DEFAULT '',
|
|
lifecycle VARCHAR(16) NOT NULL DEFAULT 'persistent',
|
|
expires_at TIMESTAMP NULL,
|
|
state VARCHAR(16) NOT NULL DEFAULT 'active',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at TIMESTAMP NULL
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_resources_tenant_location
|
|
ON resources(tenant_id, location_hash) WHERE deleted_at IS NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_resources_tenant ON resources(tenant_id);
|
|
CREATE INDEX IF NOT EXISTS idx_resources_backend ON resources(storage_backend_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS resource_bindings (
|
|
id VARCHAR(36) NOT NULL PRIMARY KEY,
|
|
resource_id VARCHAR(36) NOT NULL REFERENCES resources(id) ON DELETE CASCADE,
|
|
tenant_id BIGINT NOT NULL,
|
|
owner_type VARCHAR(32) NOT NULL,
|
|
owner_id VARCHAR(64) NOT NULL,
|
|
relation VARCHAR(32) NOT NULL DEFAULT 'attachment',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_resource_bindings_unique
|
|
ON resource_bindings(resource_id, owner_type, owner_id, relation);
|
|
CREATE INDEX IF NOT EXISTS idx_resource_bindings_owner
|
|
ON resource_bindings(tenant_id, owner_type, owner_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS resource_access_grants (
|
|
id VARCHAR(36) NOT NULL PRIMARY KEY,
|
|
token_hash VARCHAR(64) NOT NULL UNIQUE,
|
|
resource_id VARCHAR(36) NOT NULL REFERENCES resources(id) ON DELETE CASCADE,
|
|
access_scope VARCHAR(16) NOT NULL DEFAULT 'read',
|
|
expires_at TIMESTAMP NOT NULL,
|
|
revoked_at TIMESTAMP NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_resource_access_grants_resource
|
|
ON resource_access_grants(resource_id);
|
|
CREATE INDEX IF NOT EXISTS idx_resource_access_grants_expires
|
|
ON resource_access_grants(expires_at);
|