Add Mellat e-payment, videos/instructions CMS, and legacy domain lookup.
Store gateway credentials per business, initiate/verify Mellat at checkout, and resolve old CMS ids from domains in the migrate modal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
513673a7da
commit
d5e502cf77
@@ -0,0 +1,72 @@
|
||||
-- Instructions module (rich text + optional embedded video)
|
||||
|
||||
ALTER TYPE media_entity_type ADD VALUE IF NOT EXISTS 'instruction';
|
||||
|
||||
CREATE TABLE instructions (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
business_id BIGINT NOT NULL,
|
||||
author_id BIGINT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
title_fa VARCHAR(255),
|
||||
title_en VARCHAR(255),
|
||||
slug VARCHAR(255) NOT NULL,
|
||||
excerpt TEXT,
|
||||
content JSONB NOT NULL DEFAULT '{}',
|
||||
video_provider video_provider,
|
||||
embed_code TEXT,
|
||||
status content_status NOT NULL DEFAULT 'draft',
|
||||
featured_media_id BIGINT,
|
||||
published_at TIMESTAMPTZ,
|
||||
metadata JSONB NOT NULL DEFAULT '{}',
|
||||
old_id BIGINT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT instructions_business_slug_unique UNIQUE (business_id, slug),
|
||||
CONSTRAINT instructions_business_old_id_unique UNIQUE (business_id, old_id),
|
||||
CONSTRAINT instructions_business_id_fkey
|
||||
FOREIGN KEY (business_id) REFERENCES businesses (id) ON DELETE CASCADE,
|
||||
CONSTRAINT instructions_author_id_fkey
|
||||
FOREIGN KEY (author_id) REFERENCES users (id) ON DELETE SET NULL,
|
||||
CONSTRAINT instructions_featured_media_id_fkey
|
||||
FOREIGN KEY (featured_media_id) REFERENCES media (id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_instructions_business_id ON instructions (business_id);
|
||||
CREATE INDEX idx_instructions_business_status ON instructions (business_id, status);
|
||||
CREATE INDEX idx_instructions_business_published ON instructions (business_id, published_at DESC);
|
||||
CREATE INDEX idx_instructions_author_id ON instructions (author_id);
|
||||
|
||||
CREATE TRIGGER instructions_set_updated_at
|
||||
BEFORE UPDATE ON instructions
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION set_updated_at();
|
||||
|
||||
INSERT INTO permissions (name, slug, group_name, description) VALUES
|
||||
('View instructions', 'instructions.read', 'instructions', 'View instructions'),
|
||||
('Create instructions', 'instructions.create', 'instructions', 'Create instructions'),
|
||||
('Update instructions', 'instructions.update', 'instructions', 'Edit instructions'),
|
||||
('Delete instructions', 'instructions.delete', 'instructions', 'Delete instructions'),
|
||||
('Publish instructions', 'instructions.publish', 'instructions', 'Publish and unpublish instructions')
|
||||
ON CONFLICT (slug) DO NOTHING;
|
||||
|
||||
INSERT INTO role_permissions (role_id, permission_id)
|
||||
SELECT r.id, p.id
|
||||
FROM roles r
|
||||
JOIN permissions p ON p.slug LIKE 'instructions.%'
|
||||
WHERE r.slug IN ('business_owner', 'owner', 'admin')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO role_permissions (role_id, permission_id)
|
||||
SELECT r.id, p.id
|
||||
FROM roles r
|
||||
JOIN permissions p ON p.slug IN ('instructions.read', 'instructions.create', 'instructions.update', 'instructions.publish')
|
||||
WHERE r.slug = 'editor'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO role_permissions (role_id, permission_id)
|
||||
SELECT r.id, p.id
|
||||
FROM roles r
|
||||
JOIN permissions p ON p.slug = 'instructions.read'
|
||||
WHERE r.slug = 'viewer'
|
||||
ON CONFLICT DO NOTHING;
|
||||
Reference in New Issue
Block a user