finish setup insert method, refactor sql migration file
This commit is contained in:
@@ -67,19 +67,25 @@ type SetupOptions struct {
|
||||
NoBackups bool
|
||||
}
|
||||
|
||||
func (s *SetupOptions) Insert(tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
||||
query := `
|
||||
INSERT INTO featured_content (setup_id, compress_socket, compress_static, css_theme, data_path,
|
||||
fullscreen, hostname, hot_reload, language, local_hostname, port,
|
||||
proxy_ssl, telemetry, update_channel, upnp, delete_nedb, no_backups)
|
||||
func (s *SetupOptions) Query(data *InsertId[uint]) {
|
||||
data.query = `
|
||||
INSERT INTO setup_options (setup_id, css_theme, data_path, hostname, language, local_hostname,
|
||||
update_channel, port, compress_socket, compress_static, fullscreen, hot_reload, proxy_ssl,
|
||||
telemetry, upnp, delete_nedb, no_backups,)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
RETURNING id`
|
||||
}
|
||||
|
||||
args := []any{setupId.id, s.CompressSocket, s.CompressStatic, s.CSSTheme, s.DataPath,
|
||||
s.Fullscreen, s.Hostname, s.HotReload, s.Language, s.LocalHostname, s.Port,
|
||||
s.ProxySSL, s.Telemetry, s.UpdateChannel, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||
func (s *SetupOptions) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||
if data.query == "" {
|
||||
return ErrNoQuery
|
||||
}
|
||||
|
||||
err := tx.QueryRowx(query, args...).Scan(&s.ID)
|
||||
args := []any{data.id, s.CSSTheme, s.DataPath, s.Hostname, s.Language, s.LocalHostname,
|
||||
s.UpdateChannel, s.Port, s.CompressSocket, s.CompressStatic, s.Fullscreen, s.HotReload,
|
||||
s.ProxySSL, s.Telemetry, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||
|
||||
err := tx.QueryRowx(data.query, args...).Scan(&s.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -87,19 +93,16 @@ func (s *SetupOptions) Insert(tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SetupOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
||||
query := `
|
||||
INSERT INTO featured_content (setup_id, compress_socket, compress_static, css_theme, data_path,
|
||||
fullscreen, hostname, hot_reload, language, local_hostname, port,
|
||||
proxy_ssl, telemetry, update_channel, upnp, delete_nedb, no_backups)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||
RETURNING id`
|
||||
func (s *SetupOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||
if data.query == "" {
|
||||
return ErrNoQuery
|
||||
}
|
||||
|
||||
args := []any{setupId.id, s.CompressSocket, s.CompressStatic, s.CSSTheme, s.DataPath,
|
||||
s.Fullscreen, s.Hostname, s.HotReload, s.Language, s.LocalHostname, s.Port,
|
||||
s.ProxySSL, s.Telemetry, s.UpdateChannel, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||
args := []any{data.id, s.CSSTheme, s.DataPath, s.Hostname, s.Language, s.LocalHostname,
|
||||
s.UpdateChannel, s.Port, s.CompressSocket, s.CompressStatic, s.Fullscreen, s.HotReload,
|
||||
s.ProxySSL, s.Telemetry, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||
|
||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&s.ID)
|
||||
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&s.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user