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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change UniqueConstraint for SQL Server (and Postgres) database support #6607
Conversation
Manage this branch in SquashTest this branch here: https://davidjbfix-mssql-migration-b1acg.squash.io |
Thanks @davidjb! This looks really good. Can you give us any advice on how to test against SQL Server, either locally or in CI? I don't think any of the core team have much SQL Server expertise. |
@tomdyson Thanks for the feedback. For sure. Here鈥檚 my cheat sheet for running wagtail tests on all the various db backends: https://gist.github.com/davidjb/643272824f469386f933e7a4e081a81e - SQL Server is down the bottom. I spin up a Docker container for each server - thankfully SQL Server was released for Linux, install the requisite engine and client and run the tests. In this case, the install instructions are for Mac but adaptable for Linux - not sure about Windows. For CI, you could run the Docker container and then the tests; I鈥檝e done this style of thing on Travis. If that doc is helpful, feel free to take it for the wagtail docs or I can submit a PR.
Edit: ESSolutions/django-mssql-backend#86 was now merged; I've updated my gist accordingly. The change hasn't been released yet, still requires installing from git. |
This fixes wagtail#6393 by modifying the constraint to use an IN condition which supports both Postgres and SQL Server. Previously, the `|` (OR) condition was only supported by Postgres because SQL Server only supports AND conditions. The implementation follows suggestions from @gasman in wagtail#6393 (comment): * Migration 0050 is modified to not break on SQL Server * Added migration 0060 to add or replace the constraint Additionally, this allows for and documents a `DATABASE_DRIVER` env variable to be set for testing, to allow a different SQL Server driver (e.g. FreeTDS on Mac/Linux); and adds the specific `host_is_server` option for FreeTDS (won't affect SQL Server Native Client on CI).
01401e8
to
fd0a566
Compare
Rebased on the latest |
This fixes #6393 by modifying the constraint to use an IN condition which supports both Postgres and SQL Server. Previously, the `|` (OR) condition was only supported by Postgres because SQL Server only supports AND conditions. The implementation follows suggestions from @gasman in #6393 (comment): * Migration 0050 is modified to not break on SQL Server * Added migration 0060 to add or replace the constraint Additionally, this allows for and documents a `DATABASE_DRIVER` env variable to be set for testing, to allow a different SQL Server driver (e.g. FreeTDS on Mac/Linux); and adds the specific `host_is_server` option for FreeTDS (won't affect SQL Server Native Client on CI).
Thanks @gasman - much appreciated. I also created the work-in-progress ESSolutions/django-mssql-backend#97 with the database backend to catch situations where an unsupportable constraint is present. |
This fixes #6393 by modifying the constraint to use an IN condition which supports both Postgres and SQL Server. Previously, the
|
(OR) condition was only supported by Postgres because SQL Server only supports AND conditions, meaning that migrations would crash mid-way through on the latter.The implementation follows suggestions from @gasman in #6393 (comment):
Additionally, this allows for and documents a
DATABASE_DRIVER
env variable to be set for testing, to allow a different SQL Server driver (e.g. FreeTDS on Mac/Linux); and adds the specifichost_is_server
option for FreeTDS (won't affect SQL Server Native Client on CI).Note: 8 other database-related tests are failing (see https://gist.github.com/davidjb/be2849b5bbb5d4c3e3db1e317d644a17 for log) when tested against SQL Server; this could be a FreeTDS driver issue or something else but they don't seem related to this PR.
Other database backends (SQLite, MySQL) see their tests pass.
This PR depends on changes in #6585, hence why it has 2 commits present. Once that other is merged, it's just one.
Thanks for contributing to Wagtail! 馃帀
Before submitting, please review the contributor guidelines https://docs.wagtail.io/en/latest/contributing/index.html and check the following:
make lint
from the Wagtail root)