From 936d3cf690ace9adfdfe0fb44193c11a0cb26d95 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 9 Jan 2025 17:28:46 +0200 Subject: Added goose for migrations, refactored SQL schema, server and client are broken --- internal/data/networks.sql.go | 126 ------------------------------------------ 1 file changed, 126 deletions(-) (limited to 'internal/data/networks.sql.go') diff --git a/internal/data/networks.sql.go b/internal/data/networks.sql.go index 9adeeb8..5091602 100644 --- a/internal/data/networks.sql.go +++ b/internal/data/networks.sql.go @@ -84,132 +84,6 @@ func (q *Queries) GetNetworkById(ctx context.Context, id snowflake.ID) (Network, return i, err } -const getPublicNetworks = `-- name: GetPublicNetworks :many -SELECT id, owner_id, name, icon, bg_hex_color, fg_hex_color, is_public FROM networks -WHERE is_public = true -` - -func (q *Queries) GetPublicNetworks(ctx context.Context) ([]Network, error) { - rows, err := q.db.QueryContext(ctx, getPublicNetworks) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Network - for rows.Next() { - var i Network - if err := rows.Scan( - &i.ID, - &i.OwnerID, - &i.Name, - &i.Icon, - &i.BgHexColor, - &i.FgHexColor, - &i.IsPublic, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const setNetworkIcon = `-- name: SetNetworkIcon :one -UPDATE networks SET - icon = ?, - bg_hex_color = ?, - fg_hex_color = ? -WHERE id = ? -RETURNING id, owner_id, name, icon, bg_hex_color, fg_hex_color, is_public -` - -type SetNetworkIconParams struct { - Icon string - BgHexColor string - FgHexColor string - ID snowflake.ID -} - -func (q *Queries) SetNetworkIcon(ctx context.Context, arg SetNetworkIconParams) (Network, error) { - row := q.db.QueryRowContext(ctx, setNetworkIcon, - arg.Icon, - arg.BgHexColor, - arg.FgHexColor, - arg.ID, - ) - var i Network - err := row.Scan( - &i.ID, - &i.OwnerID, - &i.Name, - &i.Icon, - &i.BgHexColor, - &i.FgHexColor, - &i.IsPublic, - ) - return i, err -} - -const setNetworkIsPublic = `-- name: SetNetworkIsPublic :one -UPDATE networks SET - is_public = ? -WHERE id = ? -RETURNING id, owner_id, name, icon, bg_hex_color, fg_hex_color, is_public -` - -type SetNetworkIsPublicParams struct { - IsPublic bool - ID snowflake.ID -} - -func (q *Queries) SetNetworkIsPublic(ctx context.Context, arg SetNetworkIsPublicParams) (Network, error) { - row := q.db.QueryRowContext(ctx, setNetworkIsPublic, arg.IsPublic, arg.ID) - var i Network - err := row.Scan( - &i.ID, - &i.OwnerID, - &i.Name, - &i.Icon, - &i.BgHexColor, - &i.FgHexColor, - &i.IsPublic, - ) - return i, err -} - -const setNetworkName = `-- name: SetNetworkName :one -UPDATE networks SET - name = ? -WHERE id = ? -RETURNING id, owner_id, name, icon, bg_hex_color, fg_hex_color, is_public -` - -type SetNetworkNameParams struct { - Name string - ID snowflake.ID -} - -func (q *Queries) SetNetworkName(ctx context.Context, arg SetNetworkNameParams) (Network, error) { - row := q.db.QueryRowContext(ctx, setNetworkName, arg.Name, arg.ID) - var i Network - err := row.Scan( - &i.ID, - &i.OwnerID, - &i.Name, - &i.Icon, - &i.BgHexColor, - &i.FgHexColor, - &i.IsPublic, - ) - return i, err -} - const transferNetwork = `-- name: TransferNetwork :one UPDATE networks SET owner_id = ? -- cgit v1.3.1