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

Create new HeidiSQL command for Windows and WSL2 #2679

Merged
merged 8 commits into from Dec 29, 2020
Merged

Create new HeidiSQL command for Windows and WSL2 #2679

merged 8 commits into from Dec 29, 2020

Conversation

andreashager
Copy link
Contributor

The Problem/Issue/Bug:

Create a command for Windows/WSL2 that connects with the current project database (like ddev sequelpro).
Otherwise you always have to hardcode the database port and connect with database tool manually.

The command checks if i am on Windows directly or using DDEV with WSL2. The program used for this is HeidiSQL (https://www.heidisql.com/).

How this PR Solves The Problem:

This PR uses the Windows database tool HeidiSQL to connection to the database automatically from the command line.

Manual Testing Instructions:

Automated Testing Overview:

Related Issue Link(s):

Release/Deployment notes:

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2020

CLA assistant check
All committers have signed the CLA.

@rfay
Copy link
Member

rfay commented Dec 4, 2020

Thanks for this @andreashager ! Please do sign the CLA - it only takes a minute.

@andreashager
Copy link
Contributor Author

No problem @rfay 🙂 Sorry I forgot to do this, but it should be done now 🎉

## Description: Run HeidiSQL against current db
## Usage: heidisql
## Example: "ddev heidisql"
## OSTypes: linux,windows
Copy link
Member

Choose a reason for hiding this comment

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

The other script commands show only if the executable is installed. Seems we ought to be able to do that here as well, except for the problem of two-environments one-machine.

"win*"* | "msys"*)
# 'C:\Program Files\HeidiSQL\heidisql.exe'
# You may need to add it to your system %PATH% or change the path here
'C:\Program Files\HeidiSQL\heidisql.exe' "$arguments"
Copy link
Member

Choose a reason for hiding this comment

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

Does this work if you're in git-bash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't tried it in Git-bash, i tried it in the Windows Terminal and there it worked :)


"win*"* | "msys"*)
# 'C:\Program Files\HeidiSQL\heidisql.exe'
# You may need to add it to your system %PATH% or change the path here
Copy link
Member

Choose a reason for hiding this comment

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

The comment here isn't correct is it, since pathing is not used... It probably should be used, and remove the hard-coded path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I overtook the comment from the the MySQL Workbench example ;) HeidiSQL did not write itself into the path variable, so we have to use the hard coded path here 😞

@rfay
Copy link
Member

rfay commented Dec 8, 2020

I took the liberty of extending this a bit, coming up with multiple binary locations, and a WSL2 identifier. Then I couldn't help myself and tried to tack TablePlus in there because it was all the same testing mess, going back and forth between operating systems. But I'm blocked on TablePlus/TablePlus#2224 for TablePlus. If we don't get an answer there we'll back TablePlus changes out of here.

@rfay
Copy link
Member

rfay commented Dec 10, 2020

Per TablePlus/TablePlus-Windows#342 I guess there's no way to make TablePlus work on Windows at this point, so I'll pull out the stuff I did with TablePlus.

@rfay
Copy link
Member

rfay commented Dec 10, 2020

Removed the TablePlus changes, rebased.

@rfay
Copy link
Member

rfay commented Dec 11, 2020

@andreashager (and anybody else) I'd sure appreciate it if you could test this in your environment on both Windows and WSL2. The artifacts are at https://app.circleci.com/pipelines/github/drud/ddev/3291/workflows/b645feb6-c379-4ec3-bcbd-a1ed9b428d1b/jobs/29795/artifacts

This is a great step forward for Windows and WSL2 users!

@andreashager
Copy link
Contributor Author

@andreashager (and anybody else) I'd sure appreciate it if you could test this in your environment on both Windows and WSL2. The artifacts are at https://app.circleci.com/pipelines/github/drud/ddev/3291/workflows/b645feb6-c379-4ec3-bcbd-a1ed9b428d1b/jobs/29795/artifacts

This is a great step forward for Windows and WSL2 users!

@rfay How can I test this specific version of DDEV? Can I clone the repository to a specific path or do I have to overtake the changes to the specific files manually? 😕

@rfay
Copy link
Member

rfay commented Dec 14, 2020

Hi @andreashager you can download the artifacts at the link I gave. You'll need to get the tar for your operating system, for example ~/artifacts/ddev_macos-amd64.v1.16.2-10-ga88e3908.tar.gz for macOS. Then untar it. There's a ddev binary in there. You can put it in your path. If you use homebrew you'll want to brew unlink ddev temporarily so you are confident you're using this one. Let me know if that's enough instruction.

@andreashager
Copy link
Contributor Author

Sorry for my late andere, I will test it as soon as I am Back in the Office 😊

@andreashager
Copy link
Contributor Author

@rfay

I tested it today for WSL2 (Ubuntu 20.04 LTS) and for Windows 10 20H2.

  • WSL2 - No problem, the HeidiSQL command launches the HeidiSQL database program on my Windows Host 👍🏻
  • Windows 10 - Here i only the this error "Error: unknown command "heidisql" for "ddev" Run 'ddev --help' for usage." If I run ddev help, the heidisql command is not listed there 😞

How can I debug this? Do you need furhter information? ☺️

@rfay
Copy link
Member

rfay commented Dec 23, 2020

@andreashager thanks for testing!

  • Did you install the Linux version of ddev from the above link? If so, ddev --version should show the same version in WSL2 as it does on the Windows side.
  • Were you issuing the command ddev heidisql in the project directory?
  • Does ~/.ddev/commands/host/heidisql exist?

Thanks!

@rfay
Copy link
Member

rfay commented Dec 28, 2020

I'm able to recreate the problem you describe using PS and cmd. It works fine in git-bash. And it also works fine in PS and cmd once the global ~/.ddev/commands/host/heidisql has been created by running ddev in git-bash. But if you delete ~/.ddev/commands/host/heidisql, it doesn't get recreated by running ddev in cmd/PS

@rfay
Copy link
Member

rfay commented Dec 28, 2020

I had two problems testing:

  • I had the wrong %PATH% and the installed ddev was coming in before the download/test ddev binary
  • You have to use this in a project directory for it to show up.

@rfay rfay changed the title Create new HeidiSQL command Create new HeidiSQL command for Windows and WSL2 Dec 29, 2020
@rfay rfay merged commit 2ff4f0b into ddev:master Dec 29, 2020
@andreashager
Copy link
Contributor Author

@rfay Thanks for merging and helping to debug/test 🥳 I will try this as soon as the new release is out 🥰

Answers to your questions above (I guess you dont need it anymore 😅):

  • Did you install the Linux version of ddev from the above link? If so, ddev --version should show the same version in WSL2 as it does on the Windows side.

    I installed the version from the above link yes - the version had the commit hash appended. Both, Linux and Windows showed the same version Number with the commit hash.

  • Does ~/.ddev/commands/host/heidisql exist?

    Yes it does on WSL2, on Windows not 😞

  • I had the wrong %PATH% and the installed ddev was coming in before the download/test ddev binary

    I tested it directly in the directory with the downloaded version but maybe this was also my problem.

@andreashager andreashager deleted the heidisql-command branch January 4, 2021 21:05
diegoe added a commit to diegoe/ddev that referenced this pull request Jun 17, 2021
In 2ff4f0b, triming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

Fixes: ddev#3051

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
diegoe added a commit to diegoe/ddev that referenced this pull request Jun 17, 2021
In 2ff4f0b, triming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
diegoe added a commit to diegoe/ddev that referenced this pull request Jun 17, 2021
In 2ff4f0b, trimming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
rfay pushed a commit to diegoe/ddev that referenced this pull request Jul 12, 2021
In 2ff4f0b, trimming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants