Files
quyun-v2/backend/database/migrations/20251218171000_fix_tenant_users_status_default.sql

20 lines
668 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- +goose Up
-- +goose StatementBegin
-- tenant_users.status历史上默认值为 'active',但代码枚举使用 UserStatuspending_verify/verified/banned
-- 为避免新增成员落入未知状态,这里将默认值调整为 'verified',并修正存量 'active' -> 'verified'。
ALTER TABLE tenant_users
ALTER COLUMN status SET DEFAULT 'verified';
UPDATE tenant_users
SET status = 'verified'
WHERE status = 'active';
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
-- 回滚:恢复默认值为 'active'(不回滚数据修正)。
ALTER TABLE tenant_users
ALTER COLUMN status SET DEFAULT 'active';
-- +goose StatementEnd