-- ECR-014 MembershipPlan CREATE TABLE IF NOT EXISTS membership_plans ( code varchar(32) PRIMARY KEY, title varchar(64) NOT NULL, duration_days int NOT NULL CHECK (duration_days > 0), amount_cents int NOT NULL CHECK (amount_cents >= 0), active boolean NOT NULL DEFAULT true, updated_at timestamptz NOT NULL DEFAULT now() ); INSERT INTO membership_plans(code, title, duration_days, amount_cents, active) VALUES ('month', '月卡', 31, 2500, true), ('quarter', '季卡', 92, 6800, true), ('year', '年卡', 366, 19800, true) ON CONFLICT (code) DO NOTHING; INSERT INTO admin_role_permissions(role_id, code) SELECT r.id, p.code FROM admin_roles r CROSS JOIN (VALUES ('admin.membership.plans.read'), ('admin.membership.plans.write') ) AS p(code) WHERE r.name = 'super_admin' ON CONFLICT DO NOTHING;