update tables primary key to use serial/integer
This commit is contained in:
parent
86fd4b73b6
commit
f251f52fa9
8 changed files with 14 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id TEXT PRIMARY KEY,
|
id SERIAL PRIMARY KEY NOT NULL,
|
||||||
email TEXT UNIQUE NOT NULL,
|
email TEXT UNIQUE NOT NULL,
|
||||||
password_hash TEXT NULL, -- Allow null for passwordless login
|
password_hash TEXT NULL, -- Allow null for passwordless login
|
||||||
pending_email TEXT NULL, -- Store new email when changing email
|
pending_email TEXT NULL, -- Store new email when changing email
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE TABLE IF NOT EXISTS tokens (
|
CREATE TABLE IF NOT EXISTS tokens (
|
||||||
id TEXT PRIMARY KEY,
|
id SERIAL PRIMARY KEY NOT NULL,
|
||||||
user_id TEXT NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
token TEXT UNIQUE NOT NULL,
|
token TEXT UNIQUE NOT NULL,
|
||||||
expires_at TIMESTAMP NOT NULL,
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE TABLE IF NOT EXISTS profiles (
|
CREATE TABLE IF NOT EXISTS profiles (
|
||||||
id TEXT PRIMARY KEY,
|
id SERIAL PRIMARY KEY NOT NULL,
|
||||||
user_id TEXT UNIQUE NOT NULL,
|
user_id INTEGER UNIQUE NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE TABLE IF NOT EXISTS files (
|
CREATE TABLE IF NOT EXISTS files (
|
||||||
id TEXT PRIMARY KEY,
|
id SERIAL PRIMARY KEY NOT NULL,
|
||||||
user_id TEXT NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
owner_type TEXT NOT NULL,
|
owner_type TEXT NOT NULL,
|
||||||
owner_id TEXT NOT NULL,
|
owner_id TEXT NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
ID string `db:"id"`
|
ID uint64 `db:"id"`
|
||||||
UserID string `db:"user_id"` // Who owns/created this file
|
UserID uint64 `db:"user_id"` // Who owns/created this file
|
||||||
OwnerType string `db:"owner_type"` // "user", "profile", etc. - the entity that owns the file
|
OwnerType string `db:"owner_type"` // "user", "profile", etc. - the entity that owns the file
|
||||||
OwnerID string `db:"owner_id"` // Polymorphic FK
|
OwnerID string `db:"owner_id"` // Polymorphic FK
|
||||||
Type string `db:"type"`
|
Type string `db:"type"`
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package model
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Profile struct {
|
type Profile struct {
|
||||||
ID string `db:"id"`
|
ID uint64 `db:"id"`
|
||||||
UserID string `db:"user_id"`
|
UserID uint64 `db:"user_id"`
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
CreatedAt time.Time `db:"created_at"`
|
CreatedAt time.Time `db:"created_at"`
|
||||||
UpdatedAt time.Time `db:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Token struct {
|
type Token struct {
|
||||||
ID string `db:"id"`
|
ID uint64 `db:"id"`
|
||||||
UserID string `db:"user_id"`
|
UserID uint64 `db:"user_id"`
|
||||||
Type string `db:"type"` // "email_verify" or "password_reset"
|
Type string `db:"type"` // "email_verify" or "password_reset"
|
||||||
Token string `db:"token"`
|
Token string `db:"token"`
|
||||||
ExpiresAt time.Time `db:"expires_at"`
|
ExpiresAt time.Time `db:"expires_at"`
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package model
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID string `db:"id"`
|
ID uint64 `db:"id"`
|
||||||
Email string `db:"email"`
|
Email string `db:"email"`
|
||||||
// Allow null for passwordless users
|
// Allow null for passwordless users
|
||||||
PasswordHash *string `db:"password_hash"`
|
PasswordHash *string `db:"password_hash"`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue