rename file_metadata_connections to file_connections
This commit is contained in:
@@ -81,8 +81,8 @@ func PgInit(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = dbConn.Exec(ctx, `
|
_, err = dbConn.Exec(ctx, `
|
||||||
CREATE TABLE IF NOT EXISTS files_metadata_connections (
|
CREATE TABLE IF NOT EXISTS file_connections (
|
||||||
file_metadata_id UUID NOT NULL REFERENCES files_metadata(id) ON DELETE CASCADE,
|
file_id UUID NOT NULL REFERENCES files_metadata(id) ON DELETE CASCADE,
|
||||||
connection_id UUID NOT NULL REFERENCES user_connections(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 {
|
func PgFileConnectionsAdd(ctx context.Context, metadataId *uuid.UUID, connectionId *uuid.UUID) error {
|
||||||
_, err := dbConn.Exec(ctx, `
|
_, 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)
|
`, metadataId, connectionId)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func PgFileConnectionsGet(ctx context.Context, metadata *types.FileMetadata) error {
|
func PgFileConnectionsGet(ctx context.Context, metadata *types.FileMetadata) error {
|
||||||
rows, err := dbConn.Query(ctx, `
|
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)
|
`, metadata.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user