fix(db): 重编号合并后撞号 migration,并修 admin e2e base
将 015–023 双文件冲突线性化为 015–050;提供已有库 schema_migrations 修复脚本;admin Playwright 对齐 /psy/admin/ 预览路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
-- ECR-015 RedemptionCode
|
||||
|
||||
CREATE TABLE IF NOT EXISTS redemption_batches (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
label varchar(64) NOT NULL,
|
||||
plan_code varchar(32) NOT NULL REFERENCES membership_plans(code),
|
||||
quantity int NOT NULL CHECK (quantity > 0 AND quantity <= 100),
|
||||
created_by uuid NOT NULL REFERENCES admin_accounts(id),
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS redemption_codes (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
batch_id uuid NOT NULL REFERENCES redemption_batches(id) ON DELETE CASCADE,
|
||||
code varchar(32) NOT NULL UNIQUE,
|
||||
plan_code varchar(32) NOT NULL REFERENCES membership_plans(code),
|
||||
status varchar(16) NOT NULL DEFAULT 'unused'
|
||||
CHECK (status IN ('unused','redeemed','disabled')),
|
||||
redeemed_by uuid NULL REFERENCES users(id),
|
||||
redeemed_at timestamptz NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_redemption_codes_batch ON redemption_codes(batch_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_redemption_codes_status ON redemption_codes(status);
|
||||
|
||||
INSERT INTO admin_role_permissions(role_id, code)
|
||||
SELECT r.id, p.code
|
||||
FROM admin_roles r
|
||||
CROSS JOIN (VALUES
|
||||
('admin.membership.codes.read'),
|
||||
('admin.membership.codes.write')
|
||||
) AS p(code)
|
||||
WHERE r.name = 'super_admin'
|
||||
ON CONFLICT DO NOTHING;
|
||||
Reference in New Issue
Block a user