change joined_at to added_at

This commit is contained in:
lyx0 2022-08-09 20:08:32 +02:00
parent 3f16128812
commit 3abbeba46f
2 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@ import (
type Channel struct { type Channel struct {
ID int `json:"id"` ID int `json:"id"`
JoinedAt time.Time `json:"-"` AddedAt time.Time `json:"-"`
Login string `json:"login"` Login string `json:"login"`
TwitchID string `json:"twitchid"` TwitchID string `json:"twitchid"`
Announce bool `json:"announce"` Announce bool `json:"announce"`
@ -22,16 +22,16 @@ func (c ChannelModel) Insert(channel *Channel) error {
query := ` query := `
INSERT INTO channels (login, twitchid, announce) INSERT INTO channels (login, twitchid, announce)
VALUES ($1, $2, $3) VALUES ($1, $2, $3)
RETURNING id, joined_at` RETURNING id, added_at`
args := []interface{}{channel.Login, channel.TwitchID, channel.Announce} args := []interface{}{channel.Login, channel.TwitchID, channel.Announce}
return c.DB.QueryRow(query, args...).Scan(&channel.ID, &channel.JoinedAt) return c.DB.QueryRow(query, args...).Scan(&channel.ID, &channel.AddedAt)
} }
func (c ChannelModel) Get(login string) (*Channel, error) { func (c ChannelModel) Get(login string) (*Channel, error) {
query := ` query := `
SELECT id, joined_at, login, twitchid, announce SELECT id, added_at, login, twitchid, announce
FROM channels FROM channels
WHERE login = $1` WHERE login = $1`
@ -39,7 +39,7 @@ func (c ChannelModel) Get(login string) (*Channel, error) {
err := c.DB.QueryRow(query, login).Scan( err := c.DB.QueryRow(query, login).Scan(
&channel.ID, &channel.ID,
&channel.JoinedAt, &channel.AddedAt,
&channel.Login, &channel.Login,
&channel.TwitchID, &channel.TwitchID,
&channel.Announce, &channel.Announce,

View file

@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS channels ( CREATE TABLE IF NOT EXISTS channels (
id bigserial PRIMARY KEY, id bigserial PRIMARY KEY,
joined_at timestamp(0) with time zone NOT NULL DEFAULT NOW(), added_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
login text NOT NULL, login text NOT NULL,
twitchid text NOT NULL, twitchid text NOT NULL,
announce BOOLEAN NOT NULL announce BOOLEAN NOT NULL