fix: permit chart profile upserts
fix: permit chart profile upserts
This commit is contained in:
@@ -46,6 +46,7 @@ jobs:
|
||||
frontend/supabase/migrations/20260718100000_repair_missing_chart_profiles.sql \
|
||||
frontend/supabase/migrations/20260718102000_recover_missing_profile_rows.sql \
|
||||
frontend/supabase/migrations/20260718103000_profile_birth_time_declaration_grants.sql \
|
||||
frontend/supabase/migrations/20260718104000_chart_profiles_upsert_id_grant.sql \
|
||||
"$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/tmp/profile-migrations/"
|
||||
|
||||
- name: Apply profile migrations using VPS database URL
|
||||
@@ -74,7 +75,8 @@ jobs:
|
||||
tmp/profile-migrations/20260718080000_profiles_service_role_account_upsert_selects.sql \
|
||||
tmp/profile-migrations/20260718100000_repair_missing_chart_profiles.sql \
|
||||
tmp/profile-migrations/20260718102000_recover_missing_profile_rows.sql \
|
||||
tmp/profile-migrations/20260718103000_profile_birth_time_declaration_grants.sql
|
||||
tmp/profile-migrations/20260718103000_profile_birth_time_declaration_grants.sql \
|
||||
tmp/profile-migrations/20260718104000_chart_profiles_upsert_id_grant.sql
|
||||
do
|
||||
echo "applying $(basename "$SQL_FILE")"
|
||||
cat "$SQL_FILE" | docker run --rm -i postgres:16-alpine \
|
||||
|
||||
@@ -113,7 +113,7 @@ export function useBirthTimeGuidedJourney(input: GuidedJourneyInput): BirthTimeG
|
||||
publish: onJourney,
|
||||
})) latest.current = turn;
|
||||
}).catch((caught: unknown) => {
|
||||
setError(caught instanceof Error ? caught.message : "当前步骤暂时无法完成,请重试。");
|
||||
setError(birthTimeUserError(caught));
|
||||
}).finally(() => {
|
||||
release();
|
||||
setPending(false);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
begin;
|
||||
|
||||
-- PostgREST upsert may include the unchanged conflict key in its update set.
|
||||
grant update (id, role, profile, updated_at) on table public.chart_profiles to authenticated;
|
||||
|
||||
commit;
|
||||
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
import { birthTimeUserError } from "../src/lib/birth-time-user-error.ts";
|
||||
|
||||
@@ -12,3 +13,8 @@ test("birth-time errors never expose browser implementation messages", () => {
|
||||
test("birth-time errors preserve a safe server message", () => {
|
||||
assert.equal(birthTimeUserError(new Error("候选结果已变化")), "候选结果已变化");
|
||||
});
|
||||
|
||||
test("all guided journey mutations normalize implementation errors", () => {
|
||||
const source = readFileSync(new URL("../src/hooks/use-birth-time-guided-journey.ts", import.meta.url), "utf8");
|
||||
assert.equal((source.match(/setError\(birthTimeUserError\(caught\)\)/g) ?? []).length, 2);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
const migration = readFileSync(
|
||||
new URL("../supabase/migrations/20260718104000_chart_profiles_upsert_id_grant.sql", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("authenticated chart-profile upserts may update their unchanged conflict id", () => {
|
||||
assert.match(
|
||||
migration,
|
||||
/grant\s+update\s*\(\s*id\s*,\s*role\s*,\s*profile\s*,\s*updated_at\s*\)\s+on\s+table\s+public\.chart_profiles\s+to\s+authenticated/i,
|
||||
);
|
||||
});
|
||||
@@ -27,6 +27,7 @@ def test_profile_migration_workflow_includes_chart_library_and_birth_time_profil
|
||||
assert "20260718100000_repair_missing_chart_profiles.sql" in text
|
||||
assert "20260718102000_recover_missing_profile_rows.sql" in text
|
||||
assert "20260718103000_profile_birth_time_declaration_grants.sql" in text
|
||||
assert "20260718104000_chart_profiles_upsert_id_grant.sql" in text
|
||||
|
||||
|
||||
def test_profile_migration_workflow_does_not_reference_missing_sql_files() -> None:
|
||||
|
||||
Reference in New Issue
Block a user