feat(db): add migrations 119-122 for cloud versions, gear warranty/documents/repairs
This commit is contained in:
parent
9bef4db8a6
commit
689d9164f6
4 changed files with 55 additions and 0 deletions
26
veza-backend-api/migrations/119_cloud_file_versions.sql
Normal file
26
veza-backend-api/migrations/119_cloud_file_versions.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- Migration 119: Cloud file versioning and sharing (v0.802 CL1)
|
||||
-- Version history for user_files
|
||||
CREATE TABLE IF NOT EXISTS cloud_file_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_id UUID NOT NULL REFERENCES user_files(id) ON DELETE CASCADE,
|
||||
version INTEGER NOT NULL DEFAULT 1,
|
||||
storage_key TEXT NOT NULL,
|
||||
size_bytes BIGINT NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_cloud_file_versions_file_id ON cloud_file_versions(file_id);
|
||||
|
||||
-- Share links for temporary access
|
||||
CREATE TABLE IF NOT EXISTS cloud_file_shares (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_id UUID NOT NULL REFERENCES user_files(id) ON DELETE CASCADE,
|
||||
token VARCHAR(64) NOT NULL UNIQUE,
|
||||
permissions VARCHAR(20) NOT NULL DEFAULT 'read',
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_cloud_file_shares_file_id ON cloud_file_shares(file_id);
|
||||
CREATE INDEX idx_cloud_file_shares_token ON cloud_file_shares(token);
|
||||
CREATE INDEX idx_cloud_file_shares_expires_at ON cloud_file_shares(expires_at);
|
||||
4
veza-backend-api/migrations/120_gear_warranty.sql
Normal file
4
veza-backend-api/migrations/120_gear_warranty.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- Migration 120: Gear warranty_start (v0.802 GR1)
|
||||
-- warranty_expire already exists in gear_items
|
||||
ALTER TABLE gear_items ADD COLUMN IF NOT EXISTS warranty_start DATE;
|
||||
ALTER TABLE gear_items ADD COLUMN IF NOT EXISTS warranty_notes TEXT DEFAULT '';
|
||||
11
veza-backend-api/migrations/121_gear_documents.sql
Normal file
11
veza-backend-api/migrations/121_gear_documents.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- Migration 121: Gear documents (v0.802 GR1)
|
||||
CREATE TABLE IF NOT EXISTS gear_documents (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
gear_id UUID NOT NULL REFERENCES gear_items(id) ON DELETE CASCADE,
|
||||
type VARCHAR(50) NOT NULL DEFAULT 'invoice',
|
||||
storage_key TEXT NOT NULL,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
uploaded_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_gear_documents_gear_id ON gear_documents(gear_id);
|
||||
14
veza-backend-api/migrations/122_gear_repairs.sql
Normal file
14
veza-backend-api/migrations/122_gear_repairs.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- Migration 122: Gear repairs (v0.802 GR1)
|
||||
CREATE TABLE IF NOT EXISTS gear_repairs (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
gear_id UUID NOT NULL REFERENCES gear_items(id) ON DELETE CASCADE,
|
||||
repair_date DATE NOT NULL,
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
cost_cents INTEGER NOT NULL DEFAULT 0,
|
||||
currency VARCHAR(3) NOT NULL DEFAULT 'EUR',
|
||||
provider VARCHAR(255) DEFAULT '',
|
||||
notes TEXT DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_gear_repairs_gear_id ON gear_repairs(gear_id);
|
||||
Loading…
Reference in a new issue