Skip to content

Commit

Permalink
fix: access tokens migration
Browse files Browse the repository at this point in the history
add expires_at
  • Loading branch information
aymanbagabas committed Jul 25, 2023
1 parent f11b819 commit 907b110
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions server/db/migrate/0002_create_lfs_tables_postgres.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ CREATE TABLE IF NOT EXISTS lfs_objects (
oid TEXT NOT NULL,
size INTEGER NOT NULL,
repo_id INTEGER NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL,
UNIQUE (oid, repo_id),
CONSTRAINT repo_id_fk
FOREIGN KEY(repo_id) REFERENCES repos(id)
Expand All @@ -18,8 +18,8 @@ CREATE TABLE IF NOT EXISTS lfs_locks (
user_id INTEGER NOT NULL,
path TEXT NOT NULL,
refname TEXT,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL,
UNIQUE (repo_id, path),
CONSTRAINT repo_id_fk
FOREIGN KEY(repo_id) REFERENCES repos(id)
Expand Down
1 change: 1 addition & 0 deletions server/db/migrate/0003_password_tokens_postgres.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS access_tokens (
name text NOT NULL,
token TEXT NOT NULL UNIQUE,
user_id INTEGER NOT NULL,
expires_at TIMESTAMP,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL,
CONSTRAINT user_id_fk
Expand Down
1 change: 1 addition & 0 deletions server/db/migrate/0003_password_tokens_sqlite.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS access_tokens (
token text NOT NULL UNIQUE,
name text NOT NULL,
user_id INTEGER NOT NULL,
expires_at DATETIME,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL,
CONSTRAINT user_id_fk
Expand Down
16 changes: 10 additions & 6 deletions server/db/models/access_token.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package models

import "time"
import (
"database/sql"
"time"
)

// AccessToken represents an access token.
type AccessToken struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
Token string `db:"token"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
Token string `db:"token"`
ExpiresAt sql.NullTime `db:"expires_at"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}

0 comments on commit 907b110

Please sign in to comment.