- remove db files;
This commit is contained in:
parent
6752028e00
commit
b05930c861
|
|
@ -1,32 +0,0 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.23.0
|
|
||||||
|
|
||||||
package db
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
|
||||||
"github.com/jackc/pgx/v5/pgconn"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DBTX interface {
|
|
||||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
|
||||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
|
||||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(db DBTX) *Queries {
|
|
||||||
return &Queries{db: db}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Queries struct {
|
|
||||||
db DBTX
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
|
||||||
return &Queries{
|
|
||||||
db: tx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.23.0
|
|
||||||
|
|
||||||
package db
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Appconfig struct {
|
|
||||||
TicketKey pgtype.Text
|
|
||||||
TicketID pgtype.Int4
|
|
||||||
}
|
|
||||||
|
|
||||||
type Ticket struct {
|
|
||||||
ID int32
|
|
||||||
Key pgtype.Text
|
|
||||||
Channelid pgtype.Text
|
|
||||||
ProjectGit pgtype.Text
|
|
||||||
BuildGit pgtype.Text
|
|
||||||
Folder pgtype.Text
|
|
||||||
CreatedAt pgtype.Timestamptz
|
|
||||||
DeletedAt pgtype.Timestamptz
|
|
||||||
UpdatedAt pgtype.Timestamptz
|
|
||||||
}
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// sqlc v1.23.0
|
|
||||||
// source: queries.sql
|
|
||||||
|
|
||||||
package db
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
|
||||||
)
|
|
||||||
|
|
||||||
const createTicket = `-- name: CreateTicket :one
|
|
||||||
INSERT INTO tickets (
|
|
||||||
key, channelID
|
|
||||||
) VALUES (
|
|
||||||
$1, $2
|
|
||||||
)
|
|
||||||
RETURNING id, key, channelid, project_git, build_git, folder, created_at, deleted_at, updated_at
|
|
||||||
`
|
|
||||||
|
|
||||||
type CreateTicketParams struct {
|
|
||||||
Key pgtype.Text
|
|
||||||
Channelid pgtype.Text
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) CreateTicket(ctx context.Context, arg CreateTicketParams) (Ticket, error) {
|
|
||||||
row := q.db.QueryRow(ctx, createTicket, arg.Key, arg.Channelid)
|
|
||||||
var i Ticket
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Key,
|
|
||||||
&i.Channelid,
|
|
||||||
&i.ProjectGit,
|
|
||||||
&i.BuildGit,
|
|
||||||
&i.Folder,
|
|
||||||
&i.CreatedAt,
|
|
||||||
&i.DeletedAt,
|
|
||||||
&i.UpdatedAt,
|
|
||||||
)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteTicketByID = `-- name: DeleteTicketByID :exec
|
|
||||||
UPDATE tickets SET deleted_at = current_timestamp WHERE id = $1
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) DeleteTicketByID(ctx context.Context, id int32) error {
|
|
||||||
_, err := q.db.Exec(ctx, deleteTicketByID, id)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteTicketByKey = `-- name: DeleteTicketByKey :exec
|
|
||||||
UPDATE tickets SET deleted_at = current_timestamp WHERE key = $1
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) DeleteTicketByKey(ctx context.Context, key pgtype.Text) error {
|
|
||||||
_, err := q.db.Exec(ctx, deleteTicketByKey, key)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getConfig = `-- name: GetConfig :one
|
|
||||||
SELECT ticket_key, ticket_id
|
|
||||||
FROM appconfig
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) GetConfig(ctx context.Context) (Appconfig, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getConfig)
|
|
||||||
var i Appconfig
|
|
||||||
err := row.Scan(&i.TicketKey, &i.TicketID)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getTicketByChannelID = `-- name: GetTicketByChannelID :one
|
|
||||||
SELECT id, key, channelid, project_git, build_git, folder, created_at, deleted_at, updated_at FROM tickets WHERE channelID = $1
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) GetTicketByChannelID(ctx context.Context, channelid pgtype.Text) (Ticket, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getTicketByChannelID, channelid)
|
|
||||||
var i Ticket
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Key,
|
|
||||||
&i.Channelid,
|
|
||||||
&i.ProjectGit,
|
|
||||||
&i.BuildGit,
|
|
||||||
&i.Folder,
|
|
||||||
&i.CreatedAt,
|
|
||||||
&i.DeletedAt,
|
|
||||||
&i.UpdatedAt,
|
|
||||||
)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const getTicketByID = `-- name: GetTicketByID :one
|
|
||||||
SELECT id, key, channelid, project_git, build_git, folder, created_at, deleted_at, updated_at FROM tickets WHERE id = $1
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) GetTicketByID(ctx context.Context, id int32) (Ticket, error) {
|
|
||||||
row := q.db.QueryRow(ctx, getTicketByID, id)
|
|
||||||
var i Ticket
|
|
||||||
err := row.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Key,
|
|
||||||
&i.Channelid,
|
|
||||||
&i.ProjectGit,
|
|
||||||
&i.BuildGit,
|
|
||||||
&i.Folder,
|
|
||||||
&i.CreatedAt,
|
|
||||||
&i.DeletedAt,
|
|
||||||
&i.UpdatedAt,
|
|
||||||
)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const listTickets = `-- name: ListTickets :many
|
|
||||||
SELECT id, key, channelid, project_git, build_git, folder, created_at, deleted_at, updated_at FROM tickets WHERE deleted_at IS NULL
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListTickets(ctx context.Context) ([]Ticket, error) {
|
|
||||||
rows, err := q.db.Query(ctx, listTickets)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []Ticket
|
|
||||||
for rows.Next() {
|
|
||||||
var i Ticket
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Key,
|
|
||||||
&i.Channelid,
|
|
||||||
&i.ProjectGit,
|
|
||||||
&i.BuildGit,
|
|
||||||
&i.Folder,
|
|
||||||
&i.CreatedAt,
|
|
||||||
&i.DeletedAt,
|
|
||||||
&i.UpdatedAt,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const listTicketsWithDeleted = `-- name: ListTicketsWithDeleted :many
|
|
||||||
SELECT id, key, channelid, project_git, build_git, folder, created_at, deleted_at, updated_at FROM tickets
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) ListTicketsWithDeleted(ctx context.Context) ([]Ticket, error) {
|
|
||||||
rows, err := q.db.Query(ctx, listTicketsWithDeleted)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []Ticket
|
|
||||||
for rows.Next() {
|
|
||||||
var i Ticket
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Key,
|
|
||||||
&i.Channelid,
|
|
||||||
&i.ProjectGit,
|
|
||||||
&i.BuildGit,
|
|
||||||
&i.Folder,
|
|
||||||
&i.CreatedAt,
|
|
||||||
&i.DeletedAt,
|
|
||||||
&i.UpdatedAt,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
|
||||||
if err := rows.Err(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const setNewConfig = `-- name: SetNewConfig :one
|
|
||||||
UPDATE appconfig
|
|
||||||
SET ticket_id = ticket_id + 1
|
|
||||||
RETURNING ticket_key, ticket_id
|
|
||||||
`
|
|
||||||
|
|
||||||
func (q *Queries) SetNewConfig(ctx context.Context) (Appconfig, error) {
|
|
||||||
row := q.db.QueryRow(ctx, setNewConfig)
|
|
||||||
var i Appconfig
|
|
||||||
err := row.Scan(&i.TicketKey, &i.TicketID)
|
|
||||||
return i, err
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateTicketByID = `-- name: UpdateTicketByID :exec
|
|
||||||
UPDATE tickets SET project_git = $1, build_git = $2, folder = $3 WHERE id = $4
|
|
||||||
`
|
|
||||||
|
|
||||||
type UpdateTicketByIDParams struct {
|
|
||||||
ProjectGit pgtype.Text
|
|
||||||
BuildGit pgtype.Text
|
|
||||||
Folder pgtype.Text
|
|
||||||
ID int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdateTicketByID(ctx context.Context, arg UpdateTicketByIDParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, updateTicketByID,
|
|
||||||
arg.ProjectGit,
|
|
||||||
arg.BuildGit,
|
|
||||||
arg.Folder,
|
|
||||||
arg.ID,
|
|
||||||
)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue