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

Feature Request: Allow new databases/keyspaces to run in foreignKeyMode=managed by default (in vttestserver) #14661

Closed
janpio opened this issue Dec 2, 2023 · 6 comments · Fixed by #14665

Comments

@janpio
Copy link

janpio commented Dec 2, 2023

Feature Description

Currently one has to define all the keyspaces/databases for vttestserver before starting the container, as any CREATE DATABASE will just create a foreignKeyMode=unmanaged keyspace/database, and there is no way to change it at runtime either.

It would be great if one could configure vttestserver to default to managed instead.

Use Case(s)

We want to test our Prisma ORM against Vitess, with foreignKeyMode=managed. Our test suite works by creating a lot of databases for test isolation. That means we can unfortunately not gather or provide the list of all keyspaces/databases prior to starting the Docker container of vttestserver. (The list might even become too long for an env var, in our test setup.)

(Related question on how to confirm the mode functionally, not via SHOW KEYSPACES;: #14660)

@janpio janpio added Needs Triage This issue needs to be correctly labelled and triaged Type: Feature labels Dec 2, 2023
@GuptaManan100 GuptaManan100 added Component: Query Serving and removed Needs Triage This issue needs to be correctly labelled and triaged labels Dec 4, 2023
@GuptaManan100
Copy link
Member

GuptaManan100 commented Dec 4, 2023

I would think that after you have created a database, you can always run ApplyVschema command with a new Vschema that specifies the foreign key mode to managed. @harshit-gangal or @systay can confirm if I am right

@janpio
Copy link
Author

janpio commented Dec 4, 2023

That would be pretty cool.
Bonus question: How can I apply that via vttestserver, which we run the tests on?

@GuptaManan100
Copy link
Member

I just verified, it currently does't work with vttestserver, because of the hard-coded bind address it provides to vtcombo. I am working on fixing this. Work in progress PR - #14665

@GuptaManan100
Copy link
Member

I was able to test my changes and make the required adjustments to get vtctdclient commands to work with vttestserver - #14665

@GuptaManan100
Copy link
Member

@janpio once that PR is merged, I believe you will be able to use it. I have added all the steps I followed to create a new database in vttestserver and then change its foreign key mode to managed. Please follow those steps and it should work as intended.

@GuptaManan100
Copy link
Member

@janpio Please let me know if you have any other concerns, but I believe the recent changes should fix your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants