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

Unable to pull database from platform.sh if more than one exists #4415

Closed
1 task done
bserem opened this issue Nov 30, 2022 · 6 comments
Closed
1 task done

Unable to pull database from platform.sh if more than one exists #4415

bserem opened this issue Nov 30, 2022 · 6 comments

Comments

@bserem
Copy link
Collaborator

bserem commented Nov 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Run a Diagnostic and Paste Link Here

It passes, but contains several project/client names so I haven't uploaded it. I can do so if absolutely required.

Expected Behavior

ddev pull platform --skip-files should be able to fetch and import a database dump.

Actual Behavior

When more than one DB is configured, platform expects a parameter for which DB to work with.

Authenticating...
Obtaining database...
More than one relationship found.
Use the --relationship (-r) option to specify a relationship. Options:
    legacy
    database
Pull failed: Failed to exec #set -x   # You can enable bash debugging output by uncommenting
set -eu -o pipefail
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
platform db:dump --yes --gzip --file=/var/www/html/.ddev/.downloads/db.sql.gz --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}"
 on web: exit status 1

Steps To Reproduce

  1. Create a project with multiple mysql relationships in platform.sh
  2. .platform.app.yaml
relationships:
  database: 'mysqldb:mysql'
  legacy: 'legacydb:mysql'
  redis: 'rediscache:redis'
  1. Run ddev pull platform --skip-files
  2. See error (under Actual Behavior above)

Anything else?

This fails (from inside DDEV):

platform db:dump --yes --gzip --file=/var/www/html/.ddev/.downloads/db.sql.gz --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}" -r 0
More than one relationship found.
Use the --relationship (-r) option to specify a relationship. Options:
    legacy
    database

This works (from inside DDEV):

platform db:dump --yes --gzip --file=/var/www/html/.ddev/.downloads/db.sql.gz --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}" -r database
Creating gzipped SQL dump file: /var/www/html/.ddev/.downloads/db.sql.gz

See the -r database at the end (stands for --relationship).

I understand this is an edge case, but it happened to me so it made sense to file it.

@rfay
Copy link
Member

rfay commented Nov 30, 2022

Also reported in

but it's better here.

@bserem
Copy link
Collaborator Author

bserem commented Nov 30, 2022

A good first start for this is to document what is needed to get the DB is such a case. It is not as "fancy" as pull, but it would make it easier for people.

It might also be possible to imporve on the work done on #4180

In any case, documentation is gonna be my first step here.

@rfay
Copy link
Member

rfay commented Nov 30, 2022

Currently ddev pull platform doesn't know about PLATFORM_RELATIONSHIPS so there are a few problems here. PLATFORM_RELATIONSHIPS is parsed/created by platformsh/ddev-platformsh addon, but we'd have to have it in platform.yaml for this to work OOTB, right?

@bserem
Copy link
Collaborator Author

bserem commented Nov 30, 2022

I can't say if relationships are of such importance that we need to have them in DDEV. To be honest, only 1/50 of the projects I deal with in platformsh uses it.
Might not be worth the time needed?

@lolautruche
Copy link
Collaborator

What would be nice here is to be able to forward options, or at least to specify which database you want (here platform db:dump is asking for the relationship name from .platform.app.yaml.
This is not related to how the ddev-platformsh addon builds $PLATFORM_RELATIONSHIPS for the app. It's only about ddev pull.

@rfay
Copy link
Member

rfay commented Dec 9, 2022

@lolautruche the PR downloads all databases, and allows you to specify which one should go into 'db' if you want. Would love to have you try it out,

@rfay rfay closed this as completed in 3104ea0 Dec 12, 2022
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

No branches or pull requests

3 participants