saveinmed/backend/internal/repository/postgres/migrations/0009_financials.sql
Gabbriiel 90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core)
- Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token
- Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers
- Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 04:56:37 -06:00

39 lines
1.6 KiB
SQL

CREATE TABLE IF NOT EXISTS company_documents (
id UUID PRIMARY KEY,
company_id UUID NOT NULL REFERENCES companies(id),
type TEXT NOT NULL, -- 'CNPJ', 'PERMIT', 'IDENTITY'
url TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'PENDING', -- 'PENDING', 'APPROVED', 'REJECTED'
rejection_reason TEXT,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_company_documents_company_id ON company_documents (company_id);
CREATE TABLE IF NOT EXISTS ledger_entries (
id UUID PRIMARY KEY,
company_id UUID NOT NULL REFERENCES companies(id),
amount_cents BIGINT NOT NULL, -- Positive for credit, Negative for debit
type TEXT NOT NULL, -- 'SALE', 'FEE', 'WITHDRAWAL', 'REFUND'
description TEXT NOT NULL,
reference_id UUID, -- order_id or withdrawal_id
created_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_ledger_entries_company_id ON ledger_entries (company_id);
CREATE INDEX IF NOT EXISTS idx_ledger_entries_created_at ON ledger_entries (created_at);
CREATE TABLE IF NOT EXISTS withdrawals (
id UUID PRIMARY KEY,
company_id UUID NOT NULL REFERENCES companies(id),
amount_cents BIGINT NOT NULL,
status TEXT NOT NULL DEFAULT 'PENDING', -- 'PENDING', 'APPROVED', 'PAID', 'REJECTED'
bank_account_info TEXT NOT NULL, -- JSON or text description
transaction_id TEXT, -- Bank transaction ID if paid
rejection_reason TEXT,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_withdrawals_company_id ON withdrawals (company_id);