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

We should add unique constraint on Database name + engine (driver) #11106

Open
PatButlerTR opened this issue Oct 9, 2019 · 2 comments · May be fixed by #11228
Open

We should add unique constraint on Database name + engine (driver) #11106

PatButlerTR opened this issue Oct 9, 2019 · 2 comments · May be fixed by #11228

Comments

@PatButlerTR
Copy link
Contributor

@PatButlerTR PatButlerTR commented Oct 9, 2019

Describe the bug
POST to /api/database will overwrite an existing database instead of erroring

To Reproduce
Create a database with a POST to /api/database.
Run the same call again.

Expected behavior
Expect Metabase to error and say, "Database with name 'foo' already exists"

Actual behavior
Metabase gives another 200 and will overwrite any previous database config with the same name.

Information about your Metabase Installation:
Metabase 0.33.3

@camsaul
Copy link
Member

@camsaul camsaul commented Oct 9, 2019

We don't have a unique constraint on database name so actually what is happening is it's creating a new database with the same name. But I do think we should add a unique constraint for database name + engine (i.e. postgres or sqlserver) so you can't have two databases of the same name and same DB engine. Our test suite creates databases of the same name across multiple engines/drivers and loads the same data to each so I don't think a unique constraint on name wold be desirable.

@camsaul camsaul changed the title POST to /api/database will overwrite an existing database instead of erroring We should add unique constraint on Database name + engine (driver) Oct 9, 2019
@PatButlerTR
Copy link
Contributor Author

@PatButlerTR PatButlerTR commented Oct 10, 2019

Ah got it. Agreed, I think the unique constraint for database name + engine would be beneficial.

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

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.