fix: Ensure users table has required columns for agent sync and add explicit migrations.

This commit is contained in:
Haitao Pan 2026-02-06 13:10:18 +08:00
parent 4503b053f7
commit c366e96e5d
3 changed files with 5 additions and 0 deletions

1
.gitignore vendored
View File

@ -62,3 +62,4 @@ out/
target/
xcontrol-account
account-export.yaml
accountsvc

Binary file not shown.

View File

@ -503,6 +503,10 @@ func applyRBACSchema(ctx context.Context, db *gorm.DB, driver string) error {
proxy_uuid UUID NOT NULL DEFAULT gen_random_uuid(),
proxy_uuid_expires_at TIMESTAMPTZ
)`,
`ALTER TABLE public.users ADD COLUMN IF NOT EXISTS proxy_uuid UUID NOT NULL DEFAULT gen_random_uuid()`,
`ALTER TABLE public.users ADD COLUMN IF NOT EXISTS proxy_uuid_expires_at TIMESTAMPTZ`,
`ALTER TABLE public.users ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ NOT NULL DEFAULT now()`,
`ALTER TABLE public.users ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT now()`,
`CREATE TABLE IF NOT EXISTS public.email_blacklist (
email TEXT PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()