mirror of
https://github.com/juanfont/headscale.git
synced 2026-07-15 12:30:44 +09:00
db, sqliteconfig: remove dead and unreachable code
This commit is contained in:
@@ -981,12 +981,6 @@ func runMigrations(cfg types.DatabaseConfig, dbConn *gorm.DB, migrations *gormig
|
||||
// Add other migration IDs here as they are identified to need FK disabled
|
||||
}
|
||||
|
||||
// Get the current foreign key status
|
||||
var fkOriginallyEnabled int
|
||||
if err := dbConn.Raw("PRAGMA foreign_keys").Scan(&fkOriginallyEnabled).Error; err != nil { //nolint:noinlineerr
|
||||
return fmt.Errorf("checking foreign key status: %w", err)
|
||||
}
|
||||
|
||||
// Get all migration IDs in order from the actual migration definitions
|
||||
// Only IDs that are in the migrationsRequiringFKDisabled map will be processed with FK disabled
|
||||
// any other new migrations are ran after.
|
||||
|
||||
@@ -101,11 +101,6 @@ func (j JournalMode) IsValid() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation.
|
||||
func (j JournalMode) String() string {
|
||||
return string(j)
|
||||
}
|
||||
|
||||
// AutoVacuum represents SQLite auto_vacuum pragma values.
|
||||
// Auto-vacuum controls how SQLite reclaims space from deleted data.
|
||||
//
|
||||
@@ -157,11 +152,6 @@ func (a AutoVacuum) IsValid() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation.
|
||||
func (a AutoVacuum) String() string {
|
||||
return string(a)
|
||||
}
|
||||
|
||||
// Synchronous represents SQLite synchronous pragma values.
|
||||
// Synchronous mode controls how aggressively SQLite flushes data to disk.
|
||||
//
|
||||
@@ -221,11 +211,6 @@ func (s Synchronous) IsValid() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation.
|
||||
func (s Synchronous) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// TxLock represents SQLite transaction lock mode.
|
||||
// Transaction lock mode determines when write locks are acquired during transactions.
|
||||
//
|
||||
@@ -277,11 +262,6 @@ func (t TxLock) IsValid() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation.
|
||||
func (t TxLock) String() string {
|
||||
return string(t)
|
||||
}
|
||||
|
||||
// Config holds SQLite database configuration with type-safe enums.
|
||||
// This configuration balances performance, durability, and operational requirements
|
||||
// for Headscale's SQLite database usage patterns.
|
||||
|
||||
@@ -98,25 +98,6 @@ func TestTxLock(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTxLockString(t *testing.T) {
|
||||
tests := []struct {
|
||||
mode TxLock
|
||||
want string
|
||||
}{
|
||||
{TxLockDeferred, "deferred"},
|
||||
{TxLockImmediate, "immediate"},
|
||||
{TxLockExclusive, "exclusive"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.want, func(t *testing.T) {
|
||||
if got := tt.mode.String(); got != tt.want {
|
||||
t.Errorf("TxLock.String() = %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -95,8 +95,6 @@ var ErrCannotChangeOIDCUser = errors.New("cannot edit OIDC user")
|
||||
// RenameUser renames a [types.User]. Returns error if the [types.User] does
|
||||
// not exist or if another [types.User] exists with the new name.
|
||||
func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
||||
var err error
|
||||
|
||||
oldUser, err := GetUserByID(tx, uid)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user