mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-10 05:00:19 +08:00
恢复历史 backfill 兼容 live 账本
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'providers'
|
||||
AND column_name = 'enabled'
|
||||
) THEN
|
||||
UPDATE public.providers
|
||||
SET
|
||||
is_active = enabled,
|
||||
updated_at = NOW()
|
||||
WHERE enabled IS NOT NULL
|
||||
AND is_active IS DISTINCT FROM enabled;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'provider_endpoints'
|
||||
AND column_name = 'enabled'
|
||||
) THEN
|
||||
UPDATE public.provider_endpoints
|
||||
SET
|
||||
is_active = enabled,
|
||||
updated_at = NOW()
|
||||
WHERE enabled IS NOT NULL
|
||||
AND is_active IS DISTINCT FROM enabled;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'models'
|
||||
AND column_name = 'enabled'
|
||||
) THEN
|
||||
UPDATE public.models
|
||||
SET
|
||||
is_active = enabled,
|
||||
updated_at = NOW()
|
||||
WHERE enabled IS NOT NULL
|
||||
AND is_active IS DISTINCT FROM enabled;
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -312,7 +312,8 @@ mod tests {
|
||||
20260422110000,
|
||||
20260422120000,
|
||||
20260504120000,
|
||||
20260505120000
|
||||
20260505120000,
|
||||
20260517012000
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -328,7 +329,12 @@ mod tests {
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
versions,
|
||||
vec![20260422120000, 20260504120000, 20260505120000]
|
||||
vec![
|
||||
20260422120000,
|
||||
20260504120000,
|
||||
20260505120000,
|
||||
20260517012000
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -697,11 +703,12 @@ mod tests {
|
||||
let pending_before = pending_backfills(&pool)
|
||||
.await
|
||||
.expect("pending backfills should load");
|
||||
assert_eq!(pending_before.len(), 4);
|
||||
assert_eq!(pending_before.len(), 5);
|
||||
assert_eq!(pending_before[0].version, 20260422110000);
|
||||
assert_eq!(pending_before[1].version, 20260422120000);
|
||||
assert_eq!(pending_before[2].version, 20260504120000);
|
||||
assert_eq!(pending_before[3].version, 20260505120000);
|
||||
assert_eq!(pending_before[4].version, 20260517012000);
|
||||
|
||||
run_backfills(&pool)
|
||||
.await
|
||||
@@ -723,7 +730,8 @@ mod tests {
|
||||
20260422110000,
|
||||
20260422120000,
|
||||
20260504120000,
|
||||
20260505120000
|
||||
20260505120000,
|
||||
20260517012000
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1385,6 +1393,6 @@ mod tests {
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.expect("backfill count should load");
|
||||
assert_eq!(applied_count, 3);
|
||||
assert_eq!(applied_count, 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user