Move all tables into a schema
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m19s
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m19s
This commit is contained in:
@@ -11,18 +11,18 @@ import (
|
||||
)
|
||||
|
||||
const getClicks = `-- name: GetClicks :many
|
||||
SELECT click_id, url_id, clicked_at, referrer, user_agent, ip_address FROM click_logs
|
||||
SELECT click_id, url_id, clicked_at, referrer, user_agent, ip_address FROM lss.click_logs
|
||||
`
|
||||
|
||||
func (q *Queries) GetClicks(ctx context.Context) ([]ClickLog, error) {
|
||||
func (q *Queries) GetClicks(ctx context.Context) ([]LssClickLog, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getClicks)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ClickLog
|
||||
var items []LssClickLog
|
||||
for rows.Next() {
|
||||
var i ClickLog
|
||||
var i LssClickLog
|
||||
if err := rows.Scan(
|
||||
&i.ClickID,
|
||||
&i.UrlID,
|
||||
@@ -45,7 +45,7 @@ func (q *Queries) GetClicks(ctx context.Context) ([]ClickLog, error) {
|
||||
}
|
||||
|
||||
const trackClick = `-- name: TrackClick :one
|
||||
INSERT INTO click_logs (url_id, referrer, user_agent, ip_address)
|
||||
INSERT INTO lss.click_logs (url_id, referrer, user_agent, ip_address)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
@@ -62,14 +62,14 @@ type TrackClickParams struct {
|
||||
IpAddress sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) TrackClick(ctx context.Context, arg TrackClickParams) (ClickLog, error) {
|
||||
func (q *Queries) TrackClick(ctx context.Context, arg TrackClickParams) (LssClickLog, error) {
|
||||
row := q.db.QueryRowContext(ctx, trackClick,
|
||||
arg.UrlID,
|
||||
arg.Referrer,
|
||||
arg.UserAgent,
|
||||
arg.IpAddress,
|
||||
)
|
||||
var i ClickLog
|
||||
var i LssClickLog
|
||||
err := row.Scan(
|
||||
&i.ClickID,
|
||||
&i.UrlID,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type ClickLog struct {
|
||||
type LssClickLog struct {
|
||||
ClickID int64
|
||||
UrlID int32
|
||||
ClickedAt time.Time
|
||||
@@ -18,7 +18,7 @@ type ClickLog struct {
|
||||
IpAddress sql.NullString
|
||||
}
|
||||
|
||||
type Url struct {
|
||||
type LssUrl struct {
|
||||
UrlID int32
|
||||
LongUrl string
|
||||
ShortCode string
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const createURL = `-- name: CreateURL :one
|
||||
INSERT INTO urls (created_at, expires_at, long_url, short_code, is_active)
|
||||
INSERT INTO lss.urls (created_at, expires_at, long_url, short_code, is_active)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
@@ -31,7 +31,7 @@ type CreateURLParams struct {
|
||||
IsActive bool
|
||||
}
|
||||
|
||||
func (q *Queries) CreateURL(ctx context.Context, arg CreateURLParams) (Url, error) {
|
||||
func (q *Queries) CreateURL(ctx context.Context, arg CreateURLParams) (LssUrl, error) {
|
||||
row := q.db.QueryRowContext(ctx, createURL,
|
||||
arg.CreatedAt,
|
||||
arg.ExpiresAt,
|
||||
@@ -39,7 +39,7 @@ func (q *Queries) CreateURL(ctx context.Context, arg CreateURLParams) (Url, erro
|
||||
arg.ShortCode,
|
||||
arg.IsActive,
|
||||
)
|
||||
var i Url
|
||||
var i LssUrl
|
||||
err := row.Scan(
|
||||
&i.UrlID,
|
||||
&i.LongUrl,
|
||||
@@ -52,12 +52,12 @@ func (q *Queries) CreateURL(ctx context.Context, arg CreateURLParams) (Url, erro
|
||||
}
|
||||
|
||||
const deleteURL = `-- name: DeleteURL :one
|
||||
DELETE FROM urls WHERE url_id = $1 RETURNING url_id, long_url, short_code, created_at, expires_at, is_active
|
||||
DELETE FROM lss.urls WHERE url_id = $1 RETURNING url_id, long_url, short_code, created_at, expires_at, is_active
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteURL(ctx context.Context, urlID int32) (Url, error) {
|
||||
func (q *Queries) DeleteURL(ctx context.Context, urlID int32) (LssUrl, error) {
|
||||
row := q.db.QueryRowContext(ctx, deleteURL, urlID)
|
||||
var i Url
|
||||
var i LssUrl
|
||||
err := row.Scan(
|
||||
&i.UrlID,
|
||||
&i.LongUrl,
|
||||
@@ -70,7 +70,7 @@ func (q *Queries) DeleteURL(ctx context.Context, urlID int32) (Url, error) {
|
||||
}
|
||||
|
||||
const getURLByShortCode = `-- name: GetURLByShortCode :one
|
||||
SELECT url_id, long_url FROM urls WHERE is_active = true AND short_code = $1
|
||||
SELECT url_id, long_url FROM lss.urls WHERE is_active = true AND short_code = $1
|
||||
`
|
||||
|
||||
type GetURLByShortCodeRow struct {
|
||||
@@ -86,18 +86,18 @@ func (q *Queries) GetURLByShortCode(ctx context.Context, shortCode string) (GetU
|
||||
}
|
||||
|
||||
const getURLs = `-- name: GetURLs :many
|
||||
SELECT url_id, long_url, short_code, created_at, expires_at, is_active FROM urls
|
||||
SELECT url_id, long_url, short_code, created_at, expires_at, is_active FROM lss.urls
|
||||
`
|
||||
|
||||
func (q *Queries) GetURLs(ctx context.Context) ([]Url, error) {
|
||||
func (q *Queries) GetURLs(ctx context.Context) ([]LssUrl, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getURLs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Url
|
||||
var items []LssUrl
|
||||
for rows.Next() {
|
||||
var i Url
|
||||
var i LssUrl
|
||||
if err := rows.Scan(
|
||||
&i.UrlID,
|
||||
&i.LongUrl,
|
||||
@@ -120,7 +120,7 @@ func (q *Queries) GetURLs(ctx context.Context) ([]Url, error) {
|
||||
}
|
||||
|
||||
const setActive = `-- name: SetActive :one
|
||||
UPDATE urls SET is_active = $1 WHERE url_id = $2 RETURNING url_id, long_url, short_code, created_at, expires_at, is_active
|
||||
UPDATE lss.urls SET is_active = $1 WHERE url_id = $2 RETURNING url_id, long_url, short_code, created_at, expires_at, is_active
|
||||
`
|
||||
|
||||
type SetActiveParams struct {
|
||||
@@ -128,9 +128,9 @@ type SetActiveParams struct {
|
||||
UrlID int32
|
||||
}
|
||||
|
||||
func (q *Queries) SetActive(ctx context.Context, arg SetActiveParams) (Url, error) {
|
||||
func (q *Queries) SetActive(ctx context.Context, arg SetActiveParams) (LssUrl, error) {
|
||||
row := q.db.QueryRowContext(ctx, setActive, arg.IsActive, arg.UrlID)
|
||||
var i Url
|
||||
var i LssUrl
|
||||
err := row.Scan(
|
||||
&i.UrlID,
|
||||
&i.LongUrl,
|
||||
|
||||
Reference in New Issue
Block a user