fix: add timestamp columns to “users" table

pull/2572/head
Luke Edwards 7 years ago
parent fdf79639d2
commit 5298f8ea35

@ -6,7 +6,9 @@ exports.up = DB => {
name character varying(255), name character varying(255),
username character varying(255) not null, username character varying(255) not null,
avatar text, avatar text,
token character varying(255) not null token character varying(255) not null,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone
); );
create unique index if not exists users_pkey ON users(id int4_ops); create unique index if not exists users_pkey ON users(id int4_ops);

@ -70,8 +70,6 @@ export function API() {
if (GITHUB_CLIENT_ID) { if (GITHUB_CLIENT_ID) {
app.get('/auth/login', (req, res) => { app.get('/auth/login', (req, res) => {
try { try {
console.log('inside');
const Location = `${OAuth}/authorize?` + stringify({ const Location = `${OAuth}/authorize?` + stringify({
scope: 'read:user', scope: 'read:user',
client_id: GITHUB_CLIENT_ID, client_id: GITHUB_CLIENT_ID,
@ -108,7 +106,7 @@ export function API() {
const [user] = await query(` const [user] = await query(`
insert into users(uid, name, username, avatar, token) insert into users(uid, name, username, avatar, token)
values ($1, $2, $3, $4, $5) on conflict (uid) do update values ($1, $2, $3, $4, $5) on conflict (uid) do update
set (name, username, avatar, token) = ($2, $3, $4, $5) set (name, username, avatar, token, updated_at) = ($2, $3, $4, $5, now())
returning * returning *
`, [id, name, login, avatar_url, access_token]); `, [id, name, login, avatar_url, access_token]);

Loading…
Cancel
Save