Remove documents table (#618)

* Remove documents table (WIP)

* Further cleanup of documents table

* This should clean up the errors, but actual attachment handling still needs added.

* Full generation to update the JS side of things too

* Further fixes

* Fix cyclic dependency issue

* In theory the API side works now

* Fix go linting issues

* Fix frontend issues

* Way closer, but has a foreign key constrant issue

* UI actually works now

* Fix deduplication feature not working right

* Upgrade to `golangci-lint` v2 file

* Add ability to set primary during attachment creation

* Update swagger with new primary attachment during creation stuff

* Files are actually saved now, but there's still a bug

* Fix critical issue whith how deletions were working

* Fix the byte copy issue

* Hopefully everything is fixed now

* Fix golangci-lint config and lint files

* Fix lint issue

* Fix a few more tests

* Fix lint issues again

* More minor test fixes

* Update backend/internal/core/services/service_items_attachments.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix migration (I think)

* Fixed postgres migration

* Change some migration options to work better

* Some more little things that I tried

* Fix merge go.mod

* Fix migrations

* Little lint thing

* Fix AttachmentsList.vue with updated API

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Matt Kilgore
2025-05-03 10:15:54 -04:00
committed by GitHub
parent a64d0c5b4c
commit 606a92b5d5
58 changed files with 900 additions and 4857 deletions

View File

@@ -0,0 +1,20 @@
-- +goose Up
-- Step 1: Modify "attachments" table to add new columns
ALTER TABLE "attachments" ADD COLUMN "title" character varying NOT NULL DEFAULT '', ADD COLUMN "path" character varying NOT NULL DEFAULT '';
-- Update existing rows in "attachments" with data from "documents"
UPDATE "attachments"
SET "title" = d."title",
"path" = d."path"
FROM "documents" d
WHERE "attachments"."document_attachments" = d."id";
-- Step 3: Drop foreign key constraints referencing "documents"
ALTER TABLE "attachments" DROP CONSTRAINT IF EXISTS "attachments_documents_attachments";
-- Step 4: Drop the "document_attachments" column
ALTER TABLE "attachments" DROP COLUMN IF EXISTS "document_attachments";
-- Step 5: Drop the "documents" table
DROP TABLE IF EXISTS "documents";