|
@@ -13,7 +13,7 @@ import (
|
|
|
const createRecord = `-- name: CreateRecord :one
|
|
const createRecord = `-- name: CreateRecord :one
|
|
|
INSERT INTO records (zone_id, cf_record_id, name, type, content, proxied, is_static)
|
|
INSERT INTO records (zone_id, cf_record_id, name, type, content, proxied, is_static)
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
|
-RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, created_at, updated_at
|
|
|
|
|
|
|
+RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, last_updated_at, created_at, updated_at
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type CreateRecordParams struct {
|
|
type CreateRecordParams struct {
|
|
@@ -46,6 +46,7 @@ func (q *Queries) CreateRecord(ctx context.Context, arg CreateRecordParams) (Rec
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
)
|
|
)
|
|
@@ -76,25 +77,26 @@ func (q *Queries) DeleteRecordByCfID(ctx context.Context, arg DeleteRecordByCfID
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const getRecord = `-- name: GetRecord :one
|
|
const getRecord = `-- name: GetRecord :one
|
|
|
-SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
|
|
|
|
+SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.last_updated_at, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
FROM records r
|
|
FROM records r
|
|
|
JOIN zones z ON z.id = r.zone_id
|
|
JOIN zones z ON z.id = r.zone_id
|
|
|
WHERE r.id = ?
|
|
WHERE r.id = ?
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type GetRecordRow struct {
|
|
type GetRecordRow struct {
|
|
|
- ID int64 `json:"id"`
|
|
|
|
|
- ZoneID int64 `json:"zone_id"`
|
|
|
|
|
- CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
- Name string `json:"name"`
|
|
|
|
|
- Type string `json:"type"`
|
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
- Proxied int64 `json:"proxied"`
|
|
|
|
|
- IsStatic int64 `json:"is_static"`
|
|
|
|
|
- CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
- UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
- CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
- ZoneName string `json:"zone_name"`
|
|
|
|
|
|
|
+ ID int64 `json:"id"`
|
|
|
|
|
+ ZoneID int64 `json:"zone_id"`
|
|
|
|
|
+ CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
|
+ Proxied int64 `json:"proxied"`
|
|
|
|
|
+ IsStatic int64 `json:"is_static"`
|
|
|
|
|
+ LastUpdatedAt *time.Time `json:"last_updated_at"`
|
|
|
|
|
+ CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
+ UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
+ CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
+ ZoneName string `json:"zone_name"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetRecord(ctx context.Context, id int64) (GetRecordRow, error) {
|
|
func (q *Queries) GetRecord(ctx context.Context, id int64) (GetRecordRow, error) {
|
|
@@ -109,6 +111,7 @@ func (q *Queries) GetRecord(ctx context.Context, id int64) (GetRecordRow, error)
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
&i.CfZoneID,
|
|
&i.CfZoneID,
|
|
@@ -118,25 +121,26 @@ func (q *Queries) GetRecord(ctx context.Context, id int64) (GetRecordRow, error)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const listNonStaticRecords = `-- name: ListNonStaticRecords :many
|
|
const listNonStaticRecords = `-- name: ListNonStaticRecords :many
|
|
|
-SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.api_key as zone_api_key
|
|
|
|
|
|
|
+SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.last_updated_at, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.api_key as zone_api_key
|
|
|
FROM records r
|
|
FROM records r
|
|
|
JOIN zones z ON z.id = r.zone_id
|
|
JOIN zones z ON z.id = r.zone_id
|
|
|
WHERE r.is_static = 0
|
|
WHERE r.is_static = 0
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type ListNonStaticRecordsRow struct {
|
|
type ListNonStaticRecordsRow struct {
|
|
|
- ID int64 `json:"id"`
|
|
|
|
|
- ZoneID int64 `json:"zone_id"`
|
|
|
|
|
- CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
- Name string `json:"name"`
|
|
|
|
|
- Type string `json:"type"`
|
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
- Proxied int64 `json:"proxied"`
|
|
|
|
|
- IsStatic int64 `json:"is_static"`
|
|
|
|
|
- CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
- UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
- CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
- ZoneApiKey string `json:"zone_api_key"`
|
|
|
|
|
|
|
+ ID int64 `json:"id"`
|
|
|
|
|
+ ZoneID int64 `json:"zone_id"`
|
|
|
|
|
+ CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
|
+ Proxied int64 `json:"proxied"`
|
|
|
|
|
+ IsStatic int64 `json:"is_static"`
|
|
|
|
|
+ LastUpdatedAt *time.Time `json:"last_updated_at"`
|
|
|
|
|
+ CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
+ UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
+ CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
+ ZoneApiKey string `json:"zone_api_key"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListNonStaticRecords(ctx context.Context) ([]ListNonStaticRecordsRow, error) {
|
|
func (q *Queries) ListNonStaticRecords(ctx context.Context) ([]ListNonStaticRecordsRow, error) {
|
|
@@ -157,6 +161,7 @@ func (q *Queries) ListNonStaticRecords(ctx context.Context) ([]ListNonStaticReco
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
&i.CfZoneID,
|
|
&i.CfZoneID,
|
|
@@ -203,25 +208,26 @@ func (q *Queries) ListRecordCfIDsByZone(ctx context.Context, zoneID int64) ([]st
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const listRecords = `-- name: ListRecords :many
|
|
const listRecords = `-- name: ListRecords :many
|
|
|
-SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
|
|
|
|
+SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.last_updated_at, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
FROM records r
|
|
FROM records r
|
|
|
JOIN zones z ON z.id = r.zone_id
|
|
JOIN zones z ON z.id = r.zone_id
|
|
|
ORDER BY r.name
|
|
ORDER BY r.name
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type ListRecordsRow struct {
|
|
type ListRecordsRow struct {
|
|
|
- ID int64 `json:"id"`
|
|
|
|
|
- ZoneID int64 `json:"zone_id"`
|
|
|
|
|
- CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
- Name string `json:"name"`
|
|
|
|
|
- Type string `json:"type"`
|
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
- Proxied int64 `json:"proxied"`
|
|
|
|
|
- IsStatic int64 `json:"is_static"`
|
|
|
|
|
- CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
- UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
- CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
- ZoneName string `json:"zone_name"`
|
|
|
|
|
|
|
+ ID int64 `json:"id"`
|
|
|
|
|
+ ZoneID int64 `json:"zone_id"`
|
|
|
|
|
+ CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
|
+ Proxied int64 `json:"proxied"`
|
|
|
|
|
+ IsStatic int64 `json:"is_static"`
|
|
|
|
|
+ LastUpdatedAt *time.Time `json:"last_updated_at"`
|
|
|
|
|
+ CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
+ UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
+ CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
+ ZoneName string `json:"zone_name"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListRecords(ctx context.Context) ([]ListRecordsRow, error) {
|
|
func (q *Queries) ListRecords(ctx context.Context) ([]ListRecordsRow, error) {
|
|
@@ -242,6 +248,7 @@ func (q *Queries) ListRecords(ctx context.Context) ([]ListRecordsRow, error) {
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
&i.CfZoneID,
|
|
&i.CfZoneID,
|
|
@@ -261,7 +268,7 @@ func (q *Queries) ListRecords(ctx context.Context) ([]ListRecordsRow, error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const listRecordsByZone = `-- name: ListRecordsByZone :many
|
|
const listRecordsByZone = `-- name: ListRecordsByZone :many
|
|
|
-SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
|
|
|
|
+SELECT r.id, r.zone_id, r.cf_record_id, r.name, r.type, r.content, r.proxied, r.is_static, r.last_updated_at, r.created_at, r.updated_at, z.zone_id as cf_zone_id, z.name as zone_name
|
|
|
FROM records r
|
|
FROM records r
|
|
|
JOIN zones z ON z.id = r.zone_id
|
|
JOIN zones z ON z.id = r.zone_id
|
|
|
WHERE r.zone_id = ?
|
|
WHERE r.zone_id = ?
|
|
@@ -269,18 +276,19 @@ ORDER BY r.name
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type ListRecordsByZoneRow struct {
|
|
type ListRecordsByZoneRow struct {
|
|
|
- ID int64 `json:"id"`
|
|
|
|
|
- ZoneID int64 `json:"zone_id"`
|
|
|
|
|
- CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
- Name string `json:"name"`
|
|
|
|
|
- Type string `json:"type"`
|
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
- Proxied int64 `json:"proxied"`
|
|
|
|
|
- IsStatic int64 `json:"is_static"`
|
|
|
|
|
- CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
- UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
- CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
- ZoneName string `json:"zone_name"`
|
|
|
|
|
|
|
+ ID int64 `json:"id"`
|
|
|
|
|
+ ZoneID int64 `json:"zone_id"`
|
|
|
|
|
+ CfRecordID string `json:"cf_record_id"`
|
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
|
+ Proxied int64 `json:"proxied"`
|
|
|
|
|
+ IsStatic int64 `json:"is_static"`
|
|
|
|
|
+ LastUpdatedAt *time.Time `json:"last_updated_at"`
|
|
|
|
|
+ CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
+ UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
+ CfZoneID string `json:"cf_zone_id"`
|
|
|
|
|
+ ZoneName string `json:"zone_name"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListRecordsByZone(ctx context.Context, zoneID int64) ([]ListRecordsByZoneRow, error) {
|
|
func (q *Queries) ListRecordsByZone(ctx context.Context, zoneID int64) ([]ListRecordsByZoneRow, error) {
|
|
@@ -301,6 +309,7 @@ func (q *Queries) ListRecordsByZone(ctx context.Context, zoneID int64) ([]ListRe
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
&i.CfZoneID,
|
|
&i.CfZoneID,
|
|
@@ -321,18 +330,21 @@ func (q *Queries) ListRecordsByZone(ctx context.Context, zoneID int64) ([]ListRe
|
|
|
|
|
|
|
|
const updateRecord = `-- name: UpdateRecord :one
|
|
const updateRecord = `-- name: UpdateRecord :one
|
|
|
UPDATE records
|
|
UPDATE records
|
|
|
-SET name = ?, type = ?, content = ?, proxied = ?, is_static = ?, updated_at = CURRENT_TIMESTAMP
|
|
|
|
|
|
|
+SET name = ?, type = ?, content = ?, proxied = ?, is_static = ?,
|
|
|
|
|
+ last_updated_at = CASE WHEN ? = 1 THEN NULL ELSE last_updated_at END,
|
|
|
|
|
+ updated_at = CURRENT_TIMESTAMP
|
|
|
WHERE id = ?
|
|
WHERE id = ?
|
|
|
-RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, created_at, updated_at
|
|
|
|
|
|
|
+RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, last_updated_at, created_at, updated_at
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type UpdateRecordParams struct {
|
|
type UpdateRecordParams struct {
|
|
|
- Name string `json:"name"`
|
|
|
|
|
- Type string `json:"type"`
|
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
- Proxied int64 `json:"proxied"`
|
|
|
|
|
- IsStatic int64 `json:"is_static"`
|
|
|
|
|
- ID int64 `json:"id"`
|
|
|
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
|
+ Proxied int64 `json:"proxied"`
|
|
|
|
|
+ IsStatic int64 `json:"is_static"`
|
|
|
|
|
+ Column6 interface{} `json:"column_6"`
|
|
|
|
|
+ ID int64 `json:"id"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) UpdateRecord(ctx context.Context, arg UpdateRecordParams) (Record, error) {
|
|
func (q *Queries) UpdateRecord(ctx context.Context, arg UpdateRecordParams) (Record, error) {
|
|
@@ -342,6 +354,7 @@ func (q *Queries) UpdateRecord(ctx context.Context, arg UpdateRecordParams) (Rec
|
|
|
arg.Content,
|
|
arg.Content,
|
|
|
arg.Proxied,
|
|
arg.Proxied,
|
|
|
arg.IsStatic,
|
|
arg.IsStatic,
|
|
|
|
|
+ arg.Column6,
|
|
|
arg.ID,
|
|
arg.ID,
|
|
|
)
|
|
)
|
|
|
var i Record
|
|
var i Record
|
|
@@ -354,6 +367,7 @@ func (q *Queries) UpdateRecord(ctx context.Context, arg UpdateRecordParams) (Rec
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
)
|
|
)
|
|
@@ -362,7 +376,7 @@ func (q *Queries) UpdateRecord(ctx context.Context, arg UpdateRecordParams) (Rec
|
|
|
|
|
|
|
|
const updateRecordContent = `-- name: UpdateRecordContent :exec
|
|
const updateRecordContent = `-- name: UpdateRecordContent :exec
|
|
|
UPDATE records
|
|
UPDATE records
|
|
|
-SET content = ?, updated_at = CURRENT_TIMESTAMP
|
|
|
|
|
|
|
+SET content = ?, last_updated_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
|
|
|
WHERE id = ?
|
|
WHERE id = ?
|
|
|
`
|
|
`
|
|
|
|
|
|
|
@@ -385,7 +399,7 @@ ON CONFLICT(zone_id, cf_record_id) DO UPDATE SET
|
|
|
content = excluded.content,
|
|
content = excluded.content,
|
|
|
proxied = excluded.proxied,
|
|
proxied = excluded.proxied,
|
|
|
updated_at = CURRENT_TIMESTAMP
|
|
updated_at = CURRENT_TIMESTAMP
|
|
|
-RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, created_at, updated_at
|
|
|
|
|
|
|
+RETURNING id, zone_id, cf_record_id, name, type, content, proxied, is_static, last_updated_at, created_at, updated_at
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
type UpsertRecordParams struct {
|
|
type UpsertRecordParams struct {
|
|
@@ -418,6 +432,7 @@ func (q *Queries) UpsertRecord(ctx context.Context, arg UpsertRecordParams) (Rec
|
|
|
&i.Content,
|
|
&i.Content,
|
|
|
&i.Proxied,
|
|
&i.Proxied,
|
|
|
&i.IsStatic,
|
|
&i.IsStatic,
|
|
|
|
|
+ &i.LastUpdatedAt,
|
|
|
&i.CreatedAt,
|
|
&i.CreatedAt,
|
|
|
&i.UpdatedAt,
|
|
&i.UpdatedAt,
|
|
|
)
|
|
)
|