Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MySQL commands #225

Merged
merged 2 commits into from
Dec 7, 2024
Merged

Fix MySQL commands #225

merged 2 commits into from
Dec 7, 2024

Conversation

frenck
Copy link
Member

@frenck frenck commented Dec 7, 2024

Proposed Changes

  • mysql is being replaced by mariadb (alias is now deprecated).
  • The MariaDB CLI now uses SSL by default, but HA doesn't.

Summary by CodeRabbit

  • New Features

    • Enhanced Todo Tree extension to scan the entire workspace for TODO comments.
  • Bug Fixes

    • Updated database commands in phpMyAdmin configuration to use MariaDB instead of MySQL, improving compatibility with the current database management system.
  • Chores

    • Added --skip-ssl option to database commands for improved connection settings.

@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Dec 7, 2024
Copy link

coderabbitai bot commented Dec 7, 2024

Walkthrough

The changes involve two main modifications. First, in the .vscode/settings.json file, a new setting has been added to configure the Todo Tree extension to scan the entire workspace for TODO comments. Secondly, the script for configuring phpMyAdmin in a Home Assistant Community Add-on has been updated to replace mysql commands with mariadb, including the addition of the --skip-ssl option for database connection commands.

Changes

File Path Change Summary
.vscode/settings.json Added setting: "todo-tree.tree.scanMode": "workspace" to scan the entire workspace for TODOs.
phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/init-phpmyadmin/run Replaced mysql commands with mariadb commands; added --skip-ssl option for database connections.

Poem

In the workspace where ideas bloom,
A tree of TODOs finds more room.
With Maria's grace, we shift our way,
To better manage tasks each day.
Hops of joy in code we weave,
A brighter path, we all believe! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/init-phpmyadmin/run (2)

27-31: LGTM! Consider documenting SSL security implications.

The change from mysql to mariadb command and addition of --skip-ssl is correct and aligns with the PR objectives. However, disabling SSL removes transport layer security.

Consider adding a comment explaining why SSL is disabled:

        --skip-column-names \
+       # SSL disabled as Home Assistant doesn't support it yet
        --skip-ssl \

37-41: Add error handling for database creation.

The database creation command lacks error handling and success logging.

Consider wrapping the database creation in error handling:

    bashio::log.info "Creating database for phpMyAdmin"
+   if ! \
    mariadb \
        -u "${username}" -p"${password}" \
        -h "${host}" -P "${port}" \
        --skip-ssl \
            < /var/www/phpmyadmin/sql/create_tables.sql
+   then
+       bashio::log.error "Failed to create phpMyAdmin database"
+       exit 1
+   fi
+   bashio::log.info "Successfully created phpMyAdmin database"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9a989d7 and e3b3085.

📒 Files selected for processing (2)
  • .vscode/settings.json (1 hunks)
  • phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/init-phpmyadmin/run (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .vscode/settings.json

Comment on lines +37 to +40
mariadb \
-u "${username}" -p"${password}" \
-h "${host}" -P "${port}" \
--skip-ssl \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Schema file location issue needs attention

The schema file /var/www/phpmyadmin/sql/create_tables.sql should be present in the phpMyAdmin package as it's part of the standard distribution, but it might have been removed during the Docker image build. Looking at the Dockerfile, there's a cleanup section that removes several directories but doesn't explicitly mention the sql directory:

&& rm -f -r \
    /tmp/* \
    /etc/nginx \
    /var/www/phpmyadmin/setup \
    /var/www/phpmyadmin/examples \
    /var/www/phpmyadmin/test/ \
    /var/www/phpmyadmin/po \
    /var/www/phpmyadmin/composer.json \
    /var/www/phpmyadmin/RELEASE-DATE-*

The initialization script expects this file to exist but our verification shows it's missing. This needs to be fixed to ensure proper database initialization.

  • Ensure the sql directory and its contents are preserved during the Docker build process
  • Verify the schema file is present in phpMyAdmin 5.2.1 package before cleanup operations
🔗 Analysis chain

Verify schema file existence and accessibility.

The command changes look good, but let's verify the schema file exists and has correct permissions.


Let me search for the schema file in the repository to ensure we're looking at the correct path.


Let me try a different approach using ripgrep to search for any references to the schema file or SQL initialization in the codebase.


Let me check if the schema file is part of the phpMyAdmin installation package by looking at the Dockerfile or installation steps.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and permissions of the schema file

# Check if the file exists and show its permissions
ls -l /var/www/phpmyadmin/sql/create_tables.sql 2>/dev/null || echo "Schema file not found!"

# Check if the file is readable by the script's user
if [ -r "/var/www/phpmyadmin/sql/create_tables.sql" ]; then
    echo "Schema file is readable"
else
    echo "Schema file is not readable!"
fi

Length of output: 226


Script:

#!/bin/bash
# Search for create_tables.sql file in the repository
fd "create_tables.sql"

# Search for any SQL files that might contain table creation scripts
fd -e sql | grep -i "table"

Length of output: 50


Script:

#!/bin/bash
# Search for references to create_tables.sql or similar initialization files
rg -i "create.*tables\.sql"

# Look for SQL initialization or database setup references in the init script
rg -l "mariadb|mysql" phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/init-phpmyadmin/

# Check the content of the init script to understand the schema initialization
cat phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/init-phpmyadmin/run

Length of output: 1660


Script:

#!/bin/bash
# Check Dockerfile for phpMyAdmin installation
cat phpmyadmin/Dockerfile

# Look for any setup or installation scripts
fd -t f . phpmyadmin/rootfs/etc/s6-overlay/s6-rc.d/ -x cat {}

Length of output: 7917

@frenck frenck merged commit cda68af into main Dec 7, 2024
12 checks passed
@frenck frenck deleted the frenck-2024-0592 branch December 7, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant