Add accounting, AI, and core catalog database schema#98
Merged
Conversation
- Create acct_account_types, acct_accounts, acct_counterparties tables - Add acct_documents, acct_document_lines, acct_document_sequences - Implement acct_document_types, acct_document_applications - Add acct_fiscal_periods and acct_journal_entries with foreign keys
… tables - Create acct_journal_entry_lines table with debit/credit and currency handling - Add acct_settings for versioned accounting configuration (base currency, fx accounts) - Implement AI module: agents, models, providers, versions, sessions, tool calls - Add ai_usage_logs for immutable API call tracking and cost calculation
…nagement - Create core_addresses table with geolocation and ownership links - Add core_items unified catalog with physical/digital/service classification - Implement core_item_variants and variant attribute values - Add core_branches and core_legal_entities for multi-entity structure - Create core_item_attributes, options, values, and category relationships - Add core_item_categories hierarchy and items-categories mapping
- Create crm_accounts, crm_contacts, crm_leads, crm_opportunities - Add foreign keys to usr_accounts, usr_users, acct_counterparties - Unify collation to utf8mb4_general_ci across existing migrations
- Create hr_employees master record with account and counterparty links - Add hr_contracts, hr_departments, hr_job_levels, hr_positions - Implement hr_employee_assignments for organizational history tracking - Add hr_compensation_items, hr_employee_benefits, hr_employee_loans - Create hr_employee_identifications, hr_employee_leaves - Add competency catalog: hr_competency_categories, hr_competencies, hr_competency_levels - Implement performance review cycles, rating scales, cycle employees, review assignments - Add hr_employee_objectives and progress tracking
- Add hr_performance_review_templates, template_sections, template_questions - Create hr_performance_reviews, review_responses, review_results and details - Add hr_positions, hr_salary_history, hr_terminations and termination_settlements - Normalize collation to utf8mb4_general_ci across existing hr tables
DiegoAlejandroNino
previously approved these changes
Apr 13, 2026
Auto-generated by GitHub Actions workflow PR: #98 Workflow: Auto Version & Changelog Run ID: 24351672797
|
🚀 Auto-versioning complete! 📦 New version:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Summary
This PR introduces comprehensive database migrations for the accounting module, AI agent infrastructure, and unified core catalog. It establishes the foundational schema for chart of accounts, journal entries, fiscal periods, counterparties, documents, AI providers/models/agents/sessions/usage tracking, items with attributes/variants/categories, addresses, branches, and legal entities. Additionally, it standardizes collation to
utf8mb4_general_cion two existing tables.🎯 Type of Change
🔍 What Changed
Added
Accounting module migrations:
acct_account_types– defines account categories (asset, liability, equity, revenue, expense) with normal balance and financial statement classification.acct_accounts– chart of accounts with hierarchical parent-child relationships, posting controls, and system protection.acct_counterparties– third parties involved in transactions (customers, suppliers, employees, banks, etc.).acct_documents– business documents (invoices, receipts, payments) linking to journal entries and counterparties.acct_document_applications– links payments to documents for settlement tracking.acct_document_sequences– configurable numbering sequences for document codes.acct_document_lines– line items within documents with account mapping and inventory references.acct_document_types– defines document behavior (affects accounting, requires counterparty, auto-post).acct_fiscal_periods– fiscal years, quarters, months with closing status and hierarchy.acct_journal_entries– core accounting transactions with status (draft/posted/reversed), source, and fiscal period linkage.acct_journal_entry_lines– debit/credit lines with multi-currency support and counterparty association.acct_settings– versioned accounting configuration (base currency, FX gain/loss accounts, rounding precision).AI module migrations:
ai_providers– catalog of AI service providers (Anthropic, OpenAI, Google, etc.).ai_models– specific models per provider with capabilities (tools, vision, JSON mode) and cost tracking.ai_agents– AI agent identities with type (assistant/task/pipeline) and account scoping.ai_agent_versions– versioned snapshots of agent configuration (model, system prompt, hyperparameters).ai_sessions– execution context for agent interactions, tracking token usage and cost.ai_messages– (implied via foreign key references in tool calls and usage logs).ai_tool_calls– records every tool invocation made by an agent with arguments and results.ai_usage_logs– immutable ledger of every AI provider API call for cost analysis and audit.Core module migrations:
core_addresses– reusable physical addresses for accounts, counterparties, orders, and billing.core_items– unified catalog for physical goods, digital products, and services.core_item_variants– sellable variants of items (e.g., size/color combinations).core_item_attributes– attribute definitions with data types and variant-axis flags.core_item_attribute_options– predefined selectable values for attributes.core_item_attribute_values– EAV storage for item attribute values.core_item_categories– hierarchical category tree for item classification.core_legal_entities– legal entities for multi-entity operations.core_branches– operational branches linked to legal entities.Changed
migrations/20260125165529-create-credentials-table.js– collation changed fromutf8mb4_0900_ai_citoutf8mb4_general_ci.migrations/20260125170536-create-otp-codes-table.js– collation changed fromutf8mb4_0900_ai_citoutf8mb4_general_ci.Fixed
Removed
🧪 Testing
Test Instructions:
credentialsandotp_codestables are applied without data loss.downmigrations successfully drop tables in reverse order without constraint errors.🔗 Related Issues
📝 Additional Notes
✅ Checklist