From c335c834ba576752daa6a8cfb2be8570da445e40 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Tue, 1 Jul 2025 11:02:58 +1200 Subject: [PATCH] feat: add database schema for transaction attachments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add attachment table with fields for file metadata and relationships - Include indexes for optimal query performance on transactionId, orgId, userId, and uploaded fields - Support for file storage with path tracking and soft deletion 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- indexes.sql | 6 +++++- schema.sql | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indexes.sql b/indexes.sql index 3efdcea..c136af0 100644 --- a/indexes.sql +++ b/indexes.sql @@ -3,4 +3,8 @@ CREATE INDEX split_accountId_index ON split (accountId); CREATE INDEX split_transactionId_index ON split (transactionId); CREATE INDEX split_date_index ON split (date); CREATE INDEX split_updated_index ON split (updated); -CREATE INDEX budgetitem_orgId_index ON budgetitem (orgId); \ No newline at end of file +CREATE INDEX budgetitem_orgId_index ON budgetitem (orgId); +CREATE INDEX attachment_transactionId_index ON attachment (transactionId); +CREATE INDEX attachment_orgId_index ON attachment (orgId); +CREATE INDEX attachment_userId_index ON attachment (userId); +CREATE INDEX attachment_uploaded_index ON attachment (uploaded); \ No newline at end of file diff --git a/schema.sql b/schema.sql index 6db50e0..7b14628 100644 --- a/schema.sql +++ b/schema.sql @@ -30,4 +30,6 @@ CREATE TABLE apikey (id BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, CREATE TABLE invite (id VARCHAR(32) NOT NULL, orgId BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, updated BIGINT UNSIGNED NOT NULL, email VARCHAR(100) NOT NULL, accepted BOOLEAN NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; -CREATE TABLE budgetitem (id INT UNSIGNED NOT NULL AUTO_INCREMENT, orgId BINARY(16) NOT NULL, accountId BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, amount BIGINT NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; \ No newline at end of file +CREATE TABLE budgetitem (id INT UNSIGNED NOT NULL AUTO_INCREMENT, orgId BINARY(16) NOT NULL, accountId BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, amount BIGINT NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; + +CREATE TABLE attachment (id BINARY(16) NOT NULL, transactionId BINARY(16) NOT NULL, orgId BINARY(16) NOT NULL, userId BINARY(16) NOT NULL, fileName VARCHAR(255) NOT NULL, originalName VARCHAR(255) NOT NULL, contentType VARCHAR(100) NOT NULL, fileSize BIGINT NOT NULL, filePath VARCHAR(500) NOT NULL, description VARCHAR(500), uploaded BIGINT UNSIGNED NOT NULL, deleted BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY(id)) ENGINE=InnoDB; \ No newline at end of file