mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-10 10:14:18 +00:00
chore: preparation for merge into main branch
This commit is contained in:
@@ -168,7 +168,7 @@ func ValidateEnvConfig(config *EnvConfigSchema) error {
|
||||
switch config.FileBackend {
|
||||
case "s3", "database":
|
||||
// All good, these are valid values
|
||||
case "", "fs":
|
||||
case "", "filesystem":
|
||||
if config.UploadPath == "" {
|
||||
config.UploadPath = defaultFsUploadPath
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func TestParseEnvConfig(t *testing.T) {
|
||||
t.Setenv("APP_URL", "http://localhost:3000")
|
||||
t.Setenv("AUDIT_LOG_RETENTION_DAYS", "0")
|
||||
|
||||
err := parseEnvConfig()
|
||||
err := parseAndValidateEnvConfig(t)
|
||||
require.Error(t, err)
|
||||
assert.ErrorContains(t, err, "AUDIT_LOG_RETENTION_DAYS must be greater than 0")
|
||||
})
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *ExportService) extractDatabase() (DatabaseExport, error) {
|
||||
Tables: map[string][]map[string]any{},
|
||||
// These tables need to be inserted in a specific order because of foreign key constraints
|
||||
// Not all tables are listed here, because not all tables are order-dependent
|
||||
TableOrder: []string{"users", "user_groups", "oidc_clients"},
|
||||
TableOrder: []string{"users", "user_groups", "oidc_clients", "signup_tokens"},
|
||||
}
|
||||
|
||||
for table := range schema {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *ImportService) ImportFromZip(ctx context.Context, r *zip.Reader) error
|
||||
|
||||
// ImportDatabase only imports the database data from the given DatabaseExport struct.
|
||||
func (s *ImportService) ImportDatabase(dbData DatabaseExport) error {
|
||||
err := s.resetSchema(dbData.Version, dbData.Provider)
|
||||
err := s.resetSchema(dbData.Version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func (s *ImportService) importUploads(ctx context.Context, files []*zip.File) er
|
||||
}
|
||||
|
||||
// resetSchema drops the existing schema and migrates to the target version
|
||||
func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string) error {
|
||||
func (s *ImportService) resetSchema(targetVersion uint) error {
|
||||
sqlDb, err := s.db.DB()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get sql.DB: %w", err)
|
||||
@@ -155,11 +155,19 @@ func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string)
|
||||
return fmt.Errorf("failed to get migrate instance: %w", err)
|
||||
}
|
||||
|
||||
if s.db.Name() == "sqlite" {
|
||||
s.db.Exec("PRAGMA foreign_keys = OFF;")
|
||||
}
|
||||
|
||||
err = m.Drop()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to drop existing schema: %w", err)
|
||||
}
|
||||
|
||||
if s.db.Name() == "sqlite" {
|
||||
defer s.db.Exec("PRAGMA foreign_keys = ON;")
|
||||
}
|
||||
|
||||
// Needs to be called again to re-create the schema_migrations table
|
||||
m, err = utils.GetEmbeddedMigrateInstance(sqlDb)
|
||||
if err != nil {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
-- No-op in Postgres
|
||||
@@ -1 +0,0 @@
|
||||
-- No-op in Postgres
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This migration is part of v2
|
||||
|
||||
-- No-op in Postgres
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This migration is part of v2
|
||||
|
||||
-- No-op in Postgres
|
||||
@@ -1,3 +1,5 @@
|
||||
-- This migration is part of v2
|
||||
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
BEGIN;
|
||||
@@ -1,3 +1,5 @@
|
||||
-- This migration is part of v2
|
||||
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
BEGIN;
|
||||
Reference in New Issue
Block a user