Files
fm_be/migrations/20260630_add_is_template_to_file_files.sql
2026-07-16 22:16:45 +07:00

22 lines
462 B
SQL

-- +goose Up
ALTER TABLE file_files
ADD COLUMN is_template TINYINT(1) NOT NULL DEFAULT 0 AFTER checksum_sha256;
UPDATE file_files
SET is_template = 1
WHERE EXISTS (
SELECT 1
FROM helicopter_files hf
WHERE hf.source_file_id = file_files.id
)
OR EXISTS (
SELECT 1
FROM helicopter_files hf
INNER JOIN attachments a ON a.id = hf.file_attachment_id
AND a.file_id = file_files.id
);
-- +goose Down
ALTER TABLE file_files
DROP COLUMN is_template;