Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Add structured database migrations (#4888)

Gabe Kangas427dc1f21abe
diff --git a/.github/workflows/activitypub-tests.yaml b/.github/workflows/activitypub-tests.yaml
index 0eb2f9df61..683e566a1f 100644
--- a/.github/workflows/activitypub-tests.yaml
+++ b/.github/workflows/activitypub-tests.yaml
@@ -35,7 +35,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
- go-version: "^1.23"
+ go-version: "1.26.2"
cache: true
- name: Install Caddy
@@ -75,7 +75,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
- go-version: "^1.23"
+ go-version: "1.26.2"
cache: true
- name: Install Caddy
@@ -115,7 +115,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
- go-version: "^1.23"
+ go-version: "1.26.2"
cache: true
- name: Install dependencies
diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml
index 02d94081da..197bf7089d 100644
--- a/.github/workflows/copilot-setup-steps.yml
+++ b/.github/workflows/copilot-setup-steps.yml
@@ -31,7 +31,7 @@ jobs:
- name: Install go
uses: actions/setup-go@v6
with:
- go-version: '^1'
+ go-version: '1.26.2'
cache: true
- name: Install ffmpeg
diff --git a/.github/workflows/go-tests.yaml b/.github/workflows/go-tests.yaml
index 58acd396fa..95dfe79fb5 100644
--- a/.github/workflows/go-tests.yaml
+++ b/.github/workflows/go-tests.yaml
@@ -20,7 +20,6 @@ jobs:
test:
strategy:
matrix:
- go-version: ${{ github.event_name == 'pull_request' && fromJSON('["1.24.x"]') || fromJSON('["1.23.x", "1.24.x"]') }}
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest", "ubuntu-24.04-arm"]') }}
runs-on: ${{ matrix.os }}
steps:
@@ -48,7 +47,7 @@ jobs:
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
uses: actions/setup-go@v6
with:
- go-version: '^1'
+ go-version: '1.26.2'
cache: true
- name: Run tests
@@ -91,7 +90,7 @@ jobs:
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
uses: actions/setup-go@v6
with:
- go-version: '^1'
+ go-version: '1.26.2'
cache: true
- name: Run tests
diff --git a/.golangci.yml b/.golangci.yml
index 991bfdf603..911c4cce2a 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,6 +1,6 @@
version: "2"
run:
- go: "1.25.3"
+ go: "1.26"
modules-download-mode: readonly
tests: false
linters:
@@ -64,6 +64,7 @@ linters:
- third_party$
- builtin$
- examples$
+ - node_modules
issues:
max-issues-per-linter: 0
max-same-issues: 0
@@ -76,3 +77,4 @@ formatters:
- third_party$
- builtin$
- examples$
+ - node_modules
diff --git a/Earthfile b/Earthfile
index 2f56127a58..9dba7cf54a 100644
--- a/Earthfile
+++ b/Earthfile
@@ -17,6 +17,7 @@ docker-all:
crosscompiler:
# This image is missing a few platforms, so we'll add them locally
FROM --platform=linux/amd64 ghcr.io/gabek/go-crosscompile:latest
+ ENV GOTOOLCHAIN=auto
RUN apk add --update --no-cache tar gzip upx >> /dev/null
RUN curl -sfL "https://owncast-infra.nyc3.cdn.digitaloceanspaces.com/build/armv7l-linux-musleabihf-cross.tgz" | tar zxf - -C /usr/ --strip-components=1
RUN curl -sfL "https://owncast-infra.nyc3.cdn.digitaloceanspaces.com/build/i686-linux-musl-cross.tgz" | tar zxf - -C /usr/ --strip-components=1
@@ -202,12 +203,14 @@ dockerfile:
unit-tests:
FROM --platform=linux/amd64 ghcr.io/gabek/go-crosscompile:latest
+ ENV GOTOOLCHAIN=auto
COPY . /build
WORKDIR /build
RUN go test ./...
api-tests:
FROM --platform=linux/amd64 ghcr.io/gabek/go-crosscompile:latest
+ ENV GOTOOLCHAIN=auto
RUN apk add npm font-noto && fc-cache -f
COPY . /build
WORKDIR /build/test/automated/api
@@ -216,6 +219,7 @@ api-tests:
hls-tests:
FROM --platform=linux/amd64 ghcr.io/gabek/go-crosscompile:latest
+ ENV GOTOOLCHAIN=auto
RUN apk add npm font-noto && fc-cache -f
COPY . /build
WORKDIR /build/test/automated/hls
diff --git a/activitypub/persistence/followers.go b/activitypub/persistence/followers.go
deleted file mode 100644
index 1a5cebdebd..0000000000
--- a/activitypub/persistence/followers.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package persistence
-
-import (
- log "github.com/sirupsen/logrus"
-)
-
-func createFederationFollowersTable() {
- log.Traceln("Creating federation followers table...")
-
- createTableSQL := `CREATE TABLE IF NOT EXISTS ap_followers (
- "iri" TEXT NOT NULL,
- "inbox" TEXT NOT NULL,
- "shared_inbox" TEXT,
- "name" TEXT,
- "username" TEXT NOT NULL,
- "image" TEXT,
- "request" TEXT NOT NULL,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- "approved_at" TIMESTAMP,
- "disabled_at" TIMESTAMP,
- "request_object" BLOB,
- "last_validated_at" TIMESTAMP,
- "first_validation_failure_at" TIMESTAMP,
- PRIMARY KEY (iri));`
- _datastore.MustExec(createTableSQL)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_iri ON ap_followers (iri);`)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_approved_at ON ap_followers (approved_at);`)
-}
diff --git a/activitypub/persistence/followers_test.go b/activitypub/persistence/followers_test.go
index 937aed92e2..f1044a8697 100644
--- a/activitypub/persistence/followers_test.go
+++ b/activitypub/persistence/followers_test.go
@@ -25,7 +25,6 @@ var followers = []models.Follower{}
func setup() {
data.SetupPersistence(":memory:")
_datastore = data.GetDatastore()
- createFederationFollowersTable()
followersRepo := followersrepository.New(_datastore)
@@ -153,7 +152,6 @@ func TestGetUniqueDeliveryInboxes(t *testing.T) {
data.SetupPersistence(":memory:")
ds := data.GetDatastore()
_datastore = ds
- createFederationFollowersTable()
followersRepo := followersrepository.New(ds)
// Create followers from server1 with a shared inbox (3 users, 1 shared inbox)
@@ -251,7 +249,6 @@ func TestSharedInboxPreferredOverIndividual(t *testing.T) {
data.SetupPersistence(":memory:")
ds := data.GetDatastore()
_datastore = ds
- createFederationFollowersTable()
followersRepo := followersrepository.New(ds)
// Create a single follower with both individual and shared inbox
@@ -288,7 +285,6 @@ func TestIndividualInboxUsedWhenNoSharedInbox(t *testing.T) {
data.SetupPersistence(":memory:")
ds := data.GetDatastore()
_datastore = ds
- createFederationFollowersTable()
followersRepo := followersrepository.New(ds)
// Create a follower without a shared inbox
diff --git a/activitypub/persistence/followersrepository/followersrepository.go b/activitypub/persistence/followersrepository/followersrepository.go
index 5ba6113e85..a4a197d594 100644
--- a/activitypub/persistence/followersrepository/followersrepository.go
+++ b/activitypub/persistence/followersrepository/followersrepository.go
@@ -92,8 +92,8 @@ func (r *SqlFollowersRepository) GetFollowers(limit int, offset int) ([]models.F
}
followersResult, err := r.datastore.GetQueries().GetFederationFollowersWithOffset(ctx, db.GetFederationFollowersWithOffsetParams{
- Limit: utils.SafeIntToInt32(limit),
- Offset: utils.SafeIntToInt32(offset),
+ Limit: int64(limit),
+ Offset: int64(offset),
})
if err != nil {
return nil, 0, err
@@ -379,7 +379,7 @@ func (r *SqlFollowersRepository) removeFollow(actor *url.URL) error {
// GetFollowersToValidate returns followers needing validation, ordered by oldest validated first.
func (r *SqlFollowersRepository) GetFollowersToValidate(limit int) ([]models.Follower, error) {
ctx := context.Background()
- followersResult, err := r.datastore.GetQueries().GetFollowersToValidate(ctx, utils.SafeIntToInt32(limit))
+ followersResult, err := r.datastore.GetQueries().GetFollowersToValidate(ctx, int64(limit))
if err != nil {
return nil, err
}
diff --git a/activitypub/persistence/persistence.go b/activitypub/persistence/persistence.go
index 2882241d93..ed486b423e 100644
--- a/activitypub/persistence/persistence.go
+++ b/activitypub/persistence/persistence.go
@@ -12,7 +12,6 @@ import (
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/db"
"github.com/owncast/owncast/models"
- "github.com/owncast/owncast/utils"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
@@ -21,11 +20,10 @@ import (
var _datastore *data.Datastore
// Setup will initialize the ActivityPub persistence layer with the provided datastore.
+// ActivityPub-related tables (ap_followers, ap_outbox, ap_accepted_activities)
+// are created by the goose migrations package.
func Setup(datastore *data.Datastore) {
_datastore = datastore
- createFederationFollowersTable()
- createFederationOutboxTable()
- createFederatedActivitiesTable()
addFollowersFixtureData()
}
@@ -34,37 +32,6 @@ func GetDatastore() *data.Datastore {
return _datastore
}
-// createFederatedActivitiesTable will create the accepted
-// activities table if needed.
-func createFederatedActivitiesTable() {
- createTableSQL := `CREATE TABLE IF NOT EXISTS ap_accepted_activities (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "iri" TEXT NOT NULL,
- "actor" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "timestamp" TIMESTAMP NOT NULL
- );`
-
- _datastore.MustExec(createTableSQL)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_iri_actor_index ON ap_accepted_activities (iri,actor);`)
-}
-
-func createFederationOutboxTable() {
- log.Traceln("Creating federation outbox table...")
- createTableSQL := `CREATE TABLE IF NOT EXISTS ap_outbox (
- "iri" TEXT NOT NULL,
- "value" BLOB,
- "type" TEXT NOT NULL,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- "live_notification" BOOLEAN DEFAULT FALSE,
- PRIMARY KEY (iri));`
-
- _datastore.MustExec(createTableSQL)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_iri ON ap_outbox (iri);`)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_type ON ap_outbox (type);`)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_live_notification ON ap_outbox (live_notification);`)
-}
-
// GetOutboxPostCount will return the number of posts in the outbox.
func GetOutboxPostCount() (int64, error) {
ctx := context.Background()
@@ -77,7 +44,7 @@ func GetOutbox(limit int, offset int) (vocab.ActivityStreamsOrderedCollection, e
orderedItems := streams.NewActivityStreamsOrderedItemsProperty()
rows, err := _datastore.GetQueries().GetOutboxWithOffset(
context.Background(),
- db.GetOutboxWithOffsetParams{Limit: utils.SafeIntToInt32(limit), Offset: utils.SafeIntToInt32(offset)},
+ db.GetOutboxWithOffsetParams{Limit: int64(limit), Offset: int64(offset)},
)
if err != nil {
return collection, err
@@ -149,8 +116,8 @@ func SaveInboundFediverseActivity(objectIRI string, actorIRI string, eventType s
func GetInboundActivities(limit int, offset int) ([]models.FederatedActivity, int, error) {
ctx := context.Background()
rows, err := _datastore.GetQueries().GetInboundActivitiesWithOffset(ctx, db.GetInboundActivitiesWithOffsetParams{
- Limit: utils.SafeIntToInt32(limit),
- Offset: utils.SafeIntToInt32(offset),
+ Limit: int64(limit),
+ Offset: int64(offset),
})
if err != nil {
return nil, 0, err
diff --git a/auth/persistence.go b/auth/persistence.go
deleted file mode 100644
index 773b6fc5b6..0000000000
--- a/auth/persistence.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package auth
-
-import (
- "github.com/owncast/owncast/core/data"
-)
-
-var _datastore *data.Datastore
-
-// Setup will initialize auth persistence.
-func Setup(db *data.Datastore) {
- _datastore = db
-
- createTableSQL := `CREATE TABLE IF NOT EXISTS auth (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "user_id" TEXT NOT NULL,
- "token" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
- FOREIGN KEY(user_id) REFERENCES users(id)
- );`
- _datastore.MustExec(createTableSQL)
- _datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_auth_token ON auth (token);`)
-}
diff --git a/config/constants.go b/config/constants.go
index ae560b2015..6f3c78bdb2 100644
--- a/config/constants.go
+++ b/config/constants.go
@@ -4,7 +4,7 @@ import "path/filepath"
const (
// StaticVersionNumber is the version of Owncast that is used when it's not overwritten via build-time settings.
- StaticVersionNumber = "0.2.4" // Shown when you build from develop
+ StaticVersionNumber = "0.3.0" // Shown when you build from develop
// FfmpegSuggestedVersion is the version of ffmpeg we suggest.
FfmpegSuggestedVersion = "v4.1.5" // Requires the v
// DataDirectory is the directory we save data to.
diff --git a/core/chat/persistence.go b/core/chat/persistence.go
index 8c9090dae3..decd6b6738 100644
--- a/core/chat/persistence.go
+++ b/core/chat/persistence.go
@@ -4,8 +4,6 @@ import (
"time"
"github.com/owncast/owncast/core/data"
- "github.com/owncast/owncast/persistence/authrepository"
- "github.com/owncast/owncast/persistence/tables"
)
var _datastore *data.Datastore
@@ -16,10 +14,6 @@ const (
func setupPersistence() {
_datastore = data.GetDatastore()
- tables.CreateMessagesTable(_datastore.DB)
-
- authRepository := authrepository.Get()
- authRepository.CreateBanIPTable(_datastore.DB)
chatDataPruner := time.NewTicker(5 * time.Minute)
go func() {
diff --git a/core/core.go b/core/core.go
index 17cc856125..3b9184ce56 100644
--- a/core/core.go
+++ b/core/core.go
@@ -7,17 +7,14 @@ import (
log "github.com/sirupsen/logrus"
- "github.com/owncast/owncast/auth"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core/chat"
- "github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/core/rtmp"
"github.com/owncast/owncast/core/transcoder"
"github.com/owncast/owncast/core/webhooks"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/persistence/configrepository"
"github.com/owncast/owncast/persistence/notificationsrepository"
- "github.com/owncast/owncast/persistence/tables"
"github.com/owncast/owncast/utils"
"github.com/owncast/owncast/yp"
)
@@ -57,9 +54,6 @@ func Start() error {
log.Errorln("storage error", err)
}
- tables.SetupUsers(data.GetDatastore().DB)
- auth.Setup(data.GetDatastore())
-
fileWriter.SetupFileWriterReceiverService(&handler)
if err := createInitialOfflineState(); err != nil {
@@ -83,7 +77,7 @@ func Start() error {
webhooks.SetupWebhooks(GetStatus)
- notificationsrepository.Setup(data.GetStore())
+ notificationsrepository.Setup()
return nil
}
diff --git a/core/data/data.go b/core/data/data.go
index 5063f21e92..f4ee18e24f 100644
--- a/core/data/data.go
+++ b/core/data/data.go
@@ -11,17 +11,12 @@ import (
"path/filepath"
"time"
- "github.com/owncast/owncast/persistence/tables"
-
"github.com/owncast/owncast/config"
+ "github.com/owncast/owncast/persistence/migrations"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
)
-const (
- schemaVersion = 9
-)
-
var (
_db *sql.DB
_datastore *Datastore
@@ -75,45 +70,11 @@ func SetupPersistence(file string) error {
_, _ = db.Exec("pragma temp_store = memory")
_, _ = db.Exec("pragma wal_checkpoint(full)")
- tables.CreateConfigTable(db)
- tables.CreateWebhooksTable(db)
- tables.CreateUsersTable(db)
- tables.CreateAccessTokenTable(db)
-
- if _, err := db.Exec(`CREATE TABLE IF NOT EXISTS config (
- "key" string NOT NULL PRIMARY KEY,
- "value" TEXT
- );`); err != nil {
- return err
- }
-
- var version int
- err := db.QueryRow("SELECT value FROM config WHERE key='version'").
- Scan(&version)
- if err != nil {
- if err != sql.ErrNoRows {
- return err
- }
-
- // fresh database: initialize it with the current schema version
- _, err := db.Exec("INSERT INTO config(key, value) VALUES(?, ?)", "version", schemaVersion)
- if err != nil {
- return err
- }
- version = schemaVersion
- }
-
- // is database from a newer Owncast version?
- if version > schemaVersion {
- return fmt.Errorf("incompatible database version %d (versions up to %d are supported)",
- version, schemaVersion)
- }
-
- // is database schema outdated?
- if version < schemaVersion {
- if err := tables.MigrateDatabaseSchema(db, version, schemaVersion); err != nil {
- return err
- }
+ // Bring the schema up to date. The migrations package owns all table
+ // creation and schema changes; existing pre-goose installs are caught up
+ // automatically by its legacy-bridge step.
+ if err := migrations.Run(db); err != nil {
+ return fmt.Errorf("running database migrations: %w", err)
}
_datastore = &Datastore{}
diff --git a/db/models.go b/db/models.go
index 63c1373409..0873bcec98 100644
--- a/db/models.go
+++ b/db/models.go
@@ -10,7 +10,7 @@ import (
)
type ApAcceptedActivity struct {
- ID int32
+ ID int64
Iri string
Actor string
Type string
@@ -25,10 +25,10 @@ type ApFollower struct {
Username string
Image sql.NullString
Request string
- RequestObject []byte
CreatedAt sql.NullTime
ApprovedAt sql.NullTime
DisabledAt sql.NullTime
+ RequestObject []byte
LastValidatedAt sql.NullTime
FirstValidationFailureAt sql.NullTime
}
@@ -42,13 +42,19 @@ type ApOutbox struct {
}
type Auth struct {
- ID int32
+ ID int64
UserID string
Token string
Type string
Timestamp time.Time
}
+type Datastore struct {
+ Key string
+ Value []byte
+ Timestamp time.Time
+}
+
type IpBan struct {
IpAddress string
Notes sql.NullString
@@ -69,7 +75,7 @@ type Message struct {
}
type Notification struct {
- ID int32
+ ID int64
Channel string
Destination string
CreatedAt sql.NullTime
@@ -78,15 +84,15 @@ type Notification struct {
type User struct {
ID string
DisplayName string
- DisplayColor int32
+ DisplayColor int64
CreatedAt sql.NullTime
DisabledAt sql.NullTime
PreviousNames sql.NullString
NamechangedAt sql.NullTime
- Scopes sql.NullString
AuthenticatedAt sql.NullTime
+ Scopes sql.NullString
Type sql.NullString
- LastUsed interface{}
+ LastUsed sql.NullTime
}
type UserAccessToken struct {
@@ -94,3 +100,11 @@ type UserAccessToken struct {
UserID string
Timestamp time.Time
}
+
+type Webhook struct {
+ ID int64
+ Url string
+ Events string
+ Timestamp sql.NullTime
+ LastUsed sql.NullTime
+}
diff --git a/db/query.sql b/db/query.sql
index a816781d43..4add1f4778 100644
--- a/db/query.sql
+++ b/db/query.sql
@@ -3,13 +3,13 @@
-- Federation related queries.
-- name: GetFollowerCount :one
-SElECT count(*) FROM ap_followers WHERE approved_at is not null;
+SELECT count(*) FROM ap_followers WHERE approved_at is not null;
-- name: GetLocalPostCount :one
-SElECT count(*) FROM ap_outbox;
+SELECT count(*) FROM ap_outbox;
-- name: GetFederationFollowersWithOffset :many
-SELECT iri, inbox, shared_inbox, name, username, image, created_at FROM ap_followers WHERE approved_at is not null ORDER BY created_at DESC LIMIT $1 OFFSET $2;
+SELECT iri, inbox, shared_inbox, name, username, image, created_at FROM ap_followers WHERE approved_at is not null ORDER BY created_at DESC LIMIT ? OFFSET ?;
-- name: GetRejectedAndBlockedFollowers :many
SELECT iri, name, username, image, created_at, disabled_at FROM ap_followers WHERE disabled_at is not null;
@@ -18,113 +18,115 @@ SELECT iri, name, username, image, created_at, disabled_at FROM ap_followers WHE
SELECT iri, inbox, shared_inbox, name, username, image, created_at FROM ap_followers WHERE approved_at IS null AND disabled_at is null;
-- name: ApproveFederationFollower :exec
-UPDATE ap_followers SET approved_at = $1, disabled_at = null WHERE iri = $2;
+UPDATE ap_followers SET approved_at = ?, disabled_at = null WHERE iri = ?;
-- name: RejectFederationFollower :exec
-UPDATE ap_followers SET approved_at = null, disabled_at = $1 WHERE iri = $2;
+UPDATE ap_followers SET approved_at = null, disabled_at = ? WHERE iri = ?;
-- name: GetFollowerByIRI :one
-SELECT iri, inbox, shared_inbox, name, username, image, request, request_object, created_at, approved_at, disabled_at FROM ap_followers WHERE iri = $1;
+SELECT iri, inbox, shared_inbox, name, username, image, request, request_object, created_at, approved_at, disabled_at FROM ap_followers WHERE iri = ?;
-- name: GetOutboxWithOffset :many
-SELECT value FROM ap_outbox LIMIT $1 OFFSET $2;
+SELECT value FROM ap_outbox LIMIT ? OFFSET ?;
-- name: GetObjectFromOutboxByIRI :one
-SELECT value, live_notification, created_at FROM ap_outbox WHERE iri = $1;
+SELECT value, live_notification, created_at FROM ap_outbox WHERE iri = ?;
-- name: RemoveFollowerByIRI :exec
-DELETE FROM ap_followers WHERE iri = $1;
+DELETE FROM ap_followers WHERE iri = ?;
-- name: AddFollower :exec
-INSERT INTO ap_followers(iri, inbox, shared_inbox, request, request_object, name, username, image, approved_at) values($1, $2, $3, $4, $5, $6, $7, $8, $9);
+INSERT INTO ap_followers(iri, inbox, shared_inbox, request, request_object, name, username, image, approved_at) values(?, ?, ?, ?, ?, ?, ?, ?, ?);
-- name: AddToOutbox :exec
-INSERT INTO ap_outbox(iri, value, type, live_notification) values($1, $2, $3, $4);
+INSERT INTO ap_outbox(iri, value, type, live_notification) values(?, ?, ?, ?);
-- name: AddToAcceptedActivities :exec
-INSERT INTO ap_accepted_activities(iri, actor, type, timestamp) values($1, $2, $3, $4);
+INSERT INTO ap_accepted_activities(iri, actor, type, timestamp) values(?, ?, ?, ?);
-- name: GetInboundActivityCount :one
SELECT count(*) FROM ap_accepted_activities;
-- name: GetInboundActivitiesWithOffset :many
-SELECT iri, actor, type, timestamp FROM ap_accepted_activities ORDER BY timestamp DESC LIMIT $1 OFFSET $2;
+SELECT iri, actor, type, timestamp FROM ap_accepted_activities ORDER BY timestamp DESC LIMIT ? OFFSET ?;
-- name: DoesInboundActivityExist :one
-SELECT count(*) FROM ap_accepted_activities WHERE iri = $1 AND actor = $2 AND TYPE = $3;
+SELECT count(*) FROM ap_accepted_activities WHERE iri = ? AND actor = ? AND TYPE = ?;
-- name: UpdateFollowerByIRI :exec
-UPDATE ap_followers SET inbox = $1, shared_inbox = $2, name = $3, username = $4, image = $5 WHERE iri = $6;
+UPDATE ap_followers SET inbox = ?, shared_inbox = ?, name = ?, username = ?, image = ? WHERE iri = ?;
-- name: GetFollowersToValidate :many
SELECT iri, inbox, shared_inbox, name, username, image, first_validation_failure_at
FROM ap_followers
WHERE approved_at IS NOT NULL AND disabled_at IS NULL
ORDER BY last_validated_at ASC NULLS FIRST
-LIMIT $1;
+LIMIT ?;
-- name: UpdateFollowerValidationSuccess :exec
UPDATE ap_followers
-SET last_validated_at = $1, first_validation_failure_at = NULL
-WHERE iri = $2;
+SET last_validated_at = ?, first_validation_failure_at = NULL
+WHERE iri = ?;
-- name: UpdateFollowerValidationFailure :exec
UPDATE ap_followers
-SET last_validated_at = $1, first_validation_failure_at = COALESCE(first_validation_failure_at, $1)
-WHERE iri = $2;
+SET last_validated_at = @last_validated_at, first_validation_failure_at = COALESCE(first_validation_failure_at, @last_validated_at)
+WHERE iri = @iri;
-- name: GetUniqueDeliveryInboxes :many
SELECT COALESCE(shared_inbox, inbox) as delivery_inbox FROM ap_followers WHERE approved_at is not null GROUP BY delivery_inbox;
-- name: BanIPAddress :exec
-INSERT INTO ip_bans(ip_address, notes) values($1, $2);
+INSERT INTO ip_bans(ip_address, notes) values(?, ?);
-- name: RemoveIPAddressBan :exec
-DELETE FROM ip_bans WHERE ip_address = $1;
+DELETE FROM ip_bans WHERE ip_address = ?;
-- name: IsIPAddressBlocked :one
-SELECT count(*) FROM ip_bans WHERE ip_address = $1;
+SELECT count(*) FROM ip_bans WHERE ip_address = ?;
-- name: GetIPAddressBans :many
SELECT * FROM ip_bans;
+
-- name: AddNotification :exec
-INSERT INTO notifications (channel, destination) VALUES($1, $2);
+INSERT INTO notifications (channel, destination) VALUES(?, ?);
-- name: GetNotificationDestinationsForChannel :many
-SELECT destination FROM notifications WHERE channel = $1;
+SELECT destination FROM notifications WHERE channel = ?;
-- name: RemoveNotificationDestinationForChannel :exec
-DELETE FROM notifications WHERE channel = $1 AND destination = $2;
+DELETE FROM notifications WHERE channel = ? AND destination = ?;
+
-- name: AddAuthForUser :exec
-INSERT INTO auth(user_id, token, type) values($1, $2, $3);
+INSERT INTO auth(user_id, token, type) values(?, ?, ?);
-- name: GetUserByAuth :one
-SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM auth, users WHERE token = $1 AND auth.type = $2 AND users.id = auth.user_id;
+SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM auth, users WHERE token = ? AND auth.type = ? AND users.id = auth.user_id;
-- name: AddAccessTokenForUser :exec
-INSERT INTO user_access_tokens(token, user_id) values($1, $2);
+INSERT INTO user_access_tokens(token, user_id) values(?, ?);
-- name: GetUserByAccessToken :one
-SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM users, user_access_tokens WHERE token = $1 AND users.id = user_id;
+SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM users, user_access_tokens WHERE token = ? AND users.id = user_id;
-- name: GetUserDisplayNameByToken :one
-SELECT display_name FROM users, user_access_tokens WHERE token = $1 AND users.id = user_id AND disabled_at = NULL;
+SELECT display_name FROM users JOIN user_access_tokens ON users.id = user_access_tokens.user_id WHERE token = ? AND users.disabled_at IS NULL;
-- name: SetAccessTokenToOwner :exec
-UPDATE user_access_tokens SET user_id = $1 WHERE token = $2;
+UPDATE user_access_tokens SET user_id = ? WHERE token = ?;
-- name: SetUserAsAuthenticated :exec
-UPDATE users SET authenticated_at = CURRENT_TIMESTAMP WHERE id = $1;
+UPDATE users SET authenticated_at = CURRENT_TIMESTAMP WHERE id = ?;
-- name: GetMessagesFromUser :many
-SELECT id, body, hidden_at, timestamp FROM messages WHERE eventType = 'CHAT' AND user_id = $1 ORDER BY TIMESTAMP DESC;
+SELECT id, body, hidden_at, timestamp FROM messages WHERE eventType = 'CHAT' AND user_id = ? ORDER BY TIMESTAMP DESC;
-- name: IsDisplayNameAvailable :one
-SELECT count(*) FROM users WHERE display_name = $1 AND ( type='API' OR authenticated_at IS NOT NULL ) AND disabled_at IS NULL;
+SELECT count(*) FROM users WHERE display_name = ? AND ( type='API' OR authenticated_at IS NOT NULL ) AND disabled_at IS NULL;
-- name: ChangeDisplayName :exec
-UPDATE users SET display_name = $1, previous_names = previous_names || $2, namechanged_at = $3 WHERE id = $4;
+UPDATE users SET display_name = ?, previous_names = previous_names || ?, namechanged_at = ? WHERE id = ?;
-- name: ChangeDisplayColor :exec
-UPDATE users SET display_color = $1 WHERE id = $2;
+UPDATE users SET display_color = ? WHERE id = ?;
diff --git a/db/query.sql.go b/db/query.sql.go
index 2bd970b8c8..625eebfa2e 100644
--- a/db/query.sql.go
+++ b/db/query.sql.go
@@ -12,7 +12,7 @@ import (
)
const addAccessTokenForUser = `-- name: AddAccessTokenForUser :exec
-INSERT INTO user_access_tokens(token, user_id) values($1, $2)
+INSERT INTO user_access_tokens(token, user_id) values(?, ?)
`
type AddAccessTokenForUserParams struct {
@@ -26,7 +26,7 @@ func (q *Queries) AddAccessTokenForUser(ctx context.Context, arg AddAccessTokenF
}
const addAuthForUser = `-- name: AddAuthForUser :exec
-INSERT INTO auth(user_id, token, type) values($1, $2, $3)
+INSERT INTO auth(user_id, token, type) values(?, ?, ?)
`
type AddAuthForUserParams struct {
@@ -41,7 +41,7 @@ func (q *Queries) AddAuthForUser(ctx context.Context, arg AddAuthForUserParams)
}
const addFollower = `-- name: AddFollower :exec
-INSERT INTO ap_followers(iri, inbox, shared_inbox, request, request_object, name, username, image, approved_at) values($1, $2, $3, $4, $5, $6, $7, $8, $9)
+INSERT INTO ap_followers(iri, inbox, shared_inbox, request, request_object, name, username, image, approved_at) values(?, ?, ?, ?, ?, ?, ?, ?, ?)
`
type AddFollowerParams struct {
@@ -72,7 +72,7 @@ func (q *Queries) AddFollower(ctx context.Context, arg AddFollowerParams) error
}
const addNotification = `-- name: AddNotification :exec
-INSERT INTO notifications (channel, destination) VALUES($1, $2)
+INSERT INTO notifications (channel, destination) VALUES(?, ?)
`
type AddNotificationParams struct {
@@ -86,7 +86,7 @@ func (q *Queries) AddNotification(ctx context.Context, arg AddNotificationParams
}
const addToAcceptedActivities = `-- name: AddToAcceptedActivities :exec
-INSERT INTO ap_accepted_activities(iri, actor, type, timestamp) values($1, $2, $3, $4)
+INSERT INTO ap_accepted_activities(iri, actor, type, timestamp) values(?, ?, ?, ?)
`
type AddToAcceptedActivitiesParams struct {
@@ -107,7 +107,7 @@ func (q *Queries) AddToAcceptedActivities(ctx context.Context, arg AddToAccepted
}
const addToOutbox = `-- name: AddToOutbox :exec
-INSERT INTO ap_outbox(iri, value, type, live_notification) values($1, $2, $3, $4)
+INSERT INTO ap_outbox(iri, value, type, live_notification) values(?, ?, ?, ?)
`
type AddToOutboxParams struct {
@@ -128,7 +128,7 @@ func (q *Queries) AddToOutbox(ctx context.Context, arg AddToOutboxParams) error
}
const approveFederationFollower = `-- name: ApproveFederationFollower :exec
-UPDATE ap_followers SET approved_at = $1, disabled_at = null WHERE iri = $2
+UPDATE ap_followers SET approved_at = ?, disabled_at = null WHERE iri = ?
`
type ApproveFederationFollowerParams struct {
@@ -142,7 +142,7 @@ func (q *Queries) ApproveFederationFollower(ctx context.Context, arg ApproveFede
}
const banIPAddress = `-- name: BanIPAddress :exec
-INSERT INTO ip_bans(ip_address, notes) values($1, $2)
+INSERT INTO ip_bans(ip_address, notes) values(?, ?)
`
type BanIPAddressParams struct {
@@ -156,11 +156,11 @@ func (q *Queries) BanIPAddress(ctx context.Context, arg BanIPAddressParams) erro
}
const changeDisplayColor = `-- name: ChangeDisplayColor :exec
-UPDATE users SET display_color = $1 WHERE id = $2
+UPDATE users SET display_color = ? WHERE id = ?
`
type ChangeDisplayColorParams struct {
- DisplayColor int32
+ DisplayColor int64
ID string
}
@@ -170,7 +170,7 @@ func (q *Queries) ChangeDisplayColor(ctx context.Context, arg ChangeDisplayColor
}
const changeDisplayName = `-- name: ChangeDisplayName :exec
-UPDATE users SET display_name = $1, previous_names = previous_names || $2, namechanged_at = $3 WHERE id = $4
+UPDATE users SET display_name = ?, previous_names = previous_names || ?, namechanged_at = ? WHERE id = ?
`
type ChangeDisplayNameParams struct {
@@ -191,7 +191,7 @@ func (q *Queries) ChangeDisplayName(ctx context.Context, arg ChangeDisplayNamePa
}
const doesInboundActivityExist = `-- name: DoesInboundActivityExist :one
-SELECT count(*) FROM ap_accepted_activities WHERE iri = $1 AND actor = $2 AND TYPE = $3
+SELECT count(*) FROM ap_accepted_activities WHERE iri = ? AND actor = ? AND TYPE = ?
`
type DoesInboundActivityExistParams struct {
@@ -253,12 +253,12 @@ func (q *Queries) GetFederationFollowerApprovalRequests(ctx context.Context) ([]
}
const getFederationFollowersWithOffset = `-- name: GetFederationFollowersWithOffset :many
-SELECT iri, inbox, shared_inbox, name, username, image, created_at FROM ap_followers WHERE approved_at is not null ORDER BY created_at DESC LIMIT $1 OFFSET $2
+SELECT iri, inbox, shared_inbox, name, username, image, created_at FROM ap_followers WHERE approved_at is not null ORDER BY created_at DESC LIMIT ? OFFSET ?
`
type GetFederationFollowersWithOffsetParams struct {
- Limit int32
- Offset int32
+ Limit int64
+ Offset int64
}
type GetFederationFollowersWithOffsetRow struct {
@@ -303,7 +303,7 @@ func (q *Queries) GetFederationFollowersWithOffset(ctx context.Context, arg GetF
}
const getFollowerByIRI = `-- name: GetFollowerByIRI :one
-SELECT iri, inbox, shared_inbox, name, username, image, request, request_object, created_at, approved_at, disabled_at FROM ap_followers WHERE iri = $1
+SELECT iri, inbox, shared_inbox, name, username, image, request, request_object, created_at, approved_at, disabled_at FROM ap_followers WHERE iri = ?
`
type GetFollowerByIRIRow struct {
@@ -342,7 +342,7 @@ func (q *Queries) GetFollowerByIRI(ctx context.Context, iri string) (GetFollower
const getFollowerCount = `-- name: GetFollowerCount :one
-SElECT count(*) FROM ap_followers WHERE approved_at is not null
+SELECT count(*) FROM ap_followers WHERE approved_at is not null
`
// Queries added to query.sql must be compiled into Go code with sqlc. Read README.md for details.
@@ -359,7 +359,7 @@ SELECT iri, inbox, shared_inbox, name, username, image, first_validation_failure
FROM ap_followers
WHERE approved_at IS NOT NULL AND disabled_at IS NULL
ORDER BY last_validated_at ASC NULLS FIRST
-LIMIT $1
+LIMIT ?
`
type GetFollowersToValidateRow struct {
@@ -372,7 +372,7 @@ type GetFollowersToValidateRow struct {
FirstValidationFailureAt sql.NullTime
}
-func (q *Queries) GetFollowersToValidate(ctx context.Context, limit int32) ([]GetFollowersToValidateRow, error) {
+func (q *Queries) GetFollowersToValidate(ctx context.Context, limit int64) ([]GetFollowersToValidateRow, error) {
rows, err := q.db.QueryContext(ctx, getFollowersToValidate, limit)
if err != nil {
return nil, err
@@ -431,12 +431,12 @@ func (q *Queries) GetIPAddressBans(ctx context.Context) ([]IpBan, error) {
}
const getInboundActivitiesWithOffset = `-- name: GetInboundActivitiesWithOffset :many
-SELECT iri, actor, type, timestamp FROM ap_accepted_activities ORDER BY timestamp DESC LIMIT $1 OFFSET $2
+SELECT iri, actor, type, timestamp FROM ap_accepted_activities ORDER BY timestamp DESC LIMIT ? OFFSET ?
`
type GetInboundActivitiesWithOffsetParams struct {
- Limit int32
- Offset int32
+ Limit int64
+ Offset int64
}
type GetInboundActivitiesWithOffsetRow struct {
@@ -486,7 +486,7 @@ func (q *Queries) GetInboundActivityCount(ctx context.Context) (int64, error) {
}
const getLocalPostCount = `-- name: GetLocalPostCount :one
-SElECT count(*) FROM ap_outbox
+SELECT count(*) FROM ap_outbox
`
func (q *Queries) GetLocalPostCount(ctx context.Context) (int64, error) {
@@ -497,7 +497,7 @@ func (q *Queries) GetLocalPostCount(ctx context.Context) (int64, error) {
}
const getMessagesFromUser = `-- name: GetMessagesFromUser :many
-SELECT id, body, hidden_at, timestamp FROM messages WHERE eventType = 'CHAT' AND user_id = $1 ORDER BY TIMESTAMP DESC
+SELECT id, body, hidden_at, timestamp FROM messages WHERE eventType = 'CHAT' AND user_id = ? ORDER BY TIMESTAMP DESC
`
type GetMessagesFromUserRow struct {
@@ -536,7 +536,7 @@ func (q *Queries) GetMessagesFromUser(ctx context.Context, userID sql.NullString
}
const getNotificationDestinationsForChannel = `-- name: GetNotificationDestinationsForChannel :many
-SELECT destination FROM notifications WHERE channel = $1
+SELECT destination FROM notifications WHERE channel = ?
`
func (q *Queries) GetNotificationDestinationsForChannel(ctx context.Context, channel string) ([]string, error) {
@@ -563,7 +563,7 @@ func (q *Queries) GetNotificationDestinationsForChannel(ctx context.Context, cha
}
const getObjectFromOutboxByIRI = `-- name: GetObjectFromOutboxByIRI :one
-SELECT value, live_notification, created_at FROM ap_outbox WHERE iri = $1
+SELECT value, live_notification, created_at FROM ap_outbox WHERE iri = ?
`
type GetObjectFromOutboxByIRIRow struct {
@@ -580,12 +580,12 @@ func (q *Queries) GetObjectFromOutboxByIRI(ctx context.Context, iri string) (Get
}
const getOutboxWithOffset = `-- name: GetOutboxWithOffset :many
-SELECT value FROM ap_outbox LIMIT $1 OFFSET $2
+SELECT value FROM ap_outbox LIMIT ? OFFSET ?
`
type GetOutboxWithOffsetParams struct {
- Limit int32
- Offset int32
+ Limit int64
+ Offset int64
}
func (q *Queries) GetOutboxWithOffset(ctx context.Context, arg GetOutboxWithOffsetParams) ([][]byte, error) {
@@ -682,13 +682,13 @@ func (q *Queries) GetUniqueDeliveryInboxes(ctx context.Context) ([]string, error
}
const getUserByAccessToken = `-- name: GetUserByAccessToken :one
-SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM users, user_access_tokens WHERE token = $1 AND users.id = user_id
+SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM users, user_access_tokens WHERE token = ? AND users.id = user_id
`
type GetUserByAccessTokenRow struct {
ID string
DisplayName string
- DisplayColor int32
+ DisplayColor int64
CreatedAt sql.NullTime
DisabledAt sql.NullTime
PreviousNames sql.NullString
@@ -715,7 +715,7 @@ func (q *Queries) GetUserByAccessToken(ctx context.Context, token string) (GetUs
}
const getUserByAuth = `-- name: GetUserByAuth :one
-SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM auth, users WHERE token = $1 AND auth.type = $2 AND users.id = auth.user_id
+SELECT users.id, display_name, display_color, users.created_at, disabled_at, previous_names, namechanged_at, authenticated_at, scopes FROM auth, users WHERE token = ? AND auth.type = ? AND users.id = auth.user_id
`
type GetUserByAuthParams struct {
@@ -726,7 +726,7 @@ type GetUserByAuthParams struct {
type GetUserByAuthRow struct {
ID string
DisplayName string
- DisplayColor int32
+ DisplayColor int64
CreatedAt sql.NullTime
DisabledAt sql.NullTime
PreviousNames sql.NullString
@@ -753,7 +753,7 @@ func (q *Queries) GetUserByAuth(ctx context.Context, arg GetUserByAuthParams) (G
}
const getUserDisplayNameByToken = `-- name: GetUserDisplayNameByToken :one
-SELECT display_name FROM users, user_access_tokens WHERE token = $1 AND users.id = user_id AND disabled_at = NULL
+SELECT display_name FROM users JOIN user_access_tokens ON users.id = user_access_tokens.user_id WHERE token = ? AND users.disabled_at IS NULL
`
func (q *Queries) GetUserDisplayNameByToken(ctx context.Context, token string) (string, error) {
@@ -764,7 +764,7 @@ func (q *Queries) GetUserDisplayNameByToken(ctx context.Context, token string) (
}
const isDisplayNameAvailable = `-- name: IsDisplayNameAvailable :one
-SELECT count(*) FROM users WHERE display_name = $1 AND ( type='API' OR authenticated_at IS NOT NULL ) AND disabled_at IS NULL
+SELECT count(*) FROM users WHERE display_name = ? AND ( type='API' OR authenticated_at IS NOT NULL ) AND disabled_at IS NULL
`
func (q *Queries) IsDisplayNameAvailable(ctx context.Context, displayName string) (int64, error) {
@@ -775,7 +775,7 @@ func (q *Queries) IsDisplayNameAvailable(ctx context.Context, displayName string
}
const isIPAddressBlocked = `-- name: IsIPAddressBlocked :one
-SELECT count(*) FROM ip_bans WHERE ip_address = $1
+SELECT count(*) FROM ip_bans WHERE ip_address = ?
`
func (q *Queries) IsIPAddressBlocked(ctx context.Context, ipAddress string) (int64, error) {
@@ -786,7 +786,7 @@ func (q *Queries) IsIPAddressBlocked(ctx context.Context, ipAddress string) (int
}
const rejectFederationFollower = `-- name: RejectFederationFollower :exec
-UPDATE ap_followers SET approved_at = null, disabled_at = $1 WHERE iri = $2
+UPDATE ap_followers SET approved_at = null, disabled_at = ? WHERE iri = ?
`
type RejectFederationFollowerParams struct {
@@ -800,7 +800,7 @@ func (q *Queries) RejectFederationFollower(ctx context.Context, arg RejectFedera
}
const removeFollowerByIRI = `-- name: RemoveFollowerByIRI :exec
-DELETE FROM ap_followers WHERE iri = $1
+DELETE FROM ap_followers WHERE iri = ?
`
func (q *Queries) RemoveFollowerByIRI(ctx context.Context, iri string) error {
@@ -809,7 +809,7 @@ func (q *Queries) RemoveFollowerByIRI(ctx context.Context, iri string) error {
}
const removeIPAddressBan = `-- name: RemoveIPAddressBan :exec
-DELETE FROM ip_bans WHERE ip_address = $1
+DELETE FROM ip_bans WHERE ip_address = ?
`
func (q *Queries) RemoveIPAddressBan(ctx context.Context, ipAddress string) error {
@@ -818,7 +818,7 @@ func (q *Queries) RemoveIPAddressBan(ctx context.Context, ipAddress string) erro
}
const removeNotificationDestinationForChannel = `-- name: RemoveNotificationDestinationForChannel :exec
-DELETE FROM notifications WHERE channel = $1 AND destination = $2
+DELETE FROM notifications WHERE channel = ? AND destination = ?
`
type RemoveNotificationDestinationForChannelParams struct {
@@ -832,7 +832,7 @@ func (q *Queries) RemoveNotificationDestinationForChannel(ctx context.Context, a
}
const setAccessTokenToOwner = `-- name: SetAccessTokenToOwner :exec
-UPDATE user_access_tokens SET user_id = $1 WHERE token = $2
+UPDATE user_access_tokens SET user_id = ? WHERE token = ?
`
type SetAccessTokenToOwnerParams struct {
@@ -846,7 +846,7 @@ func (q *Queries) SetAccessTokenToOwner(ctx context.Context, arg SetAccessTokenT
}
const setUserAsAuthenticated = `-- name: SetUserAsAuthenticated :exec
-UPDATE users SET authenticated_at = CURRENT_TIMESTAMP WHERE id = $1
+UPDATE users SET authenticated_at = CURRENT_TIMESTAMP WHERE id = ?
`
func (q *Queries) SetUserAsAuthenticated(ctx context.Context, id string) error {
@@ -855,7 +855,7 @@ func (q *Queries) SetUserAsAuthenticated(ctx context.Context, id string) error {
}
const updateFollowerByIRI = `-- name: UpdateFollowerByIRI :exec
-UPDATE ap_followers SET inbox = $1, shared_inbox = $2, name = $3, username = $4, image = $5 WHERE iri = $6
+UPDATE ap_followers SET inbox = ?, shared_inbox = ?, name = ?, username = ?, image = ? WHERE iri = ?
`
type UpdateFollowerByIRIParams struct {
@@ -881,8 +881,8 @@ func (q *Queries) UpdateFollowerByIRI(ctx context.Context, arg UpdateFollowerByI
const updateFollowerValidationFailure = `-- name: UpdateFollowerValidationFailure :exec
UPDATE ap_followers
-SET last_validated_at = $1, first_validation_failure_at = COALESCE(first_validation_failure_at, $1)
-WHERE iri = $2
+SET last_validated_at = ?1, first_validation_failure_at = COALESCE(first_validation_failure_at, ?1)
+WHERE iri = ?2
`
type UpdateFollowerValidationFailureParams struct {
@@ -897,8 +897,8 @@ func (q *Queries) UpdateFollowerValidationFailure(ctx context.Context, arg Updat
const updateFollowerValidationSuccess = `-- name: UpdateFollowerValidationSuccess :exec
UPDATE ap_followers
-SET last_validated_at = $1, first_validation_failure_at = NULL
-WHERE iri = $2
+SET last_validated_at = ?, first_validation_failure_at = NULL
+WHERE iri = ?
`
type UpdateFollowerValidationSuccessParams struct {
diff --git a/db/schema.sql b/db/schema.sql
deleted file mode 100644
index 083b173481..0000000000
--- a/db/schema.sql
+++ /dev/null
@@ -1,102 +0,0 @@
--- Schema update to query.sql must be referenced in queries located in query.sql
--- and compiled into code with sqlc. Read README.md for details.
-
-CREATE TABLE IF NOT EXISTS ap_followers (
- "iri" TEXT NOT NULL,
- "inbox" TEXT NOT NULL,
- "shared_inbox" TEXT,
- "name" TEXT,
- "username" TEXT NOT NULL,
- "image" TEXT,
- "request" TEXT NOT NULL,
- "request_object" BLOB,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- "approved_at" TIMESTAMP,
- "disabled_at" TIMESTAMP,
- "last_validated_at" TIMESTAMP,
- "first_validation_failure_at" TIMESTAMP,
- PRIMARY KEY (iri));
- CREATE INDEX iri_index ON ap_followers (iri);
- CREATE INDEX approved_at_index ON ap_followers (approved_at);
-
-
-CREATE TABLE IF NOT EXISTS ap_outbox (
- "iri" TEXT NOT NULL,
- "value" BLOB,
- "type" TEXT NOT NULL,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- "live_notification" BOOLEAN DEFAULT FALSE,
- PRIMARY KEY (iri));
- CREATE INDEX iri ON ap_outbox (iri);
- CREATE INDEX type ON ap_outbox (type);
- CREATE INDEX live_notification ON ap_outbox (live_notification);
-
-CREATE TABLE IF NOT EXISTS ap_accepted_activities (
- "id" INTEGER NOT NULL PRIMARY KEY,
- "iri" TEXT NOT NULL,
- "actor" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "timestamp" TIMESTAMP NOT NULL
- );
- CREATE INDEX iri_actor_index ON ap_accepted_activities (iri,actor);
-
- CREATE TABLE IF NOT EXISTS ip_bans (
- "ip_address" TEXT NOT NULL PRIMARY KEY,
- "notes" TEXT,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- );
-
-CREATE TABLE IF NOT EXISTS notifications (
- "id" INTEGER NOT NULL PRIMARY KEY,
- "channel" TEXT NOT NULL,
- "destination" TEXT NOT NULL,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
- CREATE INDEX channel_index ON notifications (channel);
-
-CREATE TABLE IF NOT EXISTS users (
- "id" TEXT,
- "display_name" TEXT NOT NULL,
- "display_color" INTEGER NOT NULL,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- "disabled_at" TIMESTAMP,
- "previous_names" TEXT DEFAULT '',
- "namechanged_at" TIMESTAMP,
- "scopes" TEXT,
- "authenticated_at" TIMESTAMP,
- "type" TEXT DEFAULT 'STANDARD',
- "last_used" DATETIME DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (id)
- );
-
-CREATE TABLE IF NOT EXISTS user_access_tokens (
- "token" TEXT NOT NULL PRIMARY KEY,
- "user_id" TEXT NOT NULL,
- "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL
-);
-
-CREATE TABLE IF NOT EXISTS auth (
- "id" INTEGER NOT NULL PRIMARY KEY,
- "user_id" TEXT NOT NULL,
- "token" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL
- );
- CREATE INDEX auth_token ON auth (token);
-
-CREATE TABLE IF NOT EXISTS messages (
- "id" string NOT NULL,
- "user_id" TEXT,
- "body" TEXT,
- "eventType" TEXT,
- "hidden_at" DATE,
- "timestamp" DATE,
- "title" TEXT,
- "subtitle" TEXT,
- "image" TEXT,
- "link" TEXT,
- PRIMARY KEY (id)
- );CREATE INDEX index ON messages (id, user_id, hidden_at, timestamp);
- CREATE INDEX id ON messages (id);
- CREATE INDEX user_id ON messages (user_id);
- CREATE INDEX hidden_at ON messages (hidden_at);
- CREATE INDEX timestamp ON messages (timestamp);
diff --git a/go.mod b/go.mod
index 5c49935226..c8b099e476 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/owncast/owncast
-go 1.25.0
+go 1.26.2
require (
github.com/CAFxX/httpcompression v0.0.9
@@ -24,6 +24,7 @@ require (
github.com/oapi-codegen/runtime v1.4.0
github.com/oschwald/geoip2-golang v1.13.0
github.com/pkg/errors v0.9.1
+ github.com/pressly/goose/v3 v3.27.0
github.com/prometheus/client_golang v1.23.2
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/schollz/sqlite3dump v1.3.1
@@ -42,7 +43,7 @@ require (
)
require (
- github.com/andybalholm/brotli v1.0.5 // indirect
+ github.com/andybalholm/brotli v1.2.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
@@ -55,25 +56,27 @@ require (
github.com/gorilla/css v1.0.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
- github.com/jonboulle/clockwork v0.5.0 // indirect
- github.com/klauspost/compress v1.18.0 // indirect
+ github.com/klauspost/compress v1.18.4 // indirect
github.com/lestrrat-go/strftime v1.1.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
+ github.com/mfridman/interpolate v0.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oschwald/maxminddb-golang v1.13.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
- github.com/prometheus/procfs v0.16.1 // indirect
+ github.com/prometheus/procfs v0.19.2 // indirect
+ github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/tklauser/go-sysconf v0.3.15 // indirect
github.com/tklauser/numcpus v0.10.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
+ go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
- google.golang.org/protobuf v1.36.8 // indirect
+ google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index c5f86dd38b..7ac3216302 100644
--- a/go.sum
+++ b/go.sum
@@ -5,8 +5,9 @@ github.com/SherClockHolmes/webpush-go v1.4.0 h1:ocnzNKWN23T9nvHi6IfyrQjkIc0oJWv1
github.com/SherClockHolmes/webpush-go v1.4.0/go.mod h1:XSq8pKX11vNV8MJEMwjrlTkxhAj1zKfxmyhdV7Pd6UA=
github.com/TwiN/go-away v1.8.1 h1:zbbr0ISBkDSbnUFHrnRUhbCR/7+9ONMWtIi1BiQWX8Y=
github.com/TwiN/go-away v1.8.1/go.mod h1:nSQEvd/FYBNmnC27RGJdPi91LXYMG8SrRc1o1w+VmKY=
-github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
+github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
+github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
@@ -24,6 +25,8 @@ github.com/dave/jennifer v1.3.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhr
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
@@ -70,8 +73,8 @@ github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbd
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
-github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
-github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
+github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
+github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -87,23 +90,15 @@ github.com/lestrrat-go/strftime v1.1.1 h1:zgf8QCsgj27GlKBy3SU9/8MMgegZ8UCzlCyHYr
github.com/lestrrat-go/strftime v1.1.1/go.mod h1:YDrzHJAODYQ+xxvrn5SG01uFIQAeDTzpxNVppCz7Nmw=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
-github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
-github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
+github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
-github.com/mattn/go-sqlite3 v1.14.37 h1:3DOZp4cXis1cUIpCfXLtmlGolNLp2VEqhiB/PARNBIg=
-github.com/mattn/go-sqlite3 v1.14.37/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
-github.com/mattn/go-sqlite3 v1.14.38 h1:tDUzL85kMvOrvpCt8P64SbGgVFtJB11GPi2AdmITgb4=
-github.com/mattn/go-sqlite3 v1.14.38/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
-github.com/mattn/go-sqlite3 v1.14.39 h1:sIwSjlJGOaRJjw44/HXaeTblZMjseqr6OOio1tz/+JI=
-github.com/mattn/go-sqlite3 v1.14.39/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
-github.com/mattn/go-sqlite3 v1.14.40 h1:f7+saIsbq4EF86mUqe0uiecQOJYMOdfi5uATADmUG94=
-github.com/mattn/go-sqlite3 v1.14.40/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
-github.com/mattn/go-sqlite3 v1.14.41 h1:8p7Pwz5NHkEbWSqc/ygU4CBGubhFFkpgP9KwcdkAHNA=
-github.com/mattn/go-sqlite3 v1.14.41/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo=
github.com/mattn/go-sqlite3 v1.14.42/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
+github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
+github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4=
@@ -114,10 +109,8 @@ github.com/nakabonne/tstorage v0.3.6 h1:usp7pTohax8mynnFiUSUQ2QVBCKLCkYx3gmb3+rJ
github.com/nakabonne/tstorage v0.3.6/go.mod h1:1xUrK3s1MXSlU6dn96xHerHx/MdO4BGmsAHEUbsaOxU=
github.com/nareix/joy5 v0.0.0-20210317075623-2c912ca30590 h1:PnxRU8L8Y2q82vFC2QdNw23Dm2u6WrjecIdpXjiYbXM=
github.com/nareix/joy5 v0.0.0-20210317075623-2c912ca30590/go.mod h1:XmAOs6UJXpNXRwKk+KY/nv5kL6xXYXyellk+A1pTlko=
-github.com/oapi-codegen/runtime v1.3.0 h1:vyK1zc0gDWWXgk2xoQa4+X4RNNc5SL2RbTpJS/4vMYA=
-github.com/oapi-codegen/runtime v1.3.0/go.mod h1:kOdeacKy7t40Rclb1je37ZLFboFxh+YLy0zaPCMibPY=
-github.com/oapi-codegen/runtime v1.3.1 h1:RgDY6J4OGQLbRXhG/Xpt3vSVqYpHQS7hN4m85+5xB9g=
-github.com/oapi-codegen/runtime v1.3.1/go.mod h1:kOdeacKy7t40Rclb1je37ZLFboFxh+YLy0zaPCMibPY=
+github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
+github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4=
github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec=
github.com/oschwald/geoip2-golang v1.13.0 h1:Q44/Ldc703pasJeP5V9+aFSZFmBN7DKHbNsSFzQATJI=
@@ -126,28 +119,35 @@ github.com/oschwald/maxminddb-golang v1.13.0 h1:R8xBorY71s84yO06NgTmQvqvTvlS/bnY
github.com/oschwald/maxminddb-golang v1.13.0/go.mod h1:BU0z8BfFVhi1LQaonTwwGQlsHUEu9pWNdMfmq4ztm0o=
github.com/owncast/activity v1.0.1-0.20260122170223-675f6eb53e71 h1:dJ6DdVqcZjz0P7UIKPCARucmyIGNXiL7BxNfg1Ul8Gs=
github.com/owncast/activity v1.0.1-0.20260122170223-675f6eb53e71/go.mod h1:v4QoPaAzjWZ8zN2VFVGL5ep9C02mst0hQYHUpQwso4Q=
-github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=
github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+github.com/pierrec/lz4/v4 v4.1.25 h1:kocOqRffaIbU5djlIBr7Wh+cx82C0vtFb0fOurZHqD0=
+github.com/pierrec/lz4/v4 v4.1.25/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
+github.com/pressly/goose/v3 v3.27.0 h1:/D30gVTuQhu0WsNZYbJi4DMOsx1lNq+6SkLe+Wp59BM=
+github.com/pressly/goose/v3 v3.27.0/go.mod h1:3ZBeCXqzkgIRvrEMDkYh1guvtoJTU5oMMuDdkutoM78=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
-github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
-github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
+github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
+github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a h1:w3tdWGKbLGBPtR/8/oO74W6hmz0qE5q0z9aqSAewaaM=
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a/go.mod h1:S8kfXMp+yh77OxPD4fdM6YUknrZpQxLhvxzS4gDHENY=
github.com/schollz/sqlite3dump v1.3.1 h1:QXizJ7XEJ7hggjqjZ3YRtF3+javm8zKtzNByYtEkPRA=
github.com/schollz/sqlite3dump v1.3.1/go.mod h1:mzSTjZpJH4zAb1FN3iNlhWPbbdyeBpOaTW0hukyMHyI=
+github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
+github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
github.com/shirou/gopsutil/v4 v4.25.8 h1:NnAsw9lN7587WHxjJA9ryDnqhJpFH6A+wagYWTOH970=
github.com/shirou/gopsutil/v4 v4.25.8/go.mod h1:q9QdMmfAOVIw7a+eF86P7ISEU6ka+NLgkUxlopV4RwI=
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
@@ -174,6 +174,8 @@ github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XV
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/valyala/gozstd v1.20.1 h1:xPnnnvjmaDDitMFfDxmQ4vpx0+3CdTg2o3lALvXTU/g=
github.com/valyala/gozstd v1.20.1/go.mod h1:y5Ew47GLlP37EkTB+B4s7r6A5rdaeB7ftbl9zoYiIPQ=
+github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
+github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=
github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
@@ -183,6 +185,8 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
+go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -193,17 +197,15 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
-golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
-golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
+golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDMEV06GpzjG2jrqW+QTE0=
+golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
-golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
-golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -217,8 +219,6 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
-golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
-golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -245,8 +245,6 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
-golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
@@ -258,8 +256,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
-golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
-golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
+golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
+golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -269,8 +267,6 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
-golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
-golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
@@ -283,8 +279,8 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
-google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
+google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
+google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
@@ -295,5 +291,13 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+modernc.org/libc v1.68.0 h1:PJ5ikFOV5pwpW+VqCK1hKJuEWsonkIJhhIXyuF/91pQ=
+modernc.org/libc v1.68.0/go.mod h1:NnKCYeoYgsEqnY3PgvNgAeaJnso968ygU8Z0DxjoEc0=
+modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
+modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
+modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
+modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
+modernc.org/sqlite v1.46.1 h1:eFJ2ShBLIEnUWlLy12raN0Z1plqmFX9Qe3rjQTKt6sU=
+modernc.org/sqlite v1.46.1/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
mvdan.cc/xurls/v2 v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI=
mvdan.cc/xurls/v2 v2.6.0/go.mod h1:bCvEZ1XvdA6wDnxY7jPPjEmigDtvtvPXAD/Exa9IMSk=
diff --git a/persistence/authrepository/authrepository.go b/persistence/authrepository/authrepository.go
index b2c7dc5aae..2a5c29520c 100644
--- a/persistence/authrepository/authrepository.go
+++ b/persistence/authrepository/authrepository.go
@@ -1,13 +1,10 @@
package authrepository
import (
- "database/sql"
-
"github.com/owncast/owncast/webserver/handlers/generated"
)
type AuthRepository interface {
- CreateBanIPTable(db *sql.DB)
BanIPAddress(address, note string) error
IsIPAddressBanned(address string) (bool, error)
GetIPAddressBans() ([]generated.IPAddress, error)
diff --git a/persistence/authrepository/bans.go b/persistence/authrepository/bans.go
index 1370bd2812..f926306a92 100644
--- a/persistence/authrepository/bans.go
+++ b/persistence/authrepository/bans.go
@@ -3,30 +3,11 @@ package authrepository
import (
"context"
"database/sql"
- "log"
"github.com/owncast/owncast/db"
"github.com/owncast/owncast/webserver/handlers/generated"
)
-// CreateBanIPTable will create the IP ban table if needed.
-func (r *SqlAuthRepository) CreateBanIPTable(db *sql.DB) {
- createTableSQL := ` CREATE TABLE IF NOT EXISTS ip_bans (
- "ip_address" TEXT NOT NULL PRIMARY KEY,
- "notes" TEXT,
- "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- );`
-
- stmt, err := db.Prepare(createTableSQL)
- if err != nil {
- log.Fatal("error creating ip ban table", err)
- }
- defer stmt.Close()
- if _, err := stmt.Exec(); err != nil {
- log.Fatal("error creating ip ban table", err)
- }
-}
-
// BanIPAddress will persist a new IP address ban to the datastore.
func (r *SqlAuthRepository) BanIPAddress(address, note string) error {
return r.datastore.GetQueries().BanIPAddress(context.Background(), db.BanIPAddressParams{
diff --git a/persistence/tables/config.go b/persistence/legacymigrations/config.go
similarity index 92%
rename from persistence/tables/config.go
rename to persistence/legacymigrations/config.go
index 189cde2f7f..5af3020211 100644
--- a/persistence/tables/config.go
+++ b/persistence/legacymigrations/config.go
@@ -1,4 +1,4 @@
-package tables
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/tables/messages.go b/persistence/legacymigrations/messages.go
similarity index 97%
rename from persistence/tables/messages.go
rename to persistence/legacymigrations/messages.go
index 9a434b5b23..7c74461963 100644
--- a/persistence/tables/messages.go
+++ b/persistence/legacymigrations/messages.go
@@ -1,4 +1,4 @@
-package tables
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/tables/migrations.go b/persistence/legacymigrations/migrations.go
similarity index 95%
rename from persistence/tables/migrations.go
rename to persistence/legacymigrations/migrations.go
index 7df284bf64..4e296fe021 100644
--- a/persistence/tables/migrations.go
+++ b/persistence/legacymigrations/migrations.go
@@ -1,4 +1,12 @@
-package tables
+// Package legacymigrations holds the hand-rolled, version-numbered schema
+// migrations used before Owncast moved to goose. This package is FROZEN:
+// the migration functions here advance pre-goose installs to schema version
+// 9 and must not be modified or extended. All new schema changes go in
+// persistence/migrations as numbered goose migrations.
+//
+// The only public entry point, MigrateDatabaseSchema, is invoked by the
+// migrations runner when it detects a legacy `config.version` row below 9.
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/tables/notifications.go b/persistence/legacymigrations/notifications.go
similarity index 95%
rename from persistence/tables/notifications.go
rename to persistence/legacymigrations/notifications.go
index f453a4b5ad..a1bfc5534d 100644
--- a/persistence/tables/notifications.go
+++ b/persistence/legacymigrations/notifications.go
@@ -1,4 +1,4 @@
-package tables
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/tables/users.go b/persistence/legacymigrations/users.go
similarity index 98%
rename from persistence/tables/users.go
rename to persistence/legacymigrations/users.go
index 11c9aac39f..5bac1a7c80 100644
--- a/persistence/tables/users.go
+++ b/persistence/legacymigrations/users.go
@@ -1,4 +1,4 @@
-package tables
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/tables/webhooks.go b/persistence/legacymigrations/webhooks.go
similarity index 95%
rename from persistence/tables/webhooks.go
rename to persistence/legacymigrations/webhooks.go
index 2bfb78a418..9867dfd041 100644
--- a/persistence/tables/webhooks.go
+++ b/persistence/legacymigrations/webhooks.go
@@ -1,4 +1,4 @@
-package tables
+package legacymigrations
import (
"database/sql"
diff --git a/persistence/migrations/00001_init.sql b/persistence/migrations/00001_init.sql
new file mode 100644
index 0000000000..2f1c375b5b
--- /dev/null
+++ b/persistence/migrations/00001_init.sql
@@ -0,0 +1,161 @@
+-- +goose Up
+-- +goose StatementBegin
+
+-- Baseline schema migration.
+--
+-- This migration represents the consolidated database schema as of the
+-- transition from the legacy hand-rolled migration system (previously tracked
+-- via the config.version key) to goose.
+--
+-- For existing installs at legacy schema version 9, the catch-up path in
+-- persistence/legacymigrations runs first to bring them to v9; this baseline
+-- is then a sequence of no-ops (every statement is IF NOT EXISTS) and goose
+-- simply records it as applied.
+--
+-- For fresh installs, this migration creates every table and index the
+-- application expects.
+--
+-- Table ordering matches the runtime setup order of the previous system so
+-- that deterministic index-name collisions (see notes below) resolve to the
+-- same table they resolve to in existing installs.
+
+-- Key-value store used for application config values.
+-- NOTE: column types were historically declared as the non-standard
+-- "string" affinity. They're written here with standard SQLite types
+-- (TEXT) so the sqlc SQLite parser can infer Go types correctly; the
+-- stored values are identical in practice because SQLite's type
+-- affinity system is tolerant of either declaration.
+CREATE TABLE IF NOT EXISTS datastore (
+ "key" TEXT NOT NULL PRIMARY KEY,
+ "value" BLOB,
+ "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS webhooks (
+ "id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "url" TEXT NOT NULL,
+ "events" TEXT NOT NULL,
+ "timestamp" DATETIME DEFAULT CURRENT_TIMESTAMP,
+ "last_used" DATETIME
+);
+
+CREATE TABLE IF NOT EXISTS users (
+ "id" TEXT NOT NULL,
+ "display_name" TEXT NOT NULL,
+ "display_color" INTEGER NOT NULL,
+ "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ "disabled_at" TIMESTAMP,
+ "previous_names" TEXT DEFAULT '',
+ "namechanged_at" TIMESTAMP,
+ "authenticated_at" TIMESTAMP,
+ "scopes" TEXT,
+ "type" TEXT DEFAULT 'STANDARD',
+ "last_used" DATETIME DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (id)
+);
+CREATE INDEX IF NOT EXISTS idx_user_id ON users (id);
+CREATE INDEX IF NOT EXISTS idx_user_id_disabled ON users (id, disabled_at);
+CREATE INDEX IF NOT EXISTS idx_user_disabled_at ON users (disabled_at);
+
+CREATE TABLE IF NOT EXISTS user_access_tokens (
+ "token" TEXT NOT NULL PRIMARY KEY,
+ "user_id" TEXT NOT NULL,
+ "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id)
+);
+
+CREATE TABLE IF NOT EXISTS ap_followers (
+ "iri" TEXT NOT NULL,
+ "inbox" TEXT NOT NULL,
+ "shared_inbox" TEXT,
+ "name" TEXT,
+ "username" TEXT NOT NULL,
+ "image" TEXT,
+ "request" TEXT NOT NULL,
+ "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ "approved_at" TIMESTAMP,
+ "disabled_at" TIMESTAMP,
+ "request_object" BLOB,
+ "last_validated_at" TIMESTAMP,
+ "first_validation_failure_at" TIMESTAMP,
+ PRIMARY KEY (iri)
+);
+CREATE INDEX IF NOT EXISTS idx_iri ON ap_followers (iri);
+CREATE INDEX IF NOT EXISTS idx_ap_followers_iri ON ap_followers (iri);
+CREATE INDEX IF NOT EXISTS idx_approved_at ON ap_followers (approved_at);
+
+CREATE TABLE IF NOT EXISTS ap_outbox (
+ "iri" TEXT NOT NULL,
+ "value" BLOB,
+ "type" TEXT NOT NULL,
+ "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ "live_notification" BOOLEAN DEFAULT FALSE,
+ PRIMARY KEY (iri)
+);
+CREATE INDEX IF NOT EXISTS idx_iri ON ap_outbox (iri);
+CREATE INDEX IF NOT EXISTS idx_ap_outbox_iri ON ap_outbox (iri);
+CREATE INDEX IF NOT EXISTS idx_type ON ap_outbox (type);
+CREATE INDEX IF NOT EXISTS idx_live_notification ON ap_outbox (live_notification);
+
+CREATE TABLE IF NOT EXISTS ap_accepted_activities (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "iri" TEXT NOT NULL,
+ "actor" TEXT NOT NULL,
+ "type" TEXT NOT NULL,
+ "timestamp" TIMESTAMP NOT NULL
+);
+CREATE INDEX IF NOT EXISTS idx_iri_actor_index ON ap_accepted_activities (iri, actor);
+
+CREATE TABLE IF NOT EXISTS notifications (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "channel" TEXT NOT NULL,
+ "destination" TEXT NOT NULL,
+ "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+CREATE INDEX IF NOT EXISTS idx_channel ON notifications (channel);
+
+CREATE TABLE IF NOT EXISTS messages (
+ "id" TEXT NOT NULL,
+ "user_id" TEXT,
+ "body" TEXT,
+ "eventType" TEXT,
+ "hidden_at" DATETIME,
+ "timestamp" DATETIME,
+ "title" TEXT,
+ "subtitle" TEXT,
+ "image" TEXT,
+ "link" TEXT,
+ PRIMARY KEY (id)
+);
+CREATE INDEX IF NOT EXISTS user_id_hidden_at_timestamp ON messages (id, user_id, hidden_at, timestamp);
+CREATE INDEX IF NOT EXISTS idx_id ON messages (id);
+CREATE INDEX IF NOT EXISTS idx_user_id ON messages (user_id);
+CREATE INDEX IF NOT EXISTS idx_messages_user_id ON messages (user_id);
+CREATE INDEX IF NOT EXISTS idx_hidden_at ON messages (hidden_at);
+CREATE INDEX IF NOT EXISTS idx_timestamp ON messages (timestamp);
+CREATE INDEX IF NOT EXISTS idx_messages_hidden_at_timestamp ON messages (hidden_at, timestamp);
+
+CREATE TABLE IF NOT EXISTS auth (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "user_id" TEXT NOT NULL,
+ "token" TEXT NOT NULL,
+ "type" TEXT NOT NULL,
+ "timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id)
+);
+CREATE INDEX IF NOT EXISTS idx_auth_token ON auth (token);
+
+CREATE TABLE IF NOT EXISTS ip_bans (
+ "ip_address" TEXT NOT NULL PRIMARY KEY,
+ "notes" TEXT,
+ "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+-- +goose StatementEnd
+
+-- +goose Down
+-- +goose StatementBegin
+-- The baseline migration intentionally has no Down. Reverting the entire
+-- schema is not a meaningful operation for this application.
+SELECT 'baseline migration has no down step';
+-- +goose StatementEnd
diff --git a/persistence/migrations/migrations.go b/persistence/migrations/migrations.go
new file mode 100644
index 0000000000..fe0f677b22
--- /dev/null
+++ b/persistence/migrations/migrations.go
@@ -0,0 +1,108 @@
+// Package migrations is the single entry point for evolving the Owncast
+// database schema.
+//
+// On startup, Run is called exactly once by the persistence layer. It brings
+// any install (fresh or existing) up to the current schema and then returns.
+// All further schema changes must be added as additional numbered SQL files
+// in this directory; never amend an existing migration that has shipped.
+//
+// # Legacy-install support
+//
+// Before the goose system existed, schema state was tracked in a hand-rolled
+// `config.version` row and advanced by a switch statement in
+// persistence/legacymigrations. For installs that predate this package, Run
+// detects that row and invokes the legacy catch-up path to bring the schema
+// to the point where goose can take over. The legacy package is frozen —
+// no new cases may be added to it; all new schema work happens here.
+package migrations
+
+import (
+ "database/sql"
+ "embed"
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/owncast/owncast/persistence/legacymigrations"
+ "github.com/pressly/goose/v3"
+ log "github.com/sirupsen/logrus"
+)
+
+//go:embed *.sql
+var embedMigrations embed.FS
+
+// legacyBaselineVersion is the schema version the legacy hand-rolled
+// migration system reached immediately before goose took over. Any install
+// whose legacy `config.version` row is below this value is caught up by the
+// frozen legacymigrations package before goose runs.
+const legacyBaselineVersion = 9
+
+// Run brings the database schema up to date.
+//
+// For fresh installs, goose runs the baseline migration plus anything newer.
+// For installs that predate goose, the legacy catch-up runs first and then
+// the baseline is recorded as applied (its statements are all IF NOT EXISTS
+// and become no-ops on an already-populated database).
+func Run(db *sql.DB) error {
+ legacyVersion, err := readLegacyVersion(db)
+ if err != nil {
+ return fmt.Errorf("reading legacy schema version: %w", err)
+ }
+
+ if legacyVersion > 0 && legacyVersion < legacyBaselineVersion {
+ log.Infof("Legacy schema at version %d; upgrading to %d before handing off to goose",
+ legacyVersion, legacyBaselineVersion)
+ if err := legacymigrations.MigrateDatabaseSchema(db, legacyVersion, legacyBaselineVersion); err != nil {
+ return fmt.Errorf("legacy schema catch-up: %w", err)
+ }
+ }
+
+ goose.SetBaseFS(embedMigrations)
+ goose.SetLogger(gooseLogger{})
+ if err := goose.SetDialect("sqlite3"); err != nil {
+ return fmt.Errorf("setting goose dialect: %w", err)
+ }
+ if err := goose.Up(db, "."); err != nil {
+ return fmt.Errorf("applying migrations: %w", err)
+ }
+ return nil
+}
+
+// readLegacyVersion returns the schema version stored in the legacy `config`
+// table, or 0 if that table (or the version row) does not exist — which is
+// how we recognise a fresh install.
+func readLegacyVersion(db *sql.DB) (int, error) {
+ var name string
+ err := db.QueryRow(`SELECT name FROM sqlite_master WHERE type='table' AND name='config'`).Scan(&name)
+ if errors.Is(err, sql.ErrNoRows) {
+ return 0, nil
+ }
+ if err != nil {
+ return 0, err
+ }
+
+ var version int
+ err = db.QueryRow(`SELECT value FROM config WHERE key='version'`).Scan(&version)
+ if errors.Is(err, sql.ErrNoRows) {
+ return 0, nil
+ }
+ if err != nil {
+ return 0, err
+ }
+ return version, nil
+}
+
+// gooseLogger adapts goose's Logger interface onto logrus so migration
+// output flows through the project's normal logging pipeline. It silences
+// the "no migrations to run" message that goose emits on every startup
+// when the schema is already current.
+type gooseLogger struct{}
+
+func (gooseLogger) Fatalf(format string, v ...interface{}) { log.Fatalf(format, v...) }
+
+func (gooseLogger) Printf(format string, v ...interface{}) {
+ if strings.Contains(fmt.Sprintf(format, v...), "no migrations to run") {
+ return
+ }
+ log.Infof(format, v...)
+}
diff --git a/persistence/notificationsrepository/integration_test.go b/persistence/notificationsrepository/integration_test.go
index a40157d5aa..0b571770d4 100644
--- a/persistence/notificationsrepository/integration_test.go
+++ b/persistence/notificationsrepository/integration_test.go
@@ -27,7 +27,7 @@ func TestIntegrationSetup(t *testing.T) {
// The actual setup is done in the init function below
if integrationTestDatastore == nil {
integrationTestDatastore = data.GetDatastore()
- Setup(integrationTestDatastore)
+ Setup()
integrationRepo = New(integrationTestDatastore)
}
diff --git a/persistence/notificationsrepository/notificationsrepository.go b/persistence/notificationsrepository/notificationsrepository.go
index 561367f753..e4a41b273e 100644
--- a/persistence/notificationsrepository/notificationsrepository.go
+++ b/persistence/notificationsrepository/notificationsrepository.go
@@ -8,7 +8,6 @@ import (
"github.com/owncast/owncast/db"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/persistence/configrepository"
- "github.com/owncast/owncast/persistence/tables"
"github.com/owncast/owncast/notifications/browser"
"github.com/pkg/errors"
@@ -39,8 +38,8 @@ func Get() NotificationsRepository {
}
// Setup will perform any pre-use setup for the notifier.
-func Setup(datastore *data.Datastore) {
- tables.CreateNotificationsTable(datastore.DB)
+// The notifications table itself is created by the goose migrations package.
+func Setup() {
initializeBrowserPushIfNeeded()
}
diff --git a/persistence/notificationsrepository/notificationsrepository_test.go b/persistence/notificationsrepository/notificationsrepository_test.go
index b7aa7463ed..fa44ccd1dd 100644
--- a/persistence/notificationsrepository/notificationsrepository_test.go
+++ b/persistence/notificationsrepository/notificationsrepository_test.go
@@ -22,7 +22,7 @@ func TestMain(m *testing.M) {
testDatastore = data.GetDatastore()
// Setup the notifications repository
- Setup(testDatastore)
+ Setup()
testRepo = New(testDatastore)
// Run tests
diff --git a/persistence/userrepository/userrepository.go b/persistence/userrepository/userrepository.go
index 142364252f..5fe2d078a9 100644
--- a/persistence/userrepository/userrepository.go
+++ b/persistence/userrepository/userrepository.go
@@ -144,7 +144,7 @@ func (r *SqlUserRepository) ChangeUserColor(userID string, color int) error {
defer r.datastore.DbLock.Unlock()
if err := r.datastore.GetQueries().ChangeDisplayColor(context.Background(), db.ChangeDisplayColorParams{
- DisplayColor: utils.SafeIntToInt32(color),
+ DisplayColor: int64(color),
ID: userID,
}); err != nil {
return errors.Wrap(err, "unable to change display color")
diff --git a/sqlc.yaml b/sqlc.yaml
index a4964736b2..af2af2f51e 100644
--- a/sqlc.yaml
+++ b/sqlc.yaml
@@ -1,6 +1,9 @@
-version: 1
-packages:
- - path: db
- name: db
- schema: 'db/schema.sql'
- queries: 'db/query.sql'
+version: "2"
+sql:
+ - engine: "sqlite"
+ schema: "persistence/migrations"
+ queries: "db/query.sql"
+ gen:
+ go:
+ package: "db"
+ out: "db"
diff --git a/tools/go.mod b/tools/go.mod
index a72d7dcecf..a16e2c1b08 100644
--- a/tools/go.mod
+++ b/tools/go.mod
@@ -1,6 +1,6 @@
module github.com/owncast/owncast/tools
-go 1.25.3
+go 1.26.2
require (
github.com/evilmartians/lefthook v1.13.6