rename file_metadata_connections to file_connections

This commit is contained in:
gitGnome
2026-04-15 07:42:14 +02:00
parent 53c2f71d5d
commit fcda29a66b
+4 -4
View File
@@ -81,8 +81,8 @@ func PgInit(ctx context.Context) {
}
_, err = dbConn.Exec(ctx, `
CREATE TABLE IF NOT EXISTS files_metadata_connections (
file_metadata_id UUID NOT NULL REFERENCES files_metadata(id) ON DELETE CASCADE,
CREATE TABLE IF NOT EXISTS file_connections (
file_id UUID NOT NULL REFERENCES files_metadata(id) ON DELETE CASCADE,
connection_id UUID NOT NULL REFERENCES user_connections(id) ON DELETE CASCADE
)
`)
@@ -266,14 +266,14 @@ func PgFileMetadataDelete(ctx context.Context, metadataId *uuid.UUID) error {
func PgFileConnectionsAdd(ctx context.Context, metadataId *uuid.UUID, connectionId *uuid.UUID) error {
_, err := dbConn.Exec(ctx, `
INSERT INTO files_metadata_connections (file_metadata_id, connection_id) VALUES ($1, $2)
INSERT INTO file_connections (file_id, connection_id) VALUES ($1, $2)
`, metadataId, connectionId)
return err
}
func PgFileConnectionsGet(ctx context.Context, metadata *types.FileMetadata) error {
rows, err := dbConn.Query(ctx, `
SELECT connection_id FROM files_metadata_connections WHERE file_metadata_id = $1
SELECT connection_id FROM file_connections WHERE file_id = $1
`, metadata.Id)
if err != nil {
return err