15 lines
557 B
MySQL
15 lines
557 B
MySQL
|
|
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;
|