feat: 添加账号删除功能
This commit is contained in:
@@ -124,7 +124,7 @@ def upgrade() -> None:
|
||||
lifetime_spent,
|
||||
version
|
||||
)
|
||||
VALUES (new.id, 100, 0, 100, 0, 0)
|
||||
VALUES (new.id, 60, 0, 60, 0, 0)
|
||||
ON CONFLICT (user_id) DO NOTHING;
|
||||
|
||||
INSERT INTO public.points_ledger (
|
||||
@@ -144,8 +144,8 @@ def upgrade() -> None:
|
||||
v_ledger_id,
|
||||
new.id,
|
||||
1,
|
||||
100,
|
||||
100,
|
||||
60,
|
||||
60,
|
||||
'register',
|
||||
null,
|
||||
null,
|
||||
@@ -269,7 +269,7 @@ def downgrade() -> None:
|
||||
lifetime_spent,
|
||||
version
|
||||
)
|
||||
VALUES (new.id, 100, 0, 100, 0, 0)
|
||||
VALUES (new.id, 60, 0, 60, 0, 0)
|
||||
ON CONFLICT (user_id) DO NOTHING;
|
||||
|
||||
INSERT INTO public.points_ledger (
|
||||
@@ -289,8 +289,8 @@ def downgrade() -> None:
|
||||
v_ledger_id,
|
||||
new.id,
|
||||
1,
|
||||
100,
|
||||
100,
|
||||
60,
|
||||
60,
|
||||
'register',
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
"""update signup welcome points from 100 to 60
|
||||
|
||||
Revision ID: 20260409_0004
|
||||
Revises: 20260407_0003
|
||||
Create Date: 2026-04-09 00:00:00
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20260409_0004"
|
||||
down_revision: Union[str, Sequence[str], None] = "20260407_0003"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def _rewrite_signup_function(*, from_points: int, to_points: int) -> None:
|
||||
op.execute(
|
||||
f"""
|
||||
DO $$
|
||||
DECLARE
|
||||
v_def text;
|
||||
v_from_points text := '{from_points}';
|
||||
v_to_points text := '{to_points}';
|
||||
BEGIN
|
||||
SELECT pg_get_functiondef('public.initialize_profile_and_invite_code_on_signup()'::regprocedure)
|
||||
INTO v_def;
|
||||
|
||||
v_def := regexp_replace(
|
||||
v_def,
|
||||
'VALUES \\(new\\.id,\\s*' || v_from_points || ',\\s*0,\\s*' || v_from_points || ',\\s*0,\\s*0\\)',
|
||||
'VALUES (new.id, ' || v_to_points || ', 0, ' || v_to_points || ', 0, 0)'
|
||||
);
|
||||
|
||||
v_def := regexp_replace(
|
||||
v_def,
|
||||
E'\\n\\s*' || v_from_points || ',\\n\\s*' || v_from_points || ',\\n\\s*''register''',
|
||||
E'\\n ' || v_to_points || ',\\n ' || v_to_points || ',\\n ''register'''
|
||||
);
|
||||
|
||||
EXECUTE v_def;
|
||||
END;
|
||||
$$;
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
_rewrite_signup_function(from_points=100, to_points=60)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
_rewrite_signup_function(from_points=60, to_points=100)
|
||||
Reference in New Issue
Block a user