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

Support CREATE TABLE IF NOT EXISTS #36

Open
egonelbre opened this issue Nov 6, 2018 · 2 comments
Open

Support CREATE TABLE IF NOT EXISTS #36

egonelbre opened this issue Nov 6, 2018 · 2 comments

Comments

@egonelbre
Copy link
Contributor

Currently the schema use CREATE TABLE to create the table. This will throw an error in case the table already exists. Using CREATE TABLE IF NOT EXISTS instead would give better results.

However there probably should be a way to verify whether the table matches the specified schema as well to avoid version skew. Basic checks such as whether the table columns match could be a good start.

@azdagron
Copy link

azdagron commented Nov 7, 2018

The Schema() call isn't really intended for database migration purposes. We've considered building in migration support directly into dbx but haven't settled on a set of features we'd like to support. In the meantime, using dbx alongside something like github.com/go-migrate/go-migrate works pretty good. It does require manual construction of the up/down statements, however.

@egonelbre
Copy link
Contributor Author

I'm not really looking for database migration at the moment, but rather detecting version skew.

Just realized that it could add a hash of the Schema() to some version table to detect this.

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

2 participants