Skip to content

The only tool you need to know what is happening and how to fix it.

integrations should decide on the migration tables + proper 403 handling

ddux95f6fb2f9786
diff --git a/backend/app/migrations/migrations.go b/backend/app/migrations/migrations.go
index b8b77a78..e1cf7a82 100644
--- a/backend/app/migrations/migrations.go
+++ b/backend/app/migrations/migrations.go
@@ -16,6 +16,7 @@ import (
type ExtensionMigration struct {
Source embed.FS
Path string
+ Table string // unique migration table name per extension
}
var ExtensionPostgresMigrations []ExtensionMigration
@@ -98,8 +99,13 @@ func runExtensionMigrations(db *sql.DB, ext ExtensionMigration) error {
return fmt.Errorf("failed to create extension migration source: %w", err)
}
+ tableName := ext.Table
+ if tableName == "" {
+ tableName = "schema_migrations_ext"
+ }
+
driver, err := migratePg.WithInstance(db, &migratePg.Config{
- MigrationsTable: "schema_migrations_ext",
+ MigrationsTable: tableName,
})
if err != nil {
return fmt.Errorf("failed to create extension migration driver: %w", err)
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 9cc01c6b..f76b327b 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -1,4 +1,5 @@
import { authState } from './state/auth.svelte';
+import { toast } from 'svelte-sonner';
const BASE_URL = '/api';
@@ -41,6 +42,18 @@ async function request(method: string, endpoint: string, data?: unknown, options
throw new Error('Unauthorized');
}
+ if (response.status === 403) {
+ const currentPath = window.location.pathname;
+ if (currentPath === '/' || currentPath === '') {
+ authState.logout();
+ window.location.href = '/login';
+ } else {
+ toast.warning("You don't have permission to access that feature", { position: 'top-center' });
+ window.location.href = '/';
+ }
+ throw new Error('Forbidden');
+ }
+
if (!response.ok) {
const error = new Error(`API Error: ${response.statusText}`) as Error & { status: number };
error.status = response.status;