Automate SQL schema installation in install.js controller#8421
Draft
Automate SQL schema installation in install.js controller#8421
Conversation
Copilot
AI
changed the title
[WIP] Refactor installation process for automated database setup
Automate SQL schema installation in install.js controller
Oct 28, 2025
1aab6ba to
c32ebba
Compare
Co-authored-by: jniles <896472+jniles@users.noreply.github.com>
Co-authored-by: jniles <896472+jniles@users.noreply.github.com>
c32ebba to
4439f79
Compare
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.
The Bhima installation process currently requires manual execution of SQL scripts via shell scripts to build the database schema. This PR bundles SQL schema files with the application and automates their execution through the install.js controller, enabling zero-script deployment.
Implementation
Schema Setup Functions
getSQLFiles()- Discovers and sorts .sql files fromserver/models/by filenamecheckSchemaExists()- Queriesinformation_schemato verify if critical tables exist (idempotency)processSQLWithDelimiters()- Parses SQL files containingDELIMITERcommands for stored procedures/functionsexecuteSQLFile()- Executes SQL statements sequentially, ignoring duplicate object errors (ER_TABLE_EXISTS_ERROR,ER_SP_ALREADY_EXISTS, etc.)setupDatabaseSchema()- Orchestrates complete schema setup (exported for external use)Integration Point
Modified
proceedInstall()to callsetupDatabaseSchema()before creating enterprise/project/user:Behavior
information_schemaquery and skips executionBackward Compatibility
Existing installation process unchanged. If schema was already built via
build-database.sh, the existence check detects it and skips SQL execution.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.ionode install.mjs(dns block)https://storage.googleapis.com/chrome-for-testing-public/141.0.7390.78/linux64/chrome-headless-shell-linux64.zipnode install.mjs(http block)https://storage.googleapis.com/chrome-for-testing-public/141.0.7390.78/linux64/chrome-linux64.zipnode install.mjs(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Closes #8418.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.