From 3abbeba46fb2ef235d7323e2a4dae85ca43555a0 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:08:32 +0200 Subject: [PATCH] change joined_at to added_at --- internal/data/channel.go | 10 +++++----- migrations/000001_create_channels_table.up.sql | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/data/channel.go b/internal/data/channel.go index d7f84fc..5ecbd79 100644 --- a/internal/data/channel.go +++ b/internal/data/channel.go @@ -8,7 +8,7 @@ import ( type Channel struct { ID int `json:"id"` - JoinedAt time.Time `json:"-"` + AddedAt time.Time `json:"-"` Login string `json:"login"` TwitchID string `json:"twitchid"` Announce bool `json:"announce"` @@ -22,16 +22,16 @@ func (c ChannelModel) Insert(channel *Channel) error { query := ` INSERT INTO channels (login, twitchid, announce) VALUES ($1, $2, $3) - RETURNING id, joined_at` + RETURNING id, added_at` 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) { query := ` - SELECT id, joined_at, login, twitchid, announce + SELECT id, added_at, login, twitchid, announce FROM channels WHERE login = $1` @@ -39,7 +39,7 @@ func (c ChannelModel) Get(login string) (*Channel, error) { err := c.DB.QueryRow(query, login).Scan( &channel.ID, - &channel.JoinedAt, + &channel.AddedAt, &channel.Login, &channel.TwitchID, &channel.Announce, diff --git a/migrations/000001_create_channels_table.up.sql b/migrations/000001_create_channels_table.up.sql index f884116..9a76bef 100644 --- a/migrations/000001_create_channels_table.up.sql +++ b/migrations/000001_create_channels_table.up.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS channels ( 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, twitchid text NOT NULL, announce BOOLEAN NOT NULL