bmc_hub/migrations/1048_location_access_files.sql
2026-09-25 11:33:53 +02:00

15 lines
557 B
SQL

CREATE TABLE IF NOT EXISTS locations_access_files (
id SERIAL PRIMARY KEY,
location_id INTEGER NOT NULL REFERENCES locations_locations(id) ON DELETE CASCADE,
original_filename VARCHAR(255) NOT NULL,
stored_filename VARCHAR(255) NOT NULL,
content_type VARCHAR(150),
file_size BIGINT NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_locations_access_files_location
ON locations_access_files(location_id, created_at DESC)
WHERE deleted_at IS NULL;